+ 1

please explain the error

print("🙏Welcome🙏") name=input('''Enter your name to continue ''') print('hi',name,',Pls enter the numbers to be calculated below') # This is a simple calc program num1=eval(input('''Enter the first number ''')) num2=eval(input('''Enter the second number ''')) operation=input('''Enter 'a' for addition, 's' for subtraction , 'd' for division and 'm' for multiplication ''') if operation=='a': print( num1+num2) if operation=='s': print(num1- num2) if operation=='d': print(num1/num2) if operation=='m': print(num1*num2) repeat=(input("Do you want to continue?(yes/no) ")) while repeat=='yes': num1=eval(input('please enter the first number ')) num2=eval(input('please enter the second number ')) operation=input('''Enter 'a' for addition, 's' for subtraction , 'd' for division and 'm' for multiplication ''' ) if operation=='a': print(num1+num2) if operation=='s': print(num1- num2) if operation=='d': print(num1/num2)

11th Aug 2019, 5:20 AM
karthik nair
karthik nair - avatar
19 Answers
+ 5
karthik nair I edited ur code but it raises different errors at every step trying to fix all those.. glad that u fixed all those Happy learning ☺️
11th Aug 2019, 5:49 AM
Sujithra
+ 5
karthik nair In input box u can give all the values by using enter...
11th Aug 2019, 6:20 AM
Sujithra
+ 3
What error u got.. share that as a file instead of copy the whole code
11th Aug 2019, 5:33 AM
Sujithra
+ 3
Hm.... thank u
11th Aug 2019, 6:24 AM
karthik nair
karthik nair - avatar
+ 2
😎 "Awesome" Lover ❤️ ~ swim ~ thanks to you both ..... the problem was of course becuz i put tab, the issue was with pydroid 3 , i wrote half the code in landscape mode and rest in portrait mode...... in my tablet as i dont have a computer....... due to a bug , when i rotated the screen , it didnt show the extra tab,,,,,,,,, i noticed that when i pasted my code here and corrected it ........ thanks for your quick support ..... im just a python begginner whose still in school life
11th Aug 2019, 5:48 AM
karthik nair
karthik nair - avatar
+ 1
yeah i know
11th Aug 2019, 5:50 AM
karthik nair
karthik nair - avatar
11th Aug 2019, 6:16 AM
karthik nair
karthik nair - avatar
11th Aug 2019, 6:16 AM
karthik nair
karthik nair - avatar
+ 1
i dont know how to run that in sololearn
11th Aug 2019, 6:17 AM
karthik nair
karthik nair - avatar
+ 1
as there is only 1 input box shown there in sololearn
11th Aug 2019, 6:18 AM
karthik nair
karthik nair - avatar
+ 1
well it runs error free in pydroid 3
11th Aug 2019, 6:18 AM
karthik nair
karthik nair - avatar
+ 1
oh
11th Aug 2019, 6:21 AM
karthik nair
karthik nair - avatar
+ 1
What’s up with eval()? I always heard that it should be avoided for safety reasons. Anyways, wouldn’t int() or float() make more sense in this context?
11th Aug 2019, 10:43 PM
Rora
+ 1
Rora In int , only integer values can be input by the user whereas in float only decimal values can be input by the user but in eval, both can be used
12th Aug 2019, 2:17 AM
karthik nair
karthik nair - avatar
+ 1
karthik nair Nothing bad will happen happen if you store an int as a float, it will just have a ‘.0’. Anyways, integer division is implicitly converted to float when it’s not exact unless you specifically floor it.
12th Aug 2019, 11:23 AM
Rora
0
Rora i know that even though I'm a beginner. But when i thought deeply , i.e, the user may not know that he has to give '.0' . We should work in a manner that the user is comfortable.
12th Aug 2019, 11:45 AM
karthik nair
karthik nair - avatar
0
karthik nair You don’t have to give ‘.0’, it just automatically adds it. float(4) returns 4.0.
12th Aug 2019, 9:26 PM
Rora