To celsius display result stop 13 your rst program

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview:  Each statement contains one or more instrucAons (or commands) • In every programming language we have these kinds of instruc3ons:   Input: gather data and/or interac3ons from user   Output: provide feedback and/or show results   CalculaAon: perform (basic) opera3ons to produce the results   Workflow: check for some condi3ons and determine how to con3nue with the computa3on   RepeAAon: perform the same ac3on over and over again 12 4 13 ­09 ­10 Your first program • Task: Ask the user for temperature in Fahrenheit and return temperature in Celsius • Breakdown of task:   Ask user for the temperature   Do the conversion   Print out the result Start Ask temperature Convert to Celsius Display result Stop 13 Your first program • Task: Ask the user for temperature in Fahrenheit and return temperature in Celsius • Breakdown:   Ask user for the temperature: input   Do the conversion: calcula3on   Print out the result: output Start Ask temperature Convert to Celsius Display result Stop 14 The code #!/usr/local/bin/python3 # Converts temperatures from Fahrenheit to Celsius # Ask user for input F = float( input("Please enter a temperature in Fahrenheit: ") ) # Do the conversion C = (F-32)*5/9 # Print the result print("The temperature in Celsius is: ", C ) 15 5 13 ­09 ­10 Statements Statement More about statements later! #!/usr/local/bin/python3 # Converts temperatures from Fahrenheit to Celsius # Ask user for input F = float( input("Please enter a temperature in Fahrenheit: ") ) # Do the conversion C = (F-32)*5/9 # Print the result print("The temperature in Celsius is: ", C ) In Python, there is...
View Full Document

This document was uploaded on 03/02/2014.

Ask a homework question - tutors are online