Skip to content

Commit 40d06a6

Browse files
authored
Merge pull request #13 from Mmabiaa/content-branch
Uploaded Advanced Implemented Programs Directory
2 parents e8793c8 + e9cab77 commit 40d06a6

17 files changed

+33850
-0
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Currency conversion rates relative to USD
2+
currency_rates = {
3+
'USD': 1.0, # Base currency
4+
'EUR': 0.85, # Euro
5+
'GBP': 0.75, # British Pound
6+
'JPY': 110.0, # Japanese Yen
7+
'AUD': 1.35, # Australian Dollar
8+
'CAD': 1.25, # Canadian Dollar
9+
'CHF': 0.92, # Swiss Franc
10+
'CNY': 6.45, # Chinese Yuan
11+
'INR': 73.0, # Indian Rupee
12+
'BRL': 5.2, # Brazilian Real
13+
'GHC': 15.71 # Ghana Cedis
14+
}
15+
16+
def convert_currency(amount, from_currency, to_currency, rates):
17+
if (from_currency not in rates) or to_currency not in rates:
18+
raise ValueError('Invalid currency')
19+
20+
#Convert amount to USd first
21+
amount_in_usd = amount / rates[from_currency]
22+
23+
#Convert from usd to target currency
24+
converted_amount = amount_in_usd * rates[to_currency]
25+
26+
return converted_amount
27+
28+
def main():
29+
while True:
30+
print('Welcome to the Currency Converter! 👌')
31+
print('Available currencies: ', ','.join(currency_rates.keys()))
32+
33+
try:
34+
amount = float(input('Enter the amount to convert: '))
35+
from_currency = input('Enter the currency code you are converting from: ')
36+
to_currency = input('Enter the currency code you are converting to: ')
37+
38+
converted_amount = convert_currency(amount, from_currency, to_currency, currency_rates)
39+
print(f'{amount} {from_currency} == {converted_amount:.2f} {to_currency}')
40+
except:
41+
print('Invalid Input')
42+
43+
options = ('y', 'n')
44+
Continue = input('Do more conversions (y/n): ').lower()
45+
if Continue not in options:
46+
print('Invalid options')
47+
48+
else:
49+
if Continue == 'n':
50+
print('Thanks for using the programming...😁')
51+
break
52+
else:
53+
print('')
54+
55+
56+
main()
Binary file not shown.
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
from email.message import EmailMessage # A library that provides email methods
2+
import ssl # A library that helps to send message
3+
import smtplib # A library that helps to login into your email
4+
from variables import password # Importing stored variables.
5+
6+
def Email_Data(): # A function to return email details
7+
sender_email = input('Please enter your email address: ').strip().lower()
8+
9+
email_password = password
10+
11+
receiver_email = input('Please enter the recipient email address: ').strip().lower()
12+
13+
subject = input('Enter the email subject: ')
14+
15+
body = input("Enter your email message: \n")
16+
17+
return sender_email, receiver_email, email_password, subject, body
18+
19+
20+
def Message_Data(sender_email, receiver_email, subject, body): # A function that use returned email details to send emails
21+
em = EmailMessage()
22+
em['From'] = sender_email
23+
em['To'] = receiver_email
24+
em['Subject'] = subject
25+
em.set_content(body)
26+
27+
return em
28+
29+
def Login(sender_email, receiver_email, email_password, em): # A function that uses email details to login into the and send messages
30+
context = ssl.create_default_context()
31+
32+
with smtplib.SMTP_SSL('smtp.gmail.com', 465, context=context) as smtp:
33+
smtp.login(sender_email, email_password)
34+
smtp.sendmail(sender_email, receiver_email, em.as_string())
35+
36+
def Main(): # A main function that holds all the functions to be called
37+
sender_email, receiver_email, email_password, subject, body = Email_Data()
38+
em = Message_Data(sender_email, receiver_email, subject, body)
39+
Login(sender_email, receiver_email, email_password, em)
40+
print(" ")
41+
print('Email sent successfully!')
42+
43+
Main()
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# A variable to store password
2+
password = 'dffk pipb gsbm vgba'

0 commit comments

Comments
 (0)