简单的除法计算器-python实现
简单的除法计算器
print("Please give me two numbers, and I'll divide them.")
print("Enter 'q' to quit")
while True:
first_number = input("Please input the first number:")
if first_number == "q":
break
second_number = input("Please input the second number: ")
if second_number == "q":
break
try:
answer = int(first_number) / int(second_number)
except ZeroDivisionError:
print("You can't divide by 0!")
except ValueError:
print("You can only input integers!")
else:
print(answer)
break
初学python,感觉python的逻辑很清晰,逐句执⾏,下⾯改⼀下代码,⼤家觉得输出会有什么不同吗?
网页计算器html代码print("Please give me two numbers, and I'll divide them.")
print("Enter 'q' to quit")
while True:
first_number = input("Please input the first number:")
second_number = input("Please input the second number: ")
if first_number == "q":
break
if second_number == "q":
break
try:
answer = int(first_number) / int(second_number)
except ZeroDivisionError:
print("You can't divide by 0!")
except ValueError:
print("You can only input integers!")
else:
print(answer)
break

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。