What is the problem with this code? x=input(2) y=input(8) print (int(x)+int(y)) | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What is the problem with this code? x=input(2) y=input(8) print (int(x)+int(y))

15th Jun 2021, 2:12 PM
zoro
13 Answers
+ 3
Here in input u passed number 2 and 8 your input function will take inputs generally we writting some text with input like this input("enter num") like this text will show whatever mesg u have given it will print then it ask for input here u passed values its treat as string if u will not write int thats why first it will print 28 in result then input numbers will be add if u entered 3 And 2 Then final output will be 285 where 5 is addition of two input numbers and 2 ,8 are strings.
15th Jun 2021, 2:18 PM
A S Raghuvanshi
A S Raghuvanshi - avatar
+ 2
zoro its optional and not necessary to pass message or values if u dont want to write anything .u can input () this is also valid
15th Jun 2021, 2:25 PM
A S Raghuvanshi
A S Raghuvanshi - avatar
+ 2
learn basics fundamental of python you will understood much better a=input() b=input() c=a+b print(c)
15th Jun 2021, 2:28 PM
A S Raghuvanshi
A S Raghuvanshi - avatar
+ 2
Not false if u want to pass string then u need to write double quotes . If u want to pass number then write without quotes
15th Jun 2021, 2:37 PM
A S Raghuvanshi
A S Raghuvanshi - avatar
+ 1
zoro read @A.S first answer again. Argument(I.e inside parenthesis), to input() is just a message to print on console for your or reader understanding.. x=input() will accept a string value.. but if you have some more inputs needed like x=input() x2=input() ... a 10+ more , you can't understand what to input . but with x1=input("enter value for x1 ") x2=input("enter value for x2 ") will notify you to enter value for x1,next for x2 with messages you passed. Simplifies understanding. It's not value assigning.. if you want assigning,just write x=2 y=8
15th Jun 2021, 2:44 PM
Jayakrishna 🇮🇳
+ 1
Can someone solve this Python code for me 0.01*(2**5)
16th Jun 2021, 4:48 PM
Fatorma Amadu
+ 1
Input () is a built in python function that does just that, takes user input. This input is provided at runtime hence you should not include it in the code.
16th Jun 2021, 9:28 PM
Otieno Samwel
Otieno Samwel - avatar
0
Why the code is true when we do not write the numbers
15th Jun 2021, 2:24 PM
zoro
0
Could you give me an example please?
15th Jun 2021, 2:27 PM
zoro
0
I am sorry if I disturb you I'm a bignner Thank you
15th Jun 2021, 2:40 PM
zoro
0
https://code.sololearn.com/ca8A104A21a2 a=input() b=input() print(int(a)+int(b))
17th Jun 2021, 1:47 AM
Abhishek Kumar
Abhishek Kumar - avatar
0
Fatorma Amadu As per your question, 0.01(2**5) = 0.32 But what help you need in this kindly elaborate.
17th Jun 2021, 9:46 AM
DIPTIRANI SAHU
- 1
but if we want to write it with 2 and 8 is it false?
15th Jun 2021, 2:30 PM
zoro