Advertisement
Guest User

2_5390863119658516628.py

a guest
Jan 17th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.11 KB | None | 0 0
  1. print ('Здравствуй')
  2. print ('Этот калькулятор может слагать, вычитать, умножать, делить и подносить к степени')
  3. print ('Инструкция:\n Символы ввода должны быть написаны через пробел.\n + Сложение.\n - Вычетание.\n * Умножение\n / Деление\n ^ Поднесение к степени')
  4. def calc():
  5.     def expt(b, n):
  6.        if n==0:
  7.           return 1
  8.        return b*expt(b, n-1)
  9.     a=input('').split(' ')
  10.     if '+' in a:
  11.                 result = int(a[0]) + int(a[2])
  12.                 print (result)
  13.     if '-' in a:
  14.                 result = int(a[0]) - int(a[2])
  15.                 print (result)
  16.     if '*' in a:
  17.                 result = int(a[0]) * int(a[2])
  18.                 print (result)
  19.     if '/' in a:
  20.                 result = int(a[0]) / int(a[2])
  21.                 print (result)
  22.     if '^' in a:
  23.                 result = expt(int(a[0]),int(a[2]))
  24.                 print (result)
  25. def calcul():
  26.     while True:
  27.         calc()
  28.         break
  29. while True:
  30.     calcul()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement