Hi guys, I'd like some feedback on my currency conveter, I was told that my previous version was too linear, this is much better in my opinion.
PHP Code
<?php
#Currency Converter
pound = 1.66
pound_eu = 1.21
euro = 1.21
euro_d = 0.74
euro_y = 138.98
dollar = 1.66
yen = 169.26
yen_d = 102.35
def main():
print("""
[!]Welcome to XBatt's Currency Converter
=======================================
[+]The currenty curreny rates are as following:
[+]The dollar to pound is {0}
[+]The euro to pound is {1}
[+]The yen to pound is {2}
""".format(dollar,euro,yen))
option = input("""
[+]If you would like to do a currency conversion enter 1
[+]If you would like to change the conversion rates enter 2
[+]If you would like to print the current conversion rates enter 3
""")
if option == "1":
option1()
elif option == "2":
option2()
elif option == "3":
option3()
else:
print ("[+]Option 1,2 or 3 not entered. Try again.\n\n\n\n")
main()
def option1():
option_convert = input("""
[+]What curreny would you you like to convert and convert to, (Example: dollar & pound) this would allow you to convert dollars to pounds.
""")
option_convert2 = option_convert.split('&')[0].strip()
option_convert3 = option_convert.split('&')[1].strip()
if option_convert2 == "dollar" and option_convert3 == "pound":
str1 = input ("[+]How many {0}s would you like to convert to {1}s? ".format(option_convert2,option_convert3))
num1 = float(str1)
result1 = num1 / dollar
print("[+]{0} {1}s is equal to {2} {3}s".format(num1,option_convert2,result1,option_convert3))
elif option_convert2 == "dollar" and option_convert3 == "euro":
str2 = input("[+]How many {0}s would you like to convert to {1}s? ".format(option_convert2,option_convert3))
num2 = float(str2)
result2 = num2 * euro_d
print("[+]{0} {1}s is equal to {2} {3}s".format(num2,option_convert2,result2,option_convert3))
elif option_convert2 == "dollar" and option_convert3 == "yen":
str3 = input ("[+]How many {0}s would you like to convert to {1}s? ".format(option_convert2,option_convert3))
num3 = float(str3)
result3 = num3 * yen_d
print ("[+]{0} {1}s is equal to {2} {3}s".format(num3,option_convert2,result3,option_convert3))
elif option_convert2 == "euro" and option_convert3 == "dollar":
str5 = input("[+]How many {0}s would you like to convert to {1}s? ".format(option_convert2,option_convert3))
num5 = float(str5)
result5 = num5 / euro_d
print("[+]{0} {1}s is equal to {2} {3}s".format(num5,option_convert2,result5,option_convert3))
elif option_convert2 == "euro" and option_convert3 == "yen":
str6 = input("[+]How many {0}s would you like to convert to {1}s? ".format(option_convert2,option_convert3))
num6 = float(str6)
result6 = num6 * euro_y
print("[+]{0} {1}s is equal to {2} {3}s".format(num6,option_convert2,result6,option_convert3))
elif option_convert2 == "euro" and option_convert3 == "pound":
str7 = input("[+]How many {0}s would you like to convert to {1}s? ".format(option_convert2,option_convert3))
num7 = float(str7)
result7 = num7 / pound_eu
print("[+]{0} {1}s is equal to {2} {3}s".format(num7,option_convert2,result7,option_convert3))
elif option_convert2 == "yen" and option_convert3 == "pound":
str8 = input("[+]How many {0}s would you like to convert to {1}s? ".format(option_convert2,option_convert3))
num8 = float(str8)
result8 = num8 / pound_eu
print("[+]{0} {1}s is equal to {2} {3}s".format(num7,option_convert2,result7,option_convert3))
elif option_convert2 == "yen" and option_convert3 == "dollar":
str9 = input("[+]How many {0}s would you like to convert to {1}s? ".format(option_convert2,option_convert3))
num9 = float(str9)
result9 = num9 / yen_d
print("[+]{0} {1}s is equal to {2} {3}s".format(num9,option_convert2,result9,option_convert3))
elif option_convert2 == "yen" and option_convert3 == "euro":
str10 = input("[+]How many {0}s would you like to convert to {1}s? ".format(option_convert2,option_convert3))
num10 = float(str10)
result10 = num10 / euro_y
print("[+]{0} {1}s is equal to {2} {3}s".format(num10,option_convert2,result10,option_convert3))
elif option_convert2 == "pound" and option_convert3 == "dollar":
str11 = input("[+]How many {0}s would you like to convert to {1}s? ".format(option_convert2,option_convert3))
num11 = float(str11)
result11 = num11 * pound
print("[+]{0} {1}s is equal to {2} {3}s".format(num11,option_convert2,result11,option_convert3))
elif option_convert2 == "pound" and option_convert3 == "euro":
str12 = input("[+]How many {0}s would you like to convert to {1}s? ".format(option_convert2,option_convert3))
num12 = float(str12)
result12 = num12 * euro
print("[+]{0} {1}s is equal to {2} {3}s".format(num12,option_convert2,result12,option_convert3))
elif option_convert2 == "pound" and option_convert3 == "yen":
str13 = input("[+]How many {0}s would you like to convert to {1}s? ".format(option_convert2,option_convert3))
num13 = float(str13)
result13 = num13 * yen
print("[+]{0} {1}s is equal to {2} {3}s".format(num13,option_convert2,result13,option_convert3))
else:
print("[+]Something went wrong...")
main()
def option2():
print ("[+]Welcome to the currency rates changer section, to change the rates please answer the following questions.")
c1 = input("How many dollars in each pound? ")
c1num = float(c1)
pound = c1
c2 = input(" How many yen in a euro? ")
c2num = float(c2)
euro_y
c3 = input("How many euros in a pound?")
c3num = float(c3)
euro = c3
c4 = input("How many euros in a dollar?")
c4num = float(c4)
euro_d = c4
c4 = input("How many dollars in a pound?")
c4num = float(c4)
dollar = c4
c5 = input("How many pounds in a yen?")
c5num = float(c5)
yen = c5
c6 = input("How many yens in a dollar?")
c6num = float(c6)
yen_d = c6
print("Congratulations, you have changed the curent conversion rates, the program will now restart so you can convert!")
main()
def option3():
text_file = open("Current_Exchange_Rates.txt", "w")
text_file.write("£1 = £{0} \n".format(dollar))
text_file.write("£1 = €{0} \n".format(euro))
text_file.write("£1 = ¥{0} \n".format(yen_d))
text_file.close()
print("The text file has been created in the directory of this script!")
if __name__ == "__main__":
main()
end = input("Enter q to exit or c to restart the progarm")
if end == "q":
print("Bye!")
elif end == "c":
main()
Things I love - Pentesting,Python,Linux,CryptoCurrencies,Legion,Server Administration,Raspberry Pi - PM me if you wanna talk!
Freelance Pentester and Python coder.
![[Image: 2EOBWgX.png]](https://i.imgur.com/2EOBWgX.png)
Freelance Pentester and Python coder.
![[Image: 2EOBWgX.png]](https://i.imgur.com/2EOBWgX.png)

