0

Please tell me how can i take output?

print("select operation") print("1.Add") print("2.Subtract") print("3.Multiply") print("4.Divide") choice =int(input("Enter choice(1/2/3/4):")) num1 = int(input("Enter first number: ")) num2 = int(input("Enter second number: ")) if choice == 1: print (num1+num2) elif choice == 2: print (num1-num2) elif choice == 3: print (num1*num2) elif choice == 4: print (num1/num2) else: print ("Invalid input")

21st Aug 2020, 3:53 AM
Siddharth Yadav
Siddharth Yadav - avatar
3 Respostas
+ 1
Initially assign result variable to zero the in each operational stmt, instead of directly performing operation in print, assign the operation to result and the peint result. Like this: result=0 if ch=1: result=n1+n2 print(result)
21st Aug 2020, 9:16 AM
Sevda Krithika Sharma
Sevda Krithika Sharma - avatar
0
Please tell me
21st Aug 2020, 3:54 AM
Siddharth Yadav
Siddharth Yadav - avatar
21st Aug 2020, 3:59 AM
Tomiwa Joseph
Tomiwa Joseph - avatar