I need to c reate a table in python using a two-dimensional list that stores a F
ID: 3763815 • Letter: I
Question
I need to create a table in python using a two-dimensional list that stores a Fahrenheit temperature and the equivalent Celsius temperature. Use the following range of Fahrenheit temperatures: -10 through 100 in increments of 10 (thus the temperatures will be: -10, 0, 10, 20, 30, 40, 50…and so on).
Display the contents of the list.
Similarly create tables/lists for: Miles to kilometers, Gallons to liters, Pounds to kilograms, Inches to centimeters (Starting at 0 through 100 in increments of 10)
Display the contents of each list.
Explanation / Answer
def f2c(f):
return (f-32)*5/9
def m2k(m):
return 1.60934*m
def g2l(g):
return 3.78541*g
def i2c(i):
return 2.54*i
f2clist = [[] for i in range(12)]
print f2c(98.4)
x= -10.0
i=0
while(x<=100.0):
f2clist[i]=[x,f2c(x)]
x=x+10.0
i=i+1
m2klist = [[] for i in range(11)]
i=0
x= 0.0
while(x<=100.0):
m2klist[i]=[x,m2k(x)]
x=x+10.0
i=i+1
g2llist = [[] for i in range(11)]
i=0
x= 0.0
while(x<=100.0):
g2llist[i]=[x,g2l(x)]
x=x+10.0
i=i+1
i2clist = [[] for i in range(11)]
i=0
x= 0.0
while(x<=100.0):
i2clist[i]=[x,i2c(x)]
x=x+10.0
i=i+1
print "Fahrenheit to celsius conversions:"
for i in range(12):
print f2clist[i]
print "miles to kilometers conversions:"
for i in range(11):
print m2klist[i]
print "gallons to litres conversions:"
for i in range(11):
print g2llist[i]
print "inches to centimeters conversions:"
for i in range(11):
print i2clist[i]
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.