1
Hello, I’m trying to make a converter from real to dollar and to normal values it works but is giving error when I put the dollar*N10, type 420 real, or 840, it is left the exact value of the example dollar :
Type how many reals you have: 840
Enter the current quote of the dollar: 4.20
You with 840.00 real can buy 199.00 dollars and you have 4.20 real
Process finished with Exit code 0
I believe it’s because I’m using float but I don’t know how else to do it, follow the code below :
r = float(input('Digite quantos reais você tem: '))
d = float(input('Digite a cotação atual do dolar: '))
print('Você com {:.2f} reais pode comprar {:.2f} dólares e te sobram {:.2f} reais'.format(r, r // d, r % d))
It only makes sense to use the rest operator of the division for integer operands. You used for float operands.
– anonimo