Reputation: 39
This code I wrote for a school assignment. I checked the code with pylint, and pylint reports pointless-statement for all if elif else statements. I don't know how to improve my code, is there someone who could help me out? Thanks
USD = 0.8500
GBP = 1.1700
JPY = 0.0077
RATE = 0.015
FEE_MIN = 2.00
FEE_MAX = 15.00
choise = int(input("Which currency do you want to exchange for euros? "
"1) USD dollar,2) GB pound, 3) JP yen : "))
#USD
if (choise) == 1:
foreign = round(float(input("What amount of dollars do you want to convert"
" to euros? : ")))
euros = round((foreign * USD), 2)
COST = (round((foreign * USD), 2) * RATE)
if COST <= FEE_MIN:
COST = FEE_MIN
elif COST > FEE_MAX:
COST = FEE_MAX
else:
COST
payout = (float(euros) - float(COST))
print("The transactioncost are: {:.2f}.".format(COST))
print("You'll receive {:.2f} euros.".format(payout))
#GBP
if (choise) == 2:
foreign = round(float(input("What amount of pounds do you want to convert"
" to euros? : ")))
euros = round((foreign * GBP), 2)
COST = (round((foreign * GBP), 2) * RATE)
if COST <= FEE_MIN:
COST = FEE_MIN
elif COST > FEE_MAX:
COST = FEE_MAX
else:
COST
payout = (float(euros) - float(COST))
print("The transactioncost are: {:.2f}.".format(COST))
print("You'll receive {:.2f} euros.".format(payout))
#JPY
if (choise) == 3:
foreign = round(float(input("What amount of yen's do you want to convert"
" to euros? : ")))
euros = round((foreign * JPY), 2)
COST = (round((foreign * JPY), 2) * RATE)
if COST <= FEE_MIN:
COST = FEE_MIN
elif COST > FEE_MAX:
COST = FEE_MAX
else:
COST
payout = (float(euros) - float(COST))
print("The transactioncost are: {:.2f}.".format(COST))
print("You'll receive {:.2f} euros.".format(payout))
Upvotes: 0
Views: 987