Let's look at the "and" operator in Python. It can expand things so we can make more complex things. Well, in this example, a user is going to be asked for input on what his/her age is and the program will determine what school he/she is probably in.
Any questions? Do you see how the "and" operator makes more complex things than what was on the last conditionals tutorial by me? What are some other operators that can also spice things up? Have you used them or "and" in your programming? What difference did it make?
Code:
your_age = int(input("What is your under 18 child's age?"))
while your_age <= 11 and your_age >= 5:
print("Since the age submitted is" + " " + str(your_age) + " " + "you are probably in elementary school.")
if your_age < 5:
print("Since the age submitted is" + " " + str(your_age) + " " + "you are probably in preschool or not going to school.")
elif your_age >= 12 and your_age <= 14:
print("Since the age submitted is" + " " + str(your_age) + " " + "you are probably in middle school.")
elif your_age >= 15 and your_age <= 18:
print("Since the age submitted is" + " " + str(your_age) + " " + "you are probably in high school.")
elif your_age > 18
print("Sorry, only children that were under 18 were asked about.")
Any questions? Do you see how the "and" operator makes more complex things than what was on the last conditionals tutorial by me? What are some other operators that can also spice things up? Have you used them or "and" in your programming? What difference did it make?
Last edited: