Just fix and organize the code below. Show screenshot code running!
Write a menu-driven script that consolidates your code in 1 – 5. Define a function running each of them.
However, you need to use a dictionary-based
Jump Table to implement the menu
Sample run:
Assignment 5 Testing Script
1 Temperature Conversion and Mapping
2 Filtering Grades
3 Reducing Strings
4 Exit
Just fix and organize the code below
# our function temp_conversion
def convert():
for i in range(len(cel)):
cel[i] = (9 * cel[i] / 5 + 32)
cel = []
number = int(input("How many elements you want to covert? : "))
for i in range(0, number):
number = int(input("Enter the temperature in Celcius : "))
cel.append(number)
print("The temperature in Celcius are", cel, "degrees")
print("The temperature in Fahrenheit are", cel, "degrees")
# our function filtering_grades
def filtering_grades():
lst1 = []
lst2 = []
n = int(input("Enter number of elements : "))
for i in range(0, n):
n = int(input("Enter numbers between 1 to 100: "))
lst1.append(n)
print("The list of numbers are : ", lst1)
for j in range(len(lst1)):
if lst1[j] >= 80 and lst1[j] <=>=>
lst2.append(lst1[j])
print("The list of numbers in range are : ", lst2)
# our function reducing_strings
def reducing_strings():
from functools import reduce
words = ['Programming ', 'in ', 'Python ', 'is ', 'fun!']
statement = ''
result = reduce(lambda a, b: a + statement + b, words)
print(result)
# our function myexit
def myexit():
print("Thank you!")
exit()
# print statements
print("-------------------------------------")
print("1.Celcius to fahrenheit conversion")
print("2.Filter even and odd number ")
print("3.Reduce the string")
print("3.Exit from program ")
print("-------------------------------------")
# infinite loop
while (choice):
# asking choice
choice = int(input(("Please enter the choice (1-4): ")))
# if condition
if (choice <= 0="" or="" choice="">= 5):
print(f"Invalid choice! ")
# else
else:
# if condition
if (choice == 1):
convert(cel)
# elif condition
elif (choice == 2):
filtering_grades()
# elif condition
elif (choice == 3):
reducing_strings()
# elif condition
else:
myexit()
=>