0
I have the following program below in Python with 2 functions, one to convert real in dollars according to the quotation, and one to convert dollars to real also according to the quotation, plus a simple menu to decide between the 2 functions:
def reaispdolar () :
Reais = float (input("Quantos reais? R$: "))
Cotação = float (input("Cotação de hoje é? "))
conversão = Reais/Cotação
print("Você possui US$" , ("%.2f" % conversão))
def dolarpreais () :
Dolar = float(input("Quantos Dolares? US$: "))
Cotação = float(input("Cotação de hoje é? "))
Conversão = Cotação*Dolar
print("Você possui: R$", ("%.2f" % Conversão))
print("O que deseja fazer? ")
print("1 - Converter reais em dolares")
print("2 - Converter dolares em reais")
menu = input("Deseje a opção desejada\n")
if menu == "1" :
reaispdolar()
elif menu == "2" :
dolarpreais()
else :
print("Valor inválido",)
What I would like is that on the menu being the input
invalid or when the input
is correct and the conversion gives its final value, the following message appears: "You want to restart S/N ?": ").
And when the user presses "S" or "s" the program returns to the "start menu". It is possible to do this without while
?
wilhe
It’s not a methodology, it’s a loop instruction, and a programmer who’s afraid to use a loop is a popcorn uncle’s future. Ps: Nothing against popcorn uncles, but I don’t believe anyone went to college to become popcorn.– Augusto Vasques
@Augusto Vasques -> At what point has anyone mentioned fear of using ? I understand that While is important and can be used in this case, the only thing my question deals with is about other ways of performing the same operation without the while. Without fitting your comment.
– YagoFdev
You got an answer. But is it more beneficial for you? Or for those who are starting a career?
– Augusto Vasques