Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Using the following Python program: Redesign the solution in the following manne

ID: 3689571 • Letter: U

Question

Using the following Python program:

Redesign the solution in the following manner:

1. Ask the user for their name and their email address before you display the results of

the conversions.

2. When the user enters the email address search the string for the @ symbol. If the

symbol is not found, ask the user to re-enter their email address till they get it right.

3. When you display the conversion output to the user, you must include the user’s

name and email address in the output.

# convert Miles into kilometers
# convert temperature in fahrenheit to celsius
# convert Gallons to liters
# convert Pounds to kilograms
# convert Inches to centimeters
# convert Dolalrs to GBP

# take input from the user and Error checking

#Greeting
print("Hello Tell me how many miles you would like to convert!")
print("You will be able to convert Temperature, Gallons, pounds and inches and US Dollars as well!")

# Input is provided by the user in Miles
miles = float(input('How many Miles?: '))

# Error Check for Miles input
if(miles < 0):
   print("Invalid input Miles can not be negative, Program wil End.")
   quit()
else:
print("Miles Entered: ", miles)

# Input is provided by the user in degree fahrenheit
fahrenheit = float(input('Enter degree Fahrenheit: '))

# Error Check for Fahrenheit input
if(fahrenheit > 1000):
   print("Invalid input Fahrenheit Degree can not be above 1000 degrees, Program wil End.")
   quit()
else:
print("Fahrenheit Degrees Entered: ", fahrenheit)

# Input is provided by the user in Gallons
gallons = float(input('How Many Gallons: '))

# Error Check for Gallons input
if(gallons < 0):
   print("Invalid input Gallons can not be negative, Program wil End.")
   quit()
else:
print("Gallons Entered: ", gallons)
  
# Input is provided by the user in Pounds
pounds = float(input('How Many Pounds: '))

# Error Check for Pounds input
if(pounds < 0):
   print("Invalid input Pounds can not be negative, Program wil End.")
   quit()
else:
print("Pounds Entered: ", pounds)

# Input is provided by the user in Inches
inches = float(input('How Many Inches: '))

# Error Check for Inches input
if(inches < 0):
   print("Invalid input Inches can not be negative, Program wil End.")
   quit()
else:
print("Inches Entered: ", inches)
  
# Input is provided by the user in Dollars
Dollars = float(input('How Many Dollars: '))

# Error Check for Dollars input
if(Dollars < 0):
   print("Invalid input Dollars can not be negative, Program wil End.")
   quit()
else:
print("Dollars Entered: ", Dollars)

###########################################################################

# conversion factor Miles into kilometers
conv_fac = 1.6

# conversion factor fahrenheit to celsius
conv_fac1 = (fahrenheit -32) * 5/9

# conversion factor Gallons to liters
conv_fac2 = 3.9

# conversion factor pounds to kilograms
conv_fac3 = 0.45

# conversion factor Inches to centimeters
conv_fac4 = 2.54

# conversion factor Dollars to GBP (British Pounds)
conv_fac5 = 0.69
###############################################################################

# calculate miles into kilometers
kilometers = miles * conv_fac

# calculate fahrenheit to celsius
celsius = conv_fac1

# calculate Gallons to liters
liters = gallons * conv_fac2

# calculate pounds to kilograms
kilograms = pounds * conv_fac3

# calculate Inches to centimeters
centimeters = inches * conv_fac4

# calculate Dollars to GBP (British Pounds)
GBP = Dollars * conv_fac5

##################################################################################

# Display kilometers
print('%0.3f Miles is equal to %0.3f Kilometers' %(miles, kilometers))

# Display Degrees Celsius
print('%0.1f degree Fahrenheit is equal to %0.1f degree Celsius' %(fahrenheit,celsius))

# Display Liters
print('%0.3f Gallons is equal to %0.3f Liters' %(gallons,liters))

# Display kilograms
print('%0.3f Pounds is equal to %0.3f kilograms' %(pounds,kilograms))

# Display centimeters
print('%0.3f Inches is equal to %0.3f Centimeters' %(inches,centimeters))

# Display centimeters
print('%0.3f Dollars is equal to %0.3f GBP (British Pounds)' %(Dollars,GBP))

Explanation / Answer

# convert Miles into kilometers
# convert temperature in fahrenheit to celsius
# convert Gallons to liters
# convert Pounds to kilograms
# convert Inches to centimeters
# convert Dolalrs to GBP
# take input from the user and Error checking
#Greeting

print("Hello Tell me your name please!")
name = str(raw_input('Your name ?: '))
print("Your mail id")
email = ""
while(True):
email = str(raw_input('Your email ?: '))
flag = 0
for i in email :
if i == '@':
flag = 1
break
if flag == 1 :
break
else :
print("Invalid email. Pleae re-enter")


print("Hello Tell me how many miles you would like to convert!")
print("You will be able to convert Temperature, Gallons, pounds and inches and US Dollars as well!")
# Input is provided by the user in Miles
miles = float(input('How many Miles?: '))
# Error Check for Miles input
if(miles < 0):
print("Invalid input Miles can not be negative, Program wil End.")
quit()
else:
print("Miles Entered: ", miles)
# Input is provided by the user in degree fahrenheit
fahrenheit = float(input('Enter degree Fahrenheit: '))
# Error Check for Fahrenheit input
if(fahrenheit > 1000):
print("Invalid input Fahrenheit Degree can not be above 1000 degrees, Program wil End.")
quit()
else:
print("Fahrenheit Degrees Entered: ", fahrenheit)
# Input is provided by the user in Gallons
gallons = float(input('How Many Gallons: '))
# Error Check for Gallons input
if(gallons < 0):
print("Invalid input Gallons can not be negative, Program wil End.")
quit()
else:
print("Gallons Entered: ", gallons)

# Input is provided by the user in Pounds
pounds = float(input('How Many Pounds: '))
# Error Check for Pounds input
if(pounds < 0):
print("Invalid input Pounds can not be negative, Program wil End.")
quit()
else:
print("Pounds Entered: ", pounds)
# Input is provided by the user in Inches
inches = float(input('How Many Inches: '))
# Error Check for Inches input
if(inches < 0):
print("Invalid input Inches can not be negative, Program wil End.")
quit()
else:
print("Inches Entered: ", inches)

# Input is provided by the user in Dollars
Dollars = float(input('How Many Dollars: '))
# Error Check for Dollars input
if(Dollars < 0):
print("Invalid input Dollars can not be negative, Program wil End.")
quit()
else:
print("Dollars Entered: ", Dollars)
###########################################################################
# conversion factor Miles into kilometers
conv_fac = 1.6
# conversion factor fahrenheit to celsius
conv_fac1 = (fahrenheit -32) * 5/9
# conversion factor Gallons to liters
conv_fac2 = 3.9
# conversion factor pounds to kilograms
conv_fac3 = 0.45
# conversion factor Inches to centimeters
conv_fac4 = 2.54
# conversion factor Dollars to GBP (British Pounds)
conv_fac5 = 0.69
###############################################################################
# calculate miles into kilometers
kilometers = miles * conv_fac
# calculate fahrenheit to celsius
celsius = conv_fac1
# calculate Gallons to liters
liters = gallons * conv_fac2
# calculate pounds to kilograms
kilograms = pounds * conv_fac3
# calculate Inches to centimeters
centimeters = inches * conv_fac4
# calculate Dollars to GBP (British Pounds)
GBP = Dollars * conv_fac5
##################################################################################
print
print
print 'Name : ',name
print'Email : ',email
print
# Display kilometers
print('%0.3f Miles is equal to %0.3f Kilometers' %(miles, kilometers))
# Display Degrees Celsius
print('%0.1f degree Fahrenheit is equal to %0.1f degree Celsius' %(fahrenheit,celsius))
# Display Liters
print('%0.3f Gallons is equal to %0.3f Liters' %(gallons,liters))
# Display kilograms
print('%0.3f Pounds is equal to %0.3f kilograms' %(pounds,kilograms))
# Display centimeters
print('%0.3f Inches is equal to %0.3f Centimeters' %(inches,centimeters))
# Display centimeters
print('%0.3f Dollars is equal to %0.3f GBP (British Pounds)' %(Dollars,GBP))