2. Writing simple programs

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

• Notes
• 28
• 100% (1) 1 out of 1 people found this document helpful

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)

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
The Software Development Process Source: Life_Cycle#mediaviewer/File:SDLC_-_Software_Development_Life_Cycle.jpg

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
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

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.
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!

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
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

• 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.

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

• 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.

Dana University of Pennsylvania ‘17, Course Hero Intern

• 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.

Jill Tulane University ‘16, Course Hero Intern