Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- print ('Здравствуй')
- print ('Этот калькулятор может слагать, вычитать, умножать, делить и подносить к степени')
- print ('Инструкция:\n Символы ввода должны быть написаны через пробел.\n + Сложение.\n - Вычетание.\n * Умножение\n / Деление\n ^ Поднесение к степени')
- def calc():
- def expt(b, n):
- if n==0:
- return 1
- return b*expt(b, n-1)
- a=input('').split(' ')
- if '+' in a:
- result = int(a[0]) + int(a[2])
- print (result)
- if '-' in a:
- result = int(a[0]) - int(a[2])
- print (result)
- if '*' in a:
- result = int(a[0]) * int(a[2])
- print (result)
- if '/' in a:
- result = int(a[0]) / int(a[2])
- print (result)
- if '^' in a:
- result = expt(int(a[0]),int(a[2]))
- print (result)
- def calcul():
- while True:
- calc()
- break
- while True:
- calcul()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement