I am trying to run my code inside of IDLE Python i wrote everything is correct but sadly i cannot run. it restarts without any reason.
def calculator():
operation = input('''
Please Enter one of These:
+ for adding
- for minize
* for multiply
/ for devision
''')
num1 = int(input('Num 1 : '))
num2 = int(input('Num 2 : '))
if operation == '+':
print(' {} + {} = ' . format(num1 , num2))
print(num1 + num2)
elif operation == '-':
print(' {} - {} = ' . format(num1 , num2))
print(num1 - num2)
elif operation == '*':
print(' {} * {} = ' . format('num1 , num2'))
print(num1 * num2)
elif operation == '/':
print(' {} / {} = ' . format('num1 , num2'))
print(num1 / num2)
else:
print('Error')
again()
def again():
calc_again = input('''
Wanna Try Again:
if yes please type Y and if no Please Type N
''')
if calc_again.upper() == 'Y':
calculator()
elif calc_again.upper() == 'N':
print('Good Bye')
else:
again()
You will have to call the calculator() method to start the program (check the last line)..
def calculator():
operation = input('''
Please Enter one of These:
+ for adding
- for minize
* for multiply
/ for devision
''')
num1 = int(input('Num 1 : '))
num2 = int(input('Num 2 : '))
if operation == '+':
print(' {} + {} = ' . format(num1 , num2))
print(num1 + num2)
elif operation == '-':
print(' {} - {} = ' . format(num1 , num2))
print(num1 - num2)
elif operation == '*':
print(' {} * {} = ' . format('num1 , num2'))
print(num1 * num2)
elif operation == '/':
print(' {} / {} = ' . format('num1 , num2'))
print(num1 / num2)
else:
print('Error')
again()
def again():
calc_again = input('''
Wanna Try Again:
if yes please type Y and if no Please Type N
''')
if calc_again.upper() == 'Y':
calculator()
elif calc_again.upper() == 'N':
print('Good Bye')
else:
again()
calculator() #call method