+ 1

Please, how do I create the simple calculator task on Pyton?

I don't know what I'm doing wrong, somebody should please help with the code for the simple calculator, here's my code int1 = int(3)# your code goes here int2 = int(6)# your code goes here sum = int1 + int2 print(sum)

22nd Mar 2022, 12:27 PM
David Michael
David Michael - avatar
30 odpowiedzi
+ 4
print("--- Welcome to py Calculator ---") print(f"{eval(input())}") this is the simplest calculator, a one line calculator
23rd Mar 2022, 6:31 PM
Saad Khan
Saad Khan - avatar
+ 2
David Michael , can you please give us the tutorial name, the lesson / exercise name or number (assuming that you are talking about a code coach exercise) otherwise we need a more precise task description. thanks!
22nd Mar 2022, 12:52 PM
Lothar
Lothar - avatar
+ 2
You don't need to pass any argument to input() in code coach.. According to description, just ouput what is asked, no extra or less. just try this way : David Michael int1 = int(input()) int2 = int(input()) print( int1+int2 )
22nd Mar 2022, 2:50 PM
Jayakrishna 🇮🇳
+ 1
your code?
22nd Mar 2022, 12:33 PM
Abhishek Tandon
Abhishek Tandon - avatar
+ 1
Shourya Pandey , i don't know if you have misunderstood the question. but the code in your post is completely wrong. we are talking about python. may be you can correct your code, or otherwise please remove it. thanks!
23rd Mar 2022, 10:38 AM
Lothar
Lothar - avatar
+ 1
a = 1 b = 3 c = a,b print(sum(c))
23rd Mar 2022, 2:06 PM
CodeStory
CodeStory - avatar
+ 1
Liberian AG where's the code you've written so far
23rd Mar 2022, 8:25 PM
David Michael
David Michael - avatar
+ 1
Liberian AG Write your code and share it here, let's help you identify the error.
23rd Mar 2022, 8:31 PM
David Michael
David Michael - avatar
+ 1
David Michael here's it #your code goes here weight = int(input()) height = float(input()) x = weight /float(height * height / 100) if x < 18.5: print ('Underweight') if 18.5 >= x < 25: print ('Normal') if 25 >= x < 30: print ('Overweight') if x >= 30: print ('Obesity')
23rd Mar 2022, 8:35 PM
231AG
231AG - avatar
+ 1
Liberian AG Consider using the elif function
23rd Mar 2022, 8:43 PM
David Michael
David Michael - avatar
23rd Mar 2022, 9:24 PM
David Michael
David Michael - avatar
+ 1
""" off topic to OP Liberian AG you can use your own thread , instead posting here.. according to task this is what you need. See comments to know about changes... @David Michael your code missing some value what in is 20 for example.. So. Hope it helps.. """ #your code goes here weight = int(input()) height = float(input()) x = weight /height * height # √ if x < 18.5: print ('Underweight') elif 18.5 <= x < 25: # use <= instead of >= print ('Normal') elif 25 <= x < 30: print ('Overweight') elif x >= 30: print ('Obesity')
23rd Mar 2022, 9:34 PM
Jayakrishna 🇮🇳
+ 1
i1 = int(input("Enter First Number : ") ) i2 = int(input(" Enter Second Number: ") ) print( i1 + i2 )
24th Mar 2022, 2:23 AM
Vaibhav
Vaibhav - avatar
0
pls Show your attempt here....
22nd Mar 2022, 12:34 PM
Jayakrishna 🇮🇳
0
int1 = int(3) is same as int1 = 3. You need to assign them as input variables instead.
22nd Mar 2022, 12:49 PM
Simba
Simba - avatar
0
David Michael May you need to take input there.. Use this : int1 = int( input() ) # it takes input and convert to integer type. Do the same for int2 and remianing works well in your code.. int1 = int( input() ) int2 = int( input() ) print( int1 + int2 )
22nd Mar 2022, 1:02 PM
Jayakrishna 🇮🇳
0
The exercise name is 17 coach exercise, the simple calculator exercise
22nd Mar 2022, 2:12 PM
David Michael
David Michael - avatar
0
David Michael What's you update code? What changes you tried from the posts..? You can see your solution already above..
22nd Mar 2022, 2:20 PM
Jayakrishna 🇮🇳
0
# This is my update code, still not working, I thnking something is not right from the input line int1 = int( input(6) ) # it takes input and convert to integer type. Do the same for int2 and remianing works well in your code.. int2 = int( input(3) ) print( int1 + int2)
22nd Mar 2022, 2:24 PM
David Michael
David Michael - avatar
0
I did this, still not correct
22nd Mar 2022, 2:54 PM
David Michael
David Michael - avatar