Advertisement
Guest User

Untitled

a guest
Oct 15th, 2019
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. def calc_simple():
  2.  
  3. while True:
  4. s = input("Введите операцию: (+,-,*,/): ")
  5. if s == '0': break
  6. if s in ('+','-','*','/'):
  7. x = float(input("Введите первое число: "))
  8. y = float(input("Введите второе число: "))
  9. if s == '+':
  10. print("%.2f" % (x+y))
  11. elif s == '-':
  12. print("%.2f" % (x-y))
  13. elif s == '*':
  14. print("%.2f" % (x*y))
  15. elif s == '/':
  16. if y != 0:
  17. print("%.2f" % (x/y))
  18. else:
  19. print("Деление на ноль!")
  20. else:
  21. print("Неверный знак операции!")
  22. if __name__ == "__main__":
  23. calc_simple()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement