吾爱破解 - LCG - LSG |安卓破解|病毒分析|www.52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 3891|回复: 16
收起左侧

[Python 转载] Python 算术大师 新手挑战

[复制链接]
hkivanleeon68 发表于 2017-10-11 13:07
本帖最后由 hkivanleeon68 于 2017-10-11 13:14 编辑

捕获.JPG

大家好,今天带来第三篇挑战,“HackerRank” 的 Python 算术大师。与原文翻译... 有兴趣挑战的同学可以透过传送门进入。

备注:Arithmetic Operators (算术运算符)简单来说,就是 "用python 帮你完成小学数学作业",里面需要用 "加号,减号,乘号..."

挑战三传送门:https://www.hackerrank.com/challenges/python-arithmetic-operators/problem

Task (任务)
Read two integers from STDIN and print three lines where:
(读取两个正整数 从 内置输入 - "STDIN",然后打印三个单行)


1. The first line contains the sum of the two numbers.
(1. 第一行包含两个数字的总和)

2. The second line contains the difference of the two numbers (first - second).
(2. 第二行包含两个数字的相减, 第一减去第二)


3. The third line contains the product of the two numbers.
(3. 第三行包含相乘的结果)


Input Format(输入格式)


The first line contains the first integer, a. The second line contains the second integer, b.

(第一行包含第一个正整数,a 。第二行包含第二个正整数,b 。)


Constraints(条件限制)

捕获1.JPG
(a是大于或等于1,同时 a 小于或等于10的10次方, 就是 10的10次方大概是 10000000000...)
(b是大于或等于1,同时 b 小于或等于10的10次方)

Output Format(输出格式)

Print the three lines as explained above.
(打印以上所解释了的三个单行。)

Sample Input
(例子输入)
[Python] 纯文本查看 复制代码
3
2 


Sample Output
(例子输出)
[Python] 纯文本查看 复制代码
5
1
6



Explanation
(解释)
捕获2.JPG
3 加上 2 等于 5
3 减去 2 等于 1
3 乘以 2 等于 6



准备好就来吧...!!!


捕获3.JPG





最后附上小弟满分答案一枚.... 学习加油。。。

捕获4.JPG
[Python] 纯文本查看 复制代码
if __name__ == '__main__':
    a = int(input())
    b = int(input())
    print (a+b)
    print (a-b)
    print (a*b)





免费评分

参与人数 1吾爱币 +1 热心值 +1 收起 理由
Jamesstrange + 1 + 1 用心讨论,共获提升!

查看全部评分

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

mmaaiiooo 发表于 2017-10-11 15:59
[Python] 纯文本查看 复制代码
#!/usr/bin/python
# -*- coding: UTF-8 -*-
n = 1
a = int(input())
b = int(input())
while n<3:
    if 1<=a<=10**10 and 1<=b<=10**10:
       print("结果是:")
       print(a+b)
       print(a-b)
       print(a*b)
       break
    else:
        print("sorry,you put number is wrong,please reput it ")
        a = int(input())
        b = int(input())
        n = n + 1
liye1320 发表于 2017-10-11 14:38
鬼嫁 发表于 2017-10-11 13:35
if name = '__main__'
这个没看懂诶
求大佬指教

if __name__ == '__main__':

main函数入口
hyruur 发表于 2017-10-11 13:19
a5680497 发表于 2017-10-11 13:27
是不是完整版
鬼嫁 发表于 2017-10-11 13:35
if name = '__main__'
这个没看懂诶
求大佬指教
TNTcraft 发表于 2017-10-11 14:00
没有必要检索运行名和文件名是否一致吧?
星之痕迹 发表于 2017-10-11 14:59
没有做输入数值的条件限制判断吧~
匿名.Cae 发表于 2017-10-11 15:31
TNTcraft 发表于 2017-10-11 14:00
没有必要检索运行名和文件名是否一致吧?

良好的习惯吧
ing 发表于 2017-10-11 15:40
看不懂写的什么
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则 警告:本版块禁止灌水或回复与主题无关内容,违者重罚!

快速回复 收藏帖子 返回列表 搜索

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-6-14 17:23

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表