+ 6

I can't understand how the program is running

Please some one explain that

12th Nov 2020, 12:29 PM
Antony Praveenkumar M
Antony Praveenkumar M - avatar
17 Réponses
+ 4
example: x = 1 + 1 y = 2 if x == y: print('True') else: print('False') This will print 'True' the if statement will not occur if the condition is false, the else statement occur.
12th Nov 2020, 12:36 PM
noteve
noteve - avatar
+ 3
Input consider as a string???
12th Nov 2020, 12:44 PM
Antony Praveenkumar M
Antony Praveenkumar M - avatar
+ 2
'print' not 'Print' and n = int(input())
12th Nov 2020, 12:39 PM
noteve
noteve - avatar
+ 1
n=input () if n==5: Print ('true') else: print('false') The question is even though I put 5 the results show false why?????
12th Nov 2020, 12:38 PM
Antony Praveenkumar M
Antony Praveenkumar M - avatar
+ 1
Ok that's not a problem
12th Nov 2020, 12:40 PM
Antony Praveenkumar M
Antony Praveenkumar M - avatar
+ 1
Just run the program and put 5 and see what will happen
12th Nov 2020, 12:41 PM
Antony Praveenkumar M
Antony Praveenkumar M - avatar
+ 1
Input operation consider the value as string whatever I put correct As I'm correct
12th Nov 2020, 12:45 PM
Antony Praveenkumar M
Antony Praveenkumar M - avatar
+ 1
Thank u so much
12th Nov 2020, 12:48 PM
Antony Praveenkumar M
Antony Praveenkumar M - avatar
+ 1
if statement : if a condition is satisfied such as (if 2==2 : print("true")) else statement : if a condition is not satisfied
13th Nov 2020, 1:16 PM
Somil Khandelwal
12th Nov 2020, 12:33 PM
noteve
noteve - avatar
0
try to review the sololearn lessons again and experiment until you understand it. Happy coding!
12th Nov 2020, 12:40 PM
noteve
noteve - avatar
0
It's always show's false
12th Nov 2020, 12:41 PM
Antony Praveenkumar M
Antony Praveenkumar M - avatar
0
try this n=int(input ()) if n==5: print ('true') else: print('false')
12th Nov 2020, 12:42 PM
noteve
noteve - avatar
0
input () Operation work in if statement?????????
12th Nov 2020, 12:42 PM
Antony Praveenkumar M
Antony Praveenkumar M - avatar
0
Yes it's working how
12th Nov 2020, 12:43 PM
Antony Praveenkumar M
Antony Praveenkumar M - avatar
0
because the 5 youre trying to type is a string not an integer, you must convert it first to integer by adding int befor the number int(x)
12th Nov 2020, 12:45 PM
noteve
noteve - avatar
0
The input you are giving is always a string, and Python does not convert it to an integer. So you must explicitly convert the string to an integer, as said by The Zen of Python:"Explicit is better than implicit".
13th Nov 2020, 2:40 AM
Boay.JS
Boay.JS - avatar