Python Quiz Unit 3


#1

Question: What will the code print on the console?

Answer: Nothing

Code:

if not True:

  print True

elif 15 % 4 <= 1 ** 4:

  print False
  
elif False and True:

  print len("None")
  
else:
  
  print "Nothing"

I don't understand why it will print Nothing? What's the sequence?
Thank you in advance


#2

well, all other conditions (if and elif's) are false, so else runs and print


#3

It seems like the second elif is true, if I calculated it right (15 % 4 = 3
and remainer is 3; 1 ** 4 = 4, so 3 <= 4 is a true sentence)

Stetim94 codecademy@discoursemail.com於 2017年5月1日 週一,23:53寫道:


#4

1 ** 4 means: 1 * 1 * 1 * 1

not sure how that is 4, last time i did the math that was still one :stuck_out_tongue:


#5

Right! I confused it with multiplication! Thanks!

Stetim94 codecademy@discoursemail.com於 2017年5月2日 週二,01:04寫道:


#6

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.