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

2. The algorithm for convert.py is: Input the temperature in Celsius degree Calc

ID: 3879800 • Letter: 2

Question

2. The algorithm for convert.py is:

Input the temperature in Celsius degree

Calculate to Fahrenheit degree: Fahrenheit = (9/5)*Celsius + 32

Output Fahrenheit degree

3. Open IDLE Shell, then click File -->New File, TYPE convert.py file into IDLE Scripts mode. (right-hand side screenshot as below)

Comments are to explain each line of statements. It's important to help understand this program.

4. Click Run --> Run Module (or just simple click shortcut F5). Respond/interact this program (within the Interactive mode, left-hand side screenshot as below) by typing a number as requested.

See screenshots:

5. Point out each identifier (all the names in program), each variable, each expression, assignment, loop.

Modify the convert.py Program?

Programming Excises 1: Modify the convert.py to print an intro.

Programming Excises 3: Modify the convert.py to loop 5 times with different inputs before quitting, name it as: convert_v2.py.

Run it to see what the result is.

Explanation / Answer

Combined code that covers both Programming Exercises 1 and 2 and is well commented as well:

## convert_v2.py

## A program to convert Celsius to Fahrenheit

def main():

print("Welcome This program converts the given temperature in Celsius to Fahrenheit.")

print("It uses the relation: F = (9/5)*C + 32 to get the required temperature.")

## We will loop 5 times to take the input from the user and print the answer.

## _ acts as a variable here. xrange is used to provide an iterator.

for _ in xrange(5):

celsius = eval(input( "Enter the Temperature in Celsius:"))

# celsius will hold the temp. in celsius that is taken from the user

fahrenheit = 9*celsius/5 + 32

print("The temperature in Fahrenheit is: ",fahrenheit , "degrees fahrenheit.")

main()

  

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote