Created
August 12, 2022 16:07
-
-
Save acbart/8127d96897ce96db1d8d5fed7bac5945 to your computer and use it in GitHub Desktop.
Tracing Ifs Example Vehicles
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
travellers = 4 | |
suitcases = 3 | |
bookbags = 2 | |
def choose_vehicle(travellers: int, bags: int) -> str: | |
space = bags // 2 + travellers | |
if space > 4: | |
return 'van' | |
elif space <= 1: | |
return 'bike' | |
else: | |
return 'car' | |
vehicle = choose_vehicle(travellers, suitcases + bookbags) | |
print("You should get a", vehicle) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment