Use your lecture Notes to do the Us presidents program like I did in class. Make sure you load in the results file and the python code file
Fundamentals of Python: Data Structures, 2nd Edition
Author: Kenneth Lambert
Publisher: Cengage, 2019
ISBN-13: 9780357122754
Textbook Data files:
http://www.cengage.com/cgi-wadsworth/course_produc…
An Introduction to Programming Using Python
David I. Schneider
An Introduction to Computing
and Problem Solving
Lesson 1
© 2016 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
Questions and Answers
• How do we communicate with the computer?
– Programming languages
• How do we get computers to perform
complicated tasks?
– Tasks are broken down into a sequence of
instructions
• Why Python?
– Powerful, easy to download, write and read
© 2016 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
Questions and Answers
• How did the language Python get its name?
– Named for the British comedy group Monty
Python (really!)
• Book uses the editor IDLE to create programs.
How did IDLE get its name?
– Stands for Integrated DeveLopment Environment
• What is an interpreted language?
– Uses an interpreter, translates high-level language
one statement at a time into machine language
and then runs
© 2016 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
Questions and Answers
• What are the meanings of the terms
“programmer” and “user”?
– Programmer: a person who solves problems by
writing programs on a computer
– User: any person who runs a program
• What is the meaning of the term “code”?
– Python statements that the programmer writes
© 2016 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
Questions and Answers
• Are there certain characteristics that all
programs have in common?
– Input, processing, output
• What are the meanings of the terms
“hardware” and “software”?
– Hardware: physical components of the computer
– Software: the programs
© 2016 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
Questions and Answers
• How are problems solved with a program?
– Step-by-step procedure devised to process given
data and produce requested output.
• What is a zero-based numbering system?
– Numbering begins with zero instead of one
• Prerequisites to learning Python?
– Be familiar with how folders and files are managed
© 2016 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
Questions and Answers
• What is an example of a program developed in
this textbook?
© 2016 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
FIGURE 1.1 A possible output for a program in Lesson 2.
Questions and Answers
• How does the programmer create such a
program?
– About ten lines of code that search a text file
named USpres.txt and extract the requested
names.
© 2016 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
Questions and Answers
• What conventions are used to show
keystrokes?
– key1+key2 means “hold down key1 and then press
key2”
• Ctrl+C places selected material into the Clipboard
– key1/key2 means “Release key1 and then press
key2”
• Alt/F opens the FILE menu on a menu bar.
© 2016 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
Questions and Answers
• How can the programs for the examples in this
textbook be obtained?
– See the preface for information
• Where will new programs be saved?
– Create a special folder to hold your programs
• Where can I research questions I have about
Python?
– Documentation at https://www.python.org/doc/
© 2016 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
https://www.python.org/doc/
Program Development Cycle
© 2016 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
FIGURE 1.2 The problem solving process.
Program Planning
1. Analyze: Define the
problem.
2. Design: Plan the solution to the problem.
3. Code: Translate the algorithm into a
programming language.
4. Test and correct: Locate and remove any
errors in the program.
5. Complete the documentation: Organize all
the material that describes the program.
© 2016 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
Programming Tools
• Algorithms
•
Flowcharts
•
Pseudocode
• Hierarchy charts
© 2016 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
Algorithm Development
Algorithm to determine number of stamps for a
letter
• Rule of thumb: 1 stamp for every 5 sheets of
paper
1. Request sheets of paper
2. Divide by 5
3. Round quotient up to next whole number
4. Reply with number of stamps
© 2016 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
Problem Solving for Stamps
© 2016 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
FIGURE 1.3 The problem solving process
for the stamp problem.
Flowcharts
© 2016 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
Example
Flowchart
© 2016 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
FIGURE 1.4 Flowchart
for the postage-stamp
problem.
Pseudocode
• Abbreviated plain English version of actual
computer code
• Symbols used in flowcharts replaced by
English-like statements
• Allows programmer to focus on steps required
to solve problem
© 2016 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
Example Pseudocode
© 2016 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
FIGURE 1.5 Pseudocode for the postage stamp problem.
Hierarchy Chart
• Shows the overall program structure
• Depict organization of program, omit specific
processing logic
• Describe what each part, or module, of the
program does
• Each module subdivided into a succession of
submodules
© 2016 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
Example Hierarchy Chart
© 2016 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
FIGURE 1.6 Hierarchy chart for the postage-stamp problem.
Decision Structure
© 2016 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
FIGURE 1.7 Pseudocode and flowchart for a decision structure.
Direction of Numbered
NYC Streets Algorithm
• Problem: Given street number of one-way
street in New York City, decide direction of
street, either eastbound or westbound.
• Discussion: There is a simple rule to tell the
direction of a one-way street in New York City:
Even-numbered streets run eastbound.
© 2016 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
Direction of Numbered
NYC Streets Algorithm
• Input: Street number.
• Processing: Decide if the street number is
divisible by 2.
• Output: “Eastbound” or “Westbound”.
© 2016 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
© 2016 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
Direction of Streets Algorithm
FIGURE 1.8
Flowchart for the
numbered
New York City
streets problem.
© 2016 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
Direction of Streets Algorithm
FIGURE 1.9 Pseudocode for the numbered
New York City streets problem.
© 2016 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
Direction of Streets Algorithm
FIGURE 1.10 Hierarchy chart for the numbered
New York City streets problem.
Repetition Structure
• A programming structure that executes
instructions many times
– Repetition structure
– Looping structure
• Need a test (or condition) to tell when the
loop should end
– Check condition before each pass through loop
© 2016 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
© 2016 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
Direction of Streets Algorithm
FIGURE 1.11 Pseudocode and flowchart for a loop.
Class Average Algorithm
• Problem: Calculate and report the average
grade for a class.
• Discussion: Average grade equals sum of all
grades divided by number of students.
– Need loop to read and then add (accumulate)
grades for each student in class.
– Inside the loop, we also need to total (count)
number of students in class.
© 2016 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
Class Average Algorithm
• Input: Student grades.
• Processing: Find the sum of the grades; count
the number of students; calculate average
grade = sum of grades / number of students.
• Output: Average grade
© 2016 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
© 2016 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
Class Average Algorithm
FIGURE 1.12 Flowchart for the class average problem.
© 2016 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
Class Average Algorithm
FIGURE 1.13 Pseudocode for the class average problem.
© 2016 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
Class Average Algorithm
FIGURE 1.14 Hierarchy chart for the class average problem.
How to get Python compiler
• Go to: https://www.python.org/downloads/
• Follow instruction’s on how to install python
on your favorite Operating system.
• If this is your first time using a programming
compiler you are encourage to do the
tutorials.
© 2016 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
https://www.python.org/downloads/
Starting IDLE
• Windows:
Invoke with double click of
• MAC:
Open Finder, select Applications, select the
Utilities folder, select Terminal, and then enter
IDLE at the prompt
• LINUX and UNIX: usually be found at
/usr/bin/idle3
© 2016 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
Starting IDLE
FIGURE 1.16 The Python shell.
© 2016 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
Starting IDLE
FIGURE 1.17 The Python shell after the
expression 2 + 3 has been evaluated.
© 2016 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
Starting IDLE
FIGURE 1.18 The Python shell after the
statement print(“hello CS625 Class “) has been executed.
© 2016 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
A Python Code Editor Walkthrough
FIGURE 1.19 The File drop-down list.
© 2016 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
A Python Code Editor Walkthrough
FIGURE 1.20 The code editor window generated
after New Window is clicked on.
© 2016 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
A Python Code Editor Walkthrough
FIGURE 1.21 The code editor window
containing a three-line Python program.
© 2016 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
A Python Code Editor Walkthrough
FIGURE 1.22 A Save As dialog box.
© 2016 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
A Python Code Editor Walkthrough
FIGURE 1.23 The code editor window containing
a three-line Python program.
© 2016 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
A Python Code Editor Walkthrough
FIGURE 1.24 Press the F5 key to execute.
The outcome of the Python program in Fig. 1.22.
© 2016 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
A Python Code Editor Walkthrough
FIGURE 1.25 A Save message box.
© 2016 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
An Open-a-Program Walkthrough
FIGURE 1.26 An Open dialog box.
© 2016 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
Click on desired
program
An Open-a-Program Walkthrough
FIGURE 1.27 Example 10 of Section 3.4.
© 2016 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
An Open-a-Program Walkthrough
FIGURE 1.28 Request for input from Example 10 of Section 3.4.
© 2016 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
An Open-a-Program Walkthrough
FIGURE 1.29 Complete output for Example 10 of Section 3.4.
© 2016 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
Block-Structure
Figure 1.30 Example 10 of Section 3.4.
© 2016 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
The File Drop-down Menu
FIGURE 1.31 The File drop-down menu.
© 2016 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
We provide professional writing services to help you score straight A’s by submitting custom written assignments that mirror your guidelines.
Get result-oriented writing and never worry about grades anymore. We follow the highest quality standards to make sure that you get perfect assignments.
Our writers have experience in dealing with papers of every educational level. You can surely rely on the expertise of our qualified professionals.
Your deadline is our threshold for success and we take it very seriously. We make sure you receive your papers before your predefined time.
Someone from our customer support team is always here to respond to your questions. So, hit us up if you have got any ambiguity or concern.
Sit back and relax while we help you out with writing your papers. We have an ultimate policy for keeping your personal and order-related details a secret.
We assure you that your document will be thoroughly checked for plagiarism and grammatical errors as we use highly authentic and licit sources.
Still reluctant about placing an order? Our 100% Moneyback Guarantee backs you up on rare occasions where you aren’t satisfied with the writing.
You don’t have to wait for an update for hours; you can track the progress of your order any time you want. We share the status after each step.
Although you can leverage our expertise for any writing task, we have a knack for creating flawless papers for the following document types.
Although you can leverage our expertise for any writing task, we have a knack for creating flawless papers for the following document types.
From brainstorming your paper's outline to perfecting its grammar, we perform every step carefully to make your paper worthy of A grade.
Hire your preferred writer anytime. Simply specify if you want your preferred expert to write your paper and we’ll make that happen.
Get an elaborate and authentic grammar check report with your work to have the grammar goodness sealed in your document.
You can purchase this feature if you want our writers to sum up your paper in the form of a concise and well-articulated summary.
You don’t have to worry about plagiarism anymore. Get a plagiarism report to certify the uniqueness of your work.
Join us for the best experience while seeking writing assistance in your college life. A good grade is all you need to boost up your academic excellence and we are all about it.
We create perfect papers according to the guidelines.
We seamlessly edit out errors from your papers.
We thoroughly read your final draft to identify errors.
Work with ultimate peace of mind because we ensure that your academic work is our responsibility and your grades are a top concern for us!
Dedication. Quality. Commitment. Punctuality
Here is what we have achieved so far. These numbers are evidence that we go the extra mile to make your college journey successful.
We have the most intuitive and minimalistic process so that you can easily place an order. Just follow a few steps to unlock success.
We understand your guidelines first before delivering any writing service. You can discuss your writing needs and we will have them evaluated by our dedicated team.
We write your papers in a standardized way. We complete your work in such a way that it turns out to be a perfect description of your guidelines.
We promise you excellent grades and academic excellence that you always longed for. Our writers stay in touch with you via email.