My calculator is not working- bit help plz | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1
7th Jan 2020, 4:06 AM
Tanishq Sangwan
Tanishq Sangwan - avatar
19 Answers
+ 3
The reasons because your code isn't working is: 1. You must indent the the piece code of "if" || "elif" statements. 2. The Python interpreter of Sololearn is so bad, use Pydroid 3 on Play Store for check your errors. 3. You can do this for do the sum, substraction, multiply, and module: num1 = int(input("Please enter the number 1: ")) num2 = int(input("Please enter the number 2: ")) ____ Then you have these two numbers, you can define functions for the operations like this: # for sum def sum(num1, num2): print("\n", (num1 + num2)) # for substraction def subs(num1, num2): print("\n", (num1 - num2)) ## do equal >> #def mult # def module ________ Then, do you have the function created, only you must call it. You can call the function of this manner: # if user statement if user == "sum": sum(num1,num2) # num1 and num2 are parameters, in # this case are integer variables #defined by user input. ______ Can you understand that?. Chat me if you have more doubts.
7th Jan 2020, 5:03 AM
el3be
el3be - avatar
+ 1
Nvm guys I got it The parts we're not inside the block
7th Jan 2020, 4:51 AM
Tanishq Sangwan
Tanishq Sangwan - avatar
+ 1
Hmm yes, functions will take some time to understand
7th Jan 2020, 5:05 AM
CodeTypes
CodeTypes - avatar
+ 1
Have fun!
7th Jan 2020, 5:09 AM
CodeTypes
CodeTypes - avatar
+ 1
Use curly braces to put all the content of if on it limit so that your system know what is the end of if so that elif start from there ok and idk why you use sys. exit because this is enough to work on console really is is 25 % part of calculator if you really want to make calculator than know about tkinter and Matplotlip
8th Jan 2020, 9:43 AM
Abhishek nirwan
Abhishek nirwan - avatar
+ 1
while True: try: x = str(input()) x1 = eval(str(x)) print(x + ' = ' + str(x1)) except: print('error...') break #try this u really like my code
9th Jan 2020, 2:38 AM
Soma Mishra
Soma Mishra - avatar
+ 1
Hope u like it
9th Jan 2020, 2:39 AM
Soma Mishra
Soma Mishra - avatar
+ 1
Soma Mishra can you explain a bit cuz im new to python
9th Jan 2020, 3:33 AM
Tanishq Sangwan
Tanishq Sangwan - avatar
+ 1
Tanishq sangwan.....u have to understand that in python oor any programming language....never ever a string concatenate with float
9th Jan 2020, 4:24 AM
Soma Mishra
Soma Mishra - avatar
+ 1
So u just have to chance ur print statement in every condition
9th Jan 2020, 4:24 AM
Soma Mishra
Soma Mishra - avatar
0
Very nice code!
7th Jan 2020, 5:02 AM
CodeTypes
CodeTypes - avatar
7th Jan 2020, 5:03 AM
Tanishq Sangwan
Tanishq Sangwan - avatar
0
Plus I have just got to the function tutorials
7th Jan 2020, 5:06 AM
Tanishq Sangwan
Tanishq Sangwan - avatar
0
Yes functions tutorials is so easy to learn because them are so used
7th Jan 2020, 5:07 AM
el3be
el3be - avatar
0
Yeah, once you understand them they are very useful. They will allow you to get more experienced in python by creating more advanced code.
7th Jan 2020, 5:07 AM
CodeTypes
CodeTypes - avatar
0
K
7th Jan 2020, 5:07 AM
Tanishq Sangwan
Tanishq Sangwan - avatar
0
I'll get through them asap
7th Jan 2020, 5:09 AM
Tanishq Sangwan
Tanishq Sangwan - avatar
0
It is in steing value it must be in int value
8th Jan 2020, 6:00 AM
Kirui-kun
Kirui-kun - avatar
9th Jan 2020, 4:15 AM
Kirui-kun
Kirui-kun - avatar