top of page

Python - Currency Converter


In this program, we will learn to create reusable code with functions and make a currency converter that helps to convert currency from user-entered USD amount to different like, Euro, GBP, CAD, JPY. Also, this program should keep on asking the user till the user chooses the exit option.


If you wish to learn the concepts and see the detailed steps to arrive at the solution, refer to my video on youtube

Concepts Covered


python function, parameters, while loop, inputs, if-else, round values


How It Should Work



Approach


  • Create a function displayMenu that displays different options to the user as shown in the section How It Should Work

       1. Convert USD to Euro (EUR)    
       2 .Convert USD to British Pound Sterling(GBP)     
       3. Convert USD to Japanese Yen(JPY)      
       4. Convert USD to Canadian Dollar(CAD)           
       5. Exit

  • Write four different functions named USDtoEU ,USDtoGBP ,USDtoJPY and USDtoCAD, that accept a currency and return the corresponding converted value

  • Using these functions, write a python program that displays the menu previously mentioned and then prompts the user to enter a choice (of 1,2,3,4 or 5) and an amount in US dollars. The program must then display the required value.

  • Use a while loop to make sure the process repeats as many times as the user wishes.


It is given that:
$1 = 0.94 EUR
$1 =0.79 GBP
$1= 113 JPY
$1 =1.33 CAD


Solution











Comments


Never Miss a Post. Subscribe Now!

Thanks for submitting!

©anuradha agarwal

    bottom of page