Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Some New Files and Notes #272

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions Basics/match_case.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
'''
Checking City Location
'''

usa = ["atlanta", "new york", "chicago", "baltimore"]
uk = ["london", "bristol", "cambridge"]
india = ["mumbai", "delhi", "bangalore"]

city = input("Enter city name: ").lower()

match city:
case city if city in usa:
print(f"{city} is in USA")
case city if city in uk:
print(f"{city} is in UK")
case city if city in india:
print(f"{city} is in India")
case _:
print(f"I won't be able to tell you which country {city} is in! Sorry!")


'''
Comparing Two Cities
'''
usa = ["atlanta", "new york", "chicago", "baltimore"]
uk = ["london", "bristol", "cambridge"]
india = ["mumbai", "delhi", "bangalore"]

city1 = input("Enter city 1: ").lower()
city2 = input("Enter city 2: ").lower()

match (city1, city2):
case (city1, city2) if city1 in usa and city2 in usa:
print("Both cities are in USA")
case (city1, city2) if city1 in uk and city2 in uk:
print("Both cities are in UK")
case (city1, city2) if city1 in india and city2 in india:
print("Both cities are in India")
case _:
print("They don't belong to the same country")

'''
Identifying Cuisine
'''

indian = ["samosa", "kachori", "dal", "naan"]
chinese = ["egg roll", "fried rice", "pot sticker"]
italian = ["pizza", "pasta", "risotto"]

dish = input("Enter a dish name: ").lower()

match dish:
case dish if dish in indian:
print(f"{dish} is an Indian cuisine")
case dish if dish in chinese:
print(f"{dish} is a Chinese cuisine")
case dish if dish in italian:
print(f"{dish} is an Italian cuisine")
case _:
print(f"Based on whatever little knowledge I've, I can't tell which cuisine {dish} is")
Binary file added Basics/notes/notes.pdf
Binary file not shown.
Binary file not shown.
Loading