Skip to content
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
47 changes: 47 additions & 0 deletions currency-converter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Dictionary of exchange rates (as of a specific date)
exchange_rates = {
'USD': 1.0,
'EUR': 0.85,
'GBP': 0.73,
'JPY': 109.29,
'CAD': 1.25,
}

# Function to convert an amount from one currency to another
def convert_currency(amount, from_currency, to_currency):
if from_currency in exchange_rates and to_currency in exchange_rates:
rate_from = exchange_rates[from_currency]
rate_to = exchange_rates[to_currency]
converted_amount = amount * (rate_to / rate_from)
return converted_amount
else:
return "Invalid currency code(s)."

# Main program loop
while True:
print("\nCurrency Converter")
print("Available Currencies:")
for currency in exchange_rates:
print(currency, end=' ')
print()

from_currency = input("Enter the source currency code (e.g., USD): ").upper()
to_currency = input("Enter the target currency code (e.g., EUR): ").upper()

try:
amount = float(input("Enter the amount to convert: "))
except ValueError:
print("Invalid amount. Please enter a valid number.")
continue

result = convert_currency(amount, from_currency, to_currency)

if isinstance(result, (float, int)):
print(f"{amount} {from_currency} is equal to {result} {to_currency}")
else:
print(result)

another_conversion = input("Do another conversion? (yes/no): ").lower()
if another_conversion != "yes":
print("Goodbye!")
break
50 changes: 50 additions & 0 deletions to-do-list.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Initialize an empty to-do list
todo_list = []

# Function to add a task to the to-do list
def add_task():
task = input("Enter a task: ")
todo_list.append(task)
print("Task added to the to-do list.")

# Function to view the to-do list
def view_tasks():
if not todo_list:
print("Your to-do list is empty.")
else:
print("To-Do List:")
for i, task in enumerate(todo_list, start=1):
print(f"{i}. {task}")

# Function to remove a task from the to-do list
def remove_task():
view_tasks()
task_index = int(input("Enter the number of the task to remove: "))

if 1 <= task_index <= len(todo_list):
removed_task = todo_list.pop(task_index - 1)
print(f"Task '{removed_task}' removed from the to-do list.")
else:
print("Invalid task number. No task removed.")

# Main program loop
while True:
print("\nTo-Do List Manager")
print("1. Add Task")
print("2. View Tasks")
print("3. Remove Task")
print("4. Quit")

choice = input("Enter your choice: ")

if choice == '1':
add_task()
elif choice == '2':
view_tasks()
elif choice == '3':
remove_task()
elif choice == '4':
print("Goodbye!")
break
else:
print("Invalid choice. Please select a valid option.")