Skip to content

Instantly share code, notes, and snippets.

@jova30
Created May 20, 2025 19:35
Show Gist options
  • Save jova30/fc08fbfef885ebb26abca49a92cb5f32 to your computer and use it in GitHub Desktop.
Save jova30/fc08fbfef885ebb26abca49a92cb5f32 to your computer and use it in GitHub Desktop.
friend-making algoritm flowchart
#@title Solution
# Is John home?
is_home = "yes"
# Place phone call.
print("Ring ring!")
# Home?
if is_home == "yes":
# Yes.
print("Hi John, it's me.")
else:
# No.
print("Hi John. Please call me back. I have something to ask you.")
print("John calls you back. Ring ring!")
# Would you like to share a meal?
wants_meal = input("Would you like to share a meal? ")
# What is the response?
if wants_meal == "yes":
# Yes.
print("Great! I'll see you at dinner tonight.")
else:
# No.
print("I see. You wouldn't like that.")
# Would you like to have a beverage together?
wants_beverage = input("Would you like to have a beverage together? ")
# What is the response?
if wants_beverage == "yes":
# Yes.
print("Great! I'll see you for a drink this evening!")
else:
# No.
print("I see. You wouldn't like that.")
# Tell me one of your interests.
interest = input("Tell me one of your interests: ")
# Is that interest 'physics' or 'comic books'?
while interest != "physics" and interest != "comic books":
# If not, tell John you only like 'physics' and 'comic books'.
print("I'm only interested in physics and comic books.")
# Ask John for another interest.
interest = input("Tell me one of your interests: ")
# If the interest is 'physics', ask him to work together on a project.
if interest == "physics":
print("Let's work on something together!")
# If the interest is 'comic books', ask him to go to the comic book store together.
else:
print("Let's go to the comic book store sometime!")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment