0

Why i have to write print() then input a numerical operation to work. Writing directly a numerical operation showing error.

why?

5th Aug 2017, 12:33 AM
Anurag Chandra
15 Réponses
+ 2
Can you show the code or give an example? print(5+3) Works fine.
5th Aug 2017, 1:25 AM
Rrestoring faith
Rrestoring faith - avatar
+ 2
add a comma and it should work: print('we get=', 30/11)
6th Aug 2017, 6:20 AM
Martin Ed
Martin Ed - avatar
+ 1
well, for me it does not show an error 5+3 just gives: "no output" which is true - since there is no print statement, there is no output
5th Aug 2017, 11:38 AM
Martin Ed
Martin Ed - avatar
+ 1
You can... The issue is how you're writing it. Show us your code, or write it exactly as I wrote it.
6th Aug 2017, 12:34 AM
Rrestoring faith
Rrestoring faith - avatar
+ 1
On line 8 "print('we get') print(30/11)" Python is dependant on Indentation, so you cannot have 2 print statements on the same line. Move it to the next line, like this: print('we get') print(30/11)
6th Aug 2017, 12:42 AM
Rrestoring faith
Rrestoring faith - avatar
0
input() returns a string value - maybe that's the reason why retrieved an error? you have to cast the input to integer first
5th Aug 2017, 7:52 AM
Martin Ed
Martin Ed - avatar
0
directly writing 5+3 is showing error
5th Aug 2017, 9:01 AM
Anurag Chandra
0
where do you write it? python prompt? solo learn playground? any other IDE?
5th Aug 2017, 10:44 AM
Martin Ed
Martin Ed - avatar
0
solo learn playground
5th Aug 2017, 10:45 AM
Anurag Chandra
0
but it says u can write numerical operations without writing print()
6th Aug 2017, 12:28 AM
Anurag Chandra
0
hey see my code in my profile. it isn't working why?
6th Aug 2017, 12:41 AM
Anurag Chandra
0
OK thanks
6th Aug 2017, 12:43 AM
Anurag Chandra
0
hey another thing print('we get=' 30/11) it is also not working
6th Aug 2017, 12:46 AM
Anurag Chandra
0
why? we gat should be treated like text. also if it is not working. then how should I write we get= '30/11' (this 30/11 above is the value after division)
6th Aug 2017, 12:48 AM
Anurag Chandra
0
hey martin, can't we assign a operations(+,-,*,/) to a variable.
9th Aug 2017, 9:24 AM
Anurag Chandra