Making Decisions in Python
February 26, 2018
This is a short script that shows how to use if as well as elif and else so that Python can make decisions based on the input it is given.
people = 100
cars = 30
buses = 15
if cars > people:
print "We should take the cars."
elif cars < people:
print "We should not take the cars."
else:
print "We can't decide."
if buses > cars:
print "That's too many buses."
elif buses < cars:
print "Maybe we could take the buses."
else:
print "We still can't decide"
if people > buses:
print "Alright, let's just take the buses."
else:
print "Fine. Let's stay home then."
Recent Entries
- Filter First, Think Later February 21, 2026
- Five Hundred Bugs That Fuzzers Missed February 20, 2026
- Gemini 3.1 Pro and the 0.1 That Matters February 19, 2026