Chapter 37 More with Subprograms

37.1 Simple Exercises with Subprograms

Exercise 37.1-1 A Simple Currency Converter

Do the following:

i)Write a subprogram named displayMenu that displays the following menu.
1)Convert USD to Euro (EUR)
2)Convert Euro (EUR) to USD
3)Exit
ii)Using the subprogram cited above, write a Python program that displays the previously mentioned menu and prompts the user to enter a choice (of 1, 2, or 3). If choice 1 or 2 is selected, the program must prompt the user to enter an amount of money and then it must calculate and display the corresponding converted value. The process must repeat as many times as the user wishes.

It is given that $1 = 0.94 EUR (€).

Solution

According to the “Ultimate” rule, the while-loop of the ...

Get Python and Algorithmic Thinking for the Complete Beginner now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.