Write a Python program that • Uses a while loop to produce a table that shows th
ID: 3630730 • Letter: W
Question
Write a Python program that• Uses a while loop to produce a table that shows the conversion of degrees Celsius to degrees Fahrenheit between 0 degrees Celsius and 100 degrees Celsius. The conversion formula is Fahrenheit = Celsius * 9 / 5 + 32
• Uses a for loop to produce a table that shows the conversion of degrees Fahrenheit to degrees Celsius between 0 degrees Fahrenheit and 100 degrees Fahrenheit. The conversion formula is Centigrade = (Fahrenheit – 32) * 5/9.
Each conversion table should be contained in a separate module called from a main module. Submit pseudocode for each module.
Explanation / Answer
1.PUEDOCODE:
1.table1(n):
2.celsius=0
3. while celsius<=n
4. print celsius,celsius*9/5+32
5. celsius=celsius+1
#CODE
#module for celsius to fahrenheit. name is FtoC.py
def table1(n):
celsius=0 #initiliase a variable i to 0 as a celsius value
while celsius(<n+1): #run while loop for i 0 through 100
print celsius,celsius*9/5+32 #print i(celsius value) and fahrenheit respectively
celsius=celsius+1 #increment i the loop variable
#end of module FtoC
2.PSUEDOCODE:
1.table2(n):
2.for fahrenheit 0 through n
3. print fahrenheit,celsius(=(fahrenheit-32)*5/9)
#CODE
#module for fahrenheit to celsius.name is CtoF.py
def table2():
for fahrenheit in range(n+1):
print fahrenheit,(fahrenheit-31)*5/9
#end of module CtoF
3.#in main module
>>from CtoF import table1 #importing function of table1 to comver celsius to fahrenheit
>>table1(100)
>>from FtoC import table2 #importing function of table1 to comver fahrenheit to celsius
>>table2(100)
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.