-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from Mmabiaa/content-branch
Uploaded Advanced Implemented Programs Directory
- Loading branch information
Showing
17 changed files
with
33,850 additions
and
0 deletions.
There are no files selected for viewing
56 changes: 56 additions & 0 deletions
56
assets/Advanced Implemented Programs/Currency_Convertor.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 added
BIN
+211 Bytes
assets/Advanced Implemented Programs/Email_sender/__pycache__/Security.cpython-312.pyc
Binary file not shown.
Binary file added
BIN
+243 Bytes
assets/Advanced Implemented Programs/Email_sender/__pycache__/app.cpython-312.pyc
Binary file not shown.
Binary file added
BIN
+211 Bytes
assets/Advanced Implemented Programs/Email_sender/__pycache__/password.cpython-312.pyc
Binary file not shown.
Binary file added
BIN
+249 Bytes
assets/Advanced Implemented Programs/Email_sender/__pycache__/variables.cpython-312.pyc
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
2 changes: 2 additions & 0 deletions
2
assets/Advanced Implemented Programs/Email_sender/variables.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# A variable to store password | ||
password = 'dffk pipb gsbm vgba' |
Oops, something went wrong.