Python Programming: If-elif-else Loop

300

11

Posted

Introduction: Python Programming: If-elif-else Loop

# Demo of if-elif-else loop

# Have user enter a number
numberentered = input("Please enter a number: ")

# Start if-elif-else loop
# Also attached as a file

if (numberentered >0) and (numberentered<10):
print "The number is between 0 and 10."
elif numberentered < 0:
print "The number is less than 0."
elif numberentered >10:
print "The number entered was greater than 10."
elif numberentered == 10:
print "The number entered was 10."
else :
print "The number entered was 0."

print "The number entered was: ", numberentered

Share

Recommendations

  • Epilog Challenge 9

    Epilog Challenge 9
  • Paper Contest 2018

    Paper Contest 2018
  • First Time Author Contest 2018

    First Time Author Contest 2018
user

We have a be nice policy.
Please be positive and constructive.

Tips

Questions

Comments