0

Python code not working

Hi am an ameture who is learning python and i wrote this code in python which calculates THE CODE: print("Integer1:") a = input() print("Integer2:") b = input() print("If add type:1") print("If subtract type:2") print("If multiply type:3") print("If divide type:4") c = input("") if c=="1": print(a+b) if c=="2": print(a-b) if c=="3": print(a*b) if c=="4": print(a/b) Please help me out guys

19th Jan 2022, 2:13 PM
Siva Sai Devesh
Siva Sai Devesh - avatar
2 Answers
+ 4
input() return a string type object.
19th Jan 2022, 2:29 PM
FanYu
FanYu - avatar
0
Siva Sai Devesh, I think you are creating a calculator so for that, you can do this too: here is a code by ㅀㅀㅀ : x=int(input("enter first no.: ")) y=input('enter the arithematic operation (+,-,*,/): ') z=int(input('enter second no.: ')) if y=='-': print(x-z) elif y=='+': print(x+z) elif y=='*': print(x*z) elif y=='/': print(x/z) don't use the user prompt if you are using it in sololearn (cuz its of no use). you can take input as floats if you want (just change `int to float`) Credit: @~NEZ
19th Jan 2022, 3:44 PM
JOKER
JOKER - avatar