Find expert answers and community support for all your questions on IDNLearn.com. Our experts are ready to provide prompt and detailed answers to any questions you may have.

What is the output of this code?
num-7
if num > 3:
print("3")
if num < 5:
print("5")
if num --7:
print("7")


Sagot :

Answer:

The output is:

3

7

Explanation:

Given

The code segment

Required

The output

The given code segment has 3 independent if statements; meaning that, each of the if conditions will be tested and executed accordingly

This line initializes num to 7

num=7

This checks if  num is greater tha 3; If yes, "3" is printed

if num > 3:

   print("3")

The above condition is true; so, "3" will be printed

This checks if  num is less than 5; If yes, "5" is printed

if num < 5:

   print("5")

The above condition is false; so, "5" will not be printed

This checks if  num equals 5; If yes, "7" is printed

if num ==7:

   print("7")

The above condition is true; so, "7" will be printed

So, the output is:

3

7