Advertisement
shotni4k

hddf

Jul 6th, 2021
1,475
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. # обьявление функции
  3. def calc(operation):
  4.    
  5.     number_1 = int(input('Введите первое число: '))
  6.     number_2 = int(input('Введите второе число: '))
  7.     if operation == '+':
  8.         print('{} + {} = '.format(number_1, number_2))
  9.         print(number_1 + number_2)
  10.     elif operation == '-':
  11.         print('{} - {} = '.format(number_1, number_2))
  12.         print(number_1 - number_2)
  13.     elif operation == '*':
  14.         print('{} * {} = '.format(number_1, number_2))
  15.         print(number_1 * number_2)
  16.     elif operation == '/':
  17.         print('{} / {} = '.format(number_1, number_2))
  18.         print(number_1 / number_2)
  19.     else:
  20.         print('Вы не выбрали соответствующий математический символ,пожалуйста перезапустите программу.')
  21.  
  22.  
  23. def again():
  24.     calc_again = input('Do you want to calculate again\n ?Please type Y for YES or N for NO.\n')
  25.     if calc_again.upper() == 'Y':
  26.         operation = input('Пожалуйста выберите нужный математический символ: \n + сложение \n- вычитание \n * умножение \n / деление \n')
  27.         calc(operation)
  28.     elif calc_again.upper() == 'N':
  29.         print('See you later.')
  30.     else:
  31.         pass
  32.  
  33. again()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement