From e8366ab41644102a8db2ac0740212de982eb043b Mon Sep 17 00:00:00 2001 From: standenboy Date: Wed, 17 Jan 2024 13:13:58 +0000 Subject: did some comp sci homework --- comp/hw/110/cityProgram.py | 37 +++++++++++++++++++++++++++++++++++++ comp/hw/110/search.py | 12 ++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 comp/hw/110/cityProgram.py create mode 100644 comp/hw/110/search.py (limited to 'comp/hw') diff --git a/comp/hw/110/cityProgram.py b/comp/hw/110/cityProgram.py new file mode 100644 index 0000000..9a92e53 --- /dev/null +++ b/comp/hw/110/cityProgram.py @@ -0,0 +1,37 @@ +Country = ["France", "UK", "Italy", "Spain"] +Capital = ["Paris", "London", "Rome", "Madrid"] + +def add(country, capital): + Country.append(country) + Capital.append(capital) + +def remove(country): + counter = 0 + for i in Country: + if i == country: + Country.pop(counter) + Capital.pop(counter) + break + counter = counter+1 + +def printCountry(): + counter = 0 + for i in Country: + print(Country[counter], Capital[counter] ) + counter = counter + 1 + +while True: + query = input("add, remove, print: ") + if query == "add": + add(input("country: "), input("capital: ")) + printCountry() + elif query == "remove": + remove(input("country to remove: ")) + printCountry() + elif query == "print": + printCountry() + + + + + diff --git a/comp/hw/110/search.py b/comp/hw/110/search.py new file mode 100644 index 0000000..99f8b3d --- /dev/null +++ b/comp/hw/110/search.py @@ -0,0 +1,12 @@ +names = ["jacob", "thor", "katelyn", "johnson"] + +searchingFor = input("name to look for: ") +for i in names: + if i == searchingFor: + print("found name") + exit(0) + +print("name not found") + + + -- cgit v1.2.3