Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion HexToDec.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def __getDecDigit(digit):
if digit == digits[x]:
return x

def hexToDec(hexNum):
def hex_to_Dec(hexNum):
decNum = 0
power = 0
for digit in range(len(hexNum), 0, -1):
Expand Down
49 changes: 25 additions & 24 deletions TempConversion.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,30 @@
# Temperature Conversion Program

def menu():
print("\n1. Celsius to Fahrenheit")
print("2. Fahrenheit to Celsius")
print("3. Exit")
choice = int(input("Enter a choice: "))
return choice

def toCelsius(f):
return int((f - 32) / 1.8)
print("\n1. Celsius to Fahrenheit")
print("2. Fahrenheit to Celsius")
print("3. Exit")
choice = input("Enter a choice: ")
return choice

def to_celsius(f):
return int((f - 32) / 1.8)

def to_fahrenheit(c):
return int(c * 1.8 + 32)

def toFahrenheit(c):
return int(c * 1.8 + 32)

def main():
choice = menu()
while choice != 3:
if choice == 1:
c = eval(input("Enter degrees Celsius: "))
print(str(c) + "C = " + str(toFahrenheit(c)) + "F")
elif choice == 2:
f = eval(input("Enter degrees Fahrenheit: "))
print(str(f) + "F = " + str(toCelsius(f)) + "C")
else:
print("Invalid choice.")
choice = menu()

main()
choice = menu()
while choice != '3':
if choice == '1':
c = float(input("Enter degrees Celsius: "))
print(f"{c}C = {to_fahrenheit(c)}F")
elif choice == '2':
f = float(input("Enter degrees Fahrenheit: "))
print(f"{f}F = {to_celsius(f)}C")
else:
print("Invalid choice.")
choice = menu()

if __name__ == "__main__":
main()