CS Project Pile Python
CS Project Pile Python
Teacher Signature
Acknowledgment
This Python program lets you easily store and check out
info about different countries. You can either add a new
country or grab details about one that’s already saved.
When you add a country, you’ll give its name, capital,
population, president, and currency, and the program keeps
all that in a dictionary for easy access later. You can then
pull up things like the president’s name, the capital, or the
country’s currency, or just get the whole deal. It’s set up to
be super easy to use, handling your inputs smoothly,
making sure country names are all tidy, and double-
checking things to keep errors at bay. Overall, it’s a simple
but handy tool to keep country info organized and easy to
get to.
Country_Data = {}
for i in range(1, 6):
print('')
Choice = int(input('''1. Enter details about a new country.
2. Check the data of an existing country.
>>> '''))
if Choice == 1:
Country_Name = input("Enter the name of the country: ")
Country_Capital = input("Enter the capital of the country: ")
Country_Population = input("Enter the population of the country: ")
Country_President = input("Enter the name of the president of the country: ")
Country_Currency = input("Enter the name of the currency of the country: ")
elif Choice == 2:
Country_Name = input("Enter the name of the country: ")
if Country_Name in Country_Data:
print("\nMenu")
print("1. Check the president of the country")
print("2. Check the capital of the country")
print("3. Check the population of the country")
print("4. Check the currency of the country")
print("5. Check all the details of the country")
if Choice_2 == 1:
print("President of the country is:", Country_Data[Country_Name][0])
elif Choice_2 == 2:
print("Capital of the country is:", Country_Data[Country_Name][1])
elif Choice_2 == 3:
print("Population of the country is:", Country_Data[Country_Name][2])
elif Choice_2 == 4:
print("Currency of the country is:", Country_Data[Country_Name][3])
elif Choice_2 == 5:
print("\nData of the country:")
print(f"Country: {Country_Name}")
print(f"President: {Country_Data[Country_Name][0]}")
print(f"Capital: {Country_Data[Country_Name][1]}")
print(f"Population: {Country_Data[Country_Name][2]}")
print(f"Currency: {Country_Data[Country_Name][3]}")
else:
print("Invalid choice")
else:
print("Data of the country is not available")
else:
print("Invalid choice")
Input: -
Output: -
Input2: -
Output2: -
Menu
1. Check the president of the country
2. Check the capital of the country
3. Check the population of the country
4. Check the currency of the country
5. Check all the details of the country
Enter your choice: 5
Input3: -
Output3: -
Reference
s
1.Python Software Foundation. (2023). Python
Documentation. Retrieved from https://docs.python.org/3/.
Thank
You 😊