PYTHON LOGIC/FRACTION ERROR(HOW TO SOLVE)

Asked

Viewed 42 times

-7

In this market box code, if you type 0 in the variable Pv there will be an error in the last print in the variable Vp/Pv, because there is no way to caucular a number x divided by zero, how do I make it so that if the person type 0 there is no error ? (solve the problem with codes or math logic ok)

t = '---'
l = '    ' * 9
print(l, 'Caixa numérico')
p = float(input('Qual o preço ?R$'))
d = float(input('Desconto por cento:'))
pv = int(input('Se deseja parcelar, coloque em quantas vezes, se não, digite "1":'))
v = p - (p / 100) * d
vp = p + (p / 100) * (20-d)
print('\nO produto com valor de {}, sairá por {}R${:.2f}{} a vista no desconto de {}%'.format(p, t, v, t, d))
print('ou {}R${:.2f} parcelado{} em {}{}x de R${:.2f}{}, no desconto de {}%'.format(e, vp, e, e, pv, vp/pv, e, d-20))```

1 answer

-2


Browser other questions tagged

You are not signed in. Login or sign up in order to post.