2. Writing simple programs - 2 WRITING SIMPLE PROGRAMS...

Info icon This preview shows pages 1–9. Sign up to view the full content.

2. WRITING SIMPLE PROGRAMS Rocky K. C. Chang September 10, 2015 (Adapted from John Zelle’s slides)
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

Objectives To be able to understand and write Python statements to output information to the screen, assign values to variables, get numeric information entered from the keyboard, and perform a counted loop
Image of page 2
The Software Development Process Source: Life_Cycle#mediaviewer/File:SDLC_-_Software_Development_Life_Cycle.jpg
Image of page 3

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

Example Program: Temperature Converter Analysis the temperature is given in Celsius, user wants it expressed in degrees Fahrenheit. Specification Input temperature in Celsius Output temperature in Fahrenheit Output = 9/5(input) + 32
Image of page 4
Example Program: Temperature Converter Design Input, Process, Output (IPO) Prompt the user for input (Celsius temperature) Process it to convert it to Fahrenheit using F = 9/5(C) + 32 Output the result by displaying it on the screen
Image of page 5

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

Example Program: Temperature Converter Before we start coding, let s write a rough draft of the program in pseudocode. Pseudocode is precise English that describes what a program does, step by step. Using pseudocode, we can concentrate on the algorithm rather than the programming language.
Image of page 6
Example Program: Temperature Converter Pseudocode: Input the temperature in degrees Celsius (call it celsius) Calculate fahrenheit as (9/5)*celsius+32 Output fahrenheit Now we need to convert this to Python!
Image of page 7

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

Example Program: Temperature Converter #convert.py # A program to convert Celsius temps to Fahrenheit
Image of page 8
Image of page 9
This is the end of the preview. Sign up to access the rest of the document.
  • Fall '16
  • Rocky Chiang
  • Absolute Zero, Fahrenheit, Celsius, temperature converter

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern