美文网首页
PAT甲级1001-Python

PAT甲级1001-Python

作者: 逆风飞翔的鸟 | 来源:发表于2019-03-25 06:27 被阅读0次

1001 A+B Format

Calculate a+b and output the sum in standard format -- that is, the digits must be separated into groups of three by commas (unless there are less than four digits).

Input Specification:

Each input file contains one test case. Each case contains a pair of integers a and b where −10e6≤a,b≤10e6 . The numbers are separated by a space.

Output Specification:

For each test case, you should output the sum of a and b in one line. The sum must be written in the standard format.

Sample Input:

-1000000 9

Sample Output:

-999,991

提交结果

image.png

代码

if __name__=="__main__":
    line = input().split(" ")
    a,b = int(line[0]),int(line[1])
    print("{:,}".format(a+b))

积累

Python字符串的格式化函数,自己以后还要多积累多使用。
菜鸟教程

相关文章

  • PAT甲级1001-Python

    1001 A+B Format Calculate a+b and output the sum in stand...

  • PAT A1001 A+B Format (20)

    PAT A1001 A+B Format 原题链接PAT甲级题目目录(简书)PAT甲级题目目录(CSDN)在CSD...

  • 字符串输入问题

    PAT 甲级 1100 People on Mars count their numbers with base ...

  • PAT甲级题解 全部 JAVA版 持续更新

      临近过年,闲来无事。恰逢弟弟准备考PAT甲级,总是问我一些问题。又见网上PAT甲级多为c/c++版本的答案。罕...

  • PAT乙级1001-Python

    1001 害死人不偿命的(3n+1)猜想 (15 分) 注意:代码满分通过 卡拉兹(Callatz)猜想:对任何一...

  • PAT甲级 1043 Is It a Binary Search

    原题链接 PAT甲级 1043 Is It a Binary Search Tree (25 分) 题目大意 给定...

  • 2020-02-06

    PAT-甲级 做题笔记 目录 0000 做题 Tips 基本经验1003 Emergency (Dijkstra ...

  • Pat 甲级 1001

    太感人终于把1001做对了,一开始没有看清题目要求。产生各种各样的错误,最后又有编译错误。在Pat中Java的类名...

  • Pat 甲级1002

    在编译器中将边界设为1001 然后提交的代码边界设为1000,结果产生了部分正确的结果,实在是不应该,浪费太多时间...

  • PAT甲级题目

    先把会做的做了,emmmm 1006 水题,关键就是在于如何切分字符串而已,考的应该也就是字符串了: 1007 这...

网友评论

      本文标题:PAT甲级1001-Python

      本文链接:https://www.haomeiwen.com/subject/eenrvqtx.html