if statements | SoloLearn: Learn to code for FREE!

+2

if statements

can someone please break this code down for me and simplify it for me? spam = 7 if spam > 5: print("five") if spam > 8: print("eight") im using actual python 3 to practice as I go and idk how im suppose to type this out.

2/11/2018 9:20:54 PM

Ryan Wontz

6 Answers

New Answer

+1

We have spam that is equal to 7. So in this code, spam is represented by 7. Then, if we look at the if statements, they mean that if a statement is true, it will do what is below it. In this, if spam (which equals 7) is greater than 5, than it will print “five”. If spam is great than 8, it will print “eight”. This code’s outcome will be “five” because spam (7) is a bigger number than 5 while spam(7) is less than 8, it will not come out to “eight” since the statement is false. Hope that helps! More info on if statements: https://www.afterhoursprogramming.com/tutorial/python/if-statement/

+4

7 is greater than(>) 5 and output iz five and less than 8 so second condition is false

+2

that does help but how exactly do i type it out?

+2

Are you typing it out in Python Shell or Sololearn?

0

python shell

0

Im actually typing all the things I learn in python with python 3.6 (32 bit) as I go. that way I can get a handle on typing faster.