Skip to content

Commit

Permalink
Merge pull request #13 from Mmabiaa/content-branch
Browse files Browse the repository at this point in the history
Uploaded Advanced Implemented Programs Directory
  • Loading branch information
Mmabiaa authored Jan 8, 2025
2 parents e8793c8 + e9cab77 commit 40d06a6
Show file tree
Hide file tree
Showing 17 changed files with 33,850 additions and 0 deletions.
56 changes: 56 additions & 0 deletions assets/Advanced Implemented Programs/Currency_Convertor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Currency conversion rates relative to USD
currency_rates = {
'USD': 1.0, # Base currency
'EUR': 0.85, # Euro
'GBP': 0.75, # British Pound
'JPY': 110.0, # Japanese Yen
'AUD': 1.35, # Australian Dollar
'CAD': 1.25, # Canadian Dollar
'CHF': 0.92, # Swiss Franc
'CNY': 6.45, # Chinese Yuan
'INR': 73.0, # Indian Rupee
'BRL': 5.2, # Brazilian Real
'GHC': 15.71 # Ghana Cedis
}

def convert_currency(amount, from_currency, to_currency, rates):
if (from_currency not in rates) or to_currency not in rates:
raise ValueError('Invalid currency')

#Convert amount to USd first
amount_in_usd = amount / rates[from_currency]

#Convert from usd to target currency
converted_amount = amount_in_usd * rates[to_currency]

return converted_amount

def main():
while True:
print('Welcome to the Currency Converter! 👌')
print('Available currencies: ', ','.join(currency_rates.keys()))

try:
amount = float(input('Enter the amount to convert: '))
from_currency = input('Enter the currency code you are converting from: ')
to_currency = input('Enter the currency code you are converting to: ')

converted_amount = convert_currency(amount, from_currency, to_currency, currency_rates)
print(f'{amount} {from_currency} == {converted_amount:.2f} {to_currency}')
except:
print('Invalid Input')

options = ('y', 'n')
Continue = input('Do more conversions (y/n): ').lower()
if Continue not in options:
print('Invalid options')

else:
if Continue == 'n':
print('Thanks for using the programming...😁')
break
else:
print('')


main()
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
43 changes: 43 additions & 0 deletions assets/Advanced Implemented Programs/Email_sender/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
from email.message import EmailMessage # A library that provides email methods
import ssl # A library that helps to send message
import smtplib # A library that helps to login into your email
from variables import password # Importing stored variables.

def Email_Data(): # A function to return email details
sender_email = input('Please enter your email address: ').strip().lower()

email_password = password

receiver_email = input('Please enter the recipient email address: ').strip().lower()

subject = input('Enter the email subject: ')

body = input("Enter your email message: \n")

return sender_email, receiver_email, email_password, subject, body


def Message_Data(sender_email, receiver_email, subject, body): # A function that use returned email details to send emails
em = EmailMessage()
em['From'] = sender_email
em['To'] = receiver_email
em['Subject'] = subject
em.set_content(body)

return em

def Login(sender_email, receiver_email, email_password, em): # A function that uses email details to login into the and send messages
context = ssl.create_default_context()

with smtplib.SMTP_SSL('smtp.gmail.com', 465, context=context) as smtp:
smtp.login(sender_email, email_password)
smtp.sendmail(sender_email, receiver_email, em.as_string())

def Main(): # A main function that holds all the functions to be called
sender_email, receiver_email, email_password, subject, body = Email_Data()
em = Message_Data(sender_email, receiver_email, subject, body)
Login(sender_email, receiver_email, email_password, em)
print(" ")
print('Email sent successfully!')

Main()
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# A variable to store password
password = 'dffk pipb gsbm vgba'
Loading

0 comments on commit 40d06a6

Please sign in to comment.