+ 2
num=8 if num>3: print "3" if num<5: print "5" if num==7: print "7" output of this program is s 3.. why is it so????
11 odpowiedzi
+ 14
We have num = 8 ..... first If block condition is true, 8 is greater than so 3 will be printed
On second If block condition is false so nothing will be printed .... Third If block is within second IF block (nested). As condition of main If block is false so all the remaining code within it will not be checked
so that's why 3 is the right answer
+ 6
if num=8 > greater than 3, print 3.
truly 8 is greater than 3 that means the statement is true 3 will be printed.
second if num< Less than 5 is num i.e. 8 less than 5...? no that means 3 will still be printed.
lastly if num i.e. 8 == 7. no 8 isn't 7 therefore 3 will still be printed..
+ 5
these are a nested if loops. if first condition is true I.e if num > 3 is true then only the second condition is executed and the second condition is if num < 5 which is false so it comes out of the loop and hence only 3 is printed for output. upvote if you like the answer
0
thankzz..... guyzzz
0
you are welcome navaneeta babu
0
nothing gets executed after the second if statement as num=8 is not less than 5
So the output is only 3
0
In simpler terms, since you had num=8 if number is greater than 3(true), print 3. Since 8 is greater than 3, it wrote 3.
0
The first statement only true except that ask are false that's why it prints the first condition
0
>>> x = 4
>>> x
= 5
>>> print
0
num = 7
if num > 3:
print("3")
if num < 5:
print("5")
if num ==7:
print("7")
why 3 is the only output it should be 37 right because the last if statement is true so it should print 37?
can u help me?
0
thanks