Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
12 views2 pages

Transcript 8

The document outlines a structured approach to refactor the Remitly Currency Manager by reviewing the existing codebase and defining essential functions for core functionalities like viewing, converting, and adding currencies. It emphasizes the importance of global and local variable management, program flow control, and the addition of analytical functions to enhance the currency management system. Additionally, it highlights the need for thorough comments and documentation to ensure code readability and maintainability.

Uploaded by

236f1a6634
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views2 pages

Transcript 8

The document outlines a structured approach to refactor the Remitly Currency Manager by reviewing the existing codebase and defining essential functions for core functionalities like viewing, converting, and adding currencies. It emphasizes the importance of global and local variable management, program flow control, and the addition of analytical functions to enhance the currency management system. Additionally, it highlights the need for thorough comments and documentation to ensure code readability and maintainability.

Uploaded by

236f1a6634
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Approach to Refactor the Remitly Currency Manager

1. Understand the Existing Codebase:


o Review the remitly_currency_manager.py file
from the previous week to understand the current
structure and functionality.
o Identify major operations such as viewing
currencies, converting currencies, adding new
currencies, etc.
2. Define Global Variables:
o Create global variables to store data that need to
be accessed across multiple functions, such
as exchange_rates.
3. Create the main() Function:
o Define a main() function that contains the primary
program loop.
o This function will call other functions based on user
input.
4. Menu Display Function:
o Define a function display_menu() to display menu
options and get the user's choice.
5. Core Functionalities as Separate Functions:
o View Currencies:
 Define a view_currencies() function to
display the available currencies.
o Convert Currency:
 Define a convert_currency(amount,
from_currency, to_currency) function to
perform currency conversion and return the
converted amount.
o Add New Currency:
 Define an add_currency(code,
rate) function to add a new currency to
the exchange_rates and return a
success/failure message.
6. New Analytical Functions:
o Calculate Average Exchange Rate:
 Define calculate_average_rate() to
calculate and return the average exchange
rate.
o Find Extreme Exchange Rates:
 Define find_extreme_rates() to find and
return the currencies with the highest and
lowest exchange rates.
o Apply Discount:
 Define apply_discount(amount,
discount_rate) to apply a discount to the
conversion amount and return the
discounted amount.
7. Function Parameters and Return Statements:
o Ensure each function takes appropriate
parameters and returns necessary values.
o Use parameters to pass data into functions and
return statements to pass data between functions.
8. Variable Scope Management:
o Use global variables for data that needs to be
shared across functions.
o Use local variables within functions for data that
doesn't need to persist beyond the function call.
o Clearly comment on the use of global and local
variables in your code.
9. Control Program Flow in main():
o In the main() function, use a loop to
call display_menu() and other functions based on
user input.
o Implement conditionals to handle different user
choices and call the appropriate functions.
10. Add Comments and Documentation:
o Add comments explaining the purpose and usage
of each function.
o Comment on the variable scope to demonstrate
understanding.
o Ensure code readability and maintain high-quality
comments.

You might also like