(For example:output 1 output2 output 3 etc.) def silly (a, b, c): if a > b: if b > c: print(“Spam!”) else: print(“Ni!”) elif b > c: print(“Python!”) if (a
Expert Answer
def silly(a, b, c):
if a > b:
if b > c:
print(“Spam!”)
else:
print(“Ni!”)
elif b > c:
print(“Python!”)
if(a <= c):
print(“cobra”)
else :
print(“viper”)
else:
print(“Done!”)
silly(3,7,5)
print(‘n’)
silly(2,0,0)
print(‘n’)
silly(1,3,5)
print(‘n’)
silly(2,7,-5)
print(‘n’)
silly(0,0,0)
If you want to understand the flow of execution, i will explain it for first case,
silly(3,7,5):
here a =3, b = 7, c = 5;
we can see that first if condition of a > b is not met, hence it goes to next if condition of b > c. This condition is true, hence it goes inside code block and prints Python!, then a <= c is checked which is true, hence it prints cobra and comes out.
Similarly other cases execute too.