Chapter 1. Objectives To provide examples of computer science in the real world To provide an overview of common problem- solving strategies To introduce.

Slides:



Advertisements
Similar presentations
Python Basics: Statements Expressions Loops Strings Functions.
Advertisements

By Now, 1. Your Student ID should open the classroom door 2. You should have C:\100 folder Desktop shortcuts to Command Prompt and Notepad 3. You should.
Static Single Assignment CS 540. Spring Efficient Representations for Reachability Efficiency is measured in terms of the size of the representation.
Python Programming: An Introduction to Computer Science
Vahé Karamian Python Programming CS-110 CHAPTER 2 Writing Simple Programs.
CS 201 Functions Debzani Deb.
Chapter 2 Writing Simple Programs
Computer Science: A Structured Programming Approach Using C1 Objectives ❏ To understand basic loop concepts: ■ pretest loops and post-test loops ■ loop.
Copyright © 2014 Dr. James D. Palmer; This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.
Chapter 3 Planning Your Solution
VARIABLES AND EXPRESSIONS NUMERICAL EXPRESSION A NAME FOR A NUMBER VARIABLE OR ALGEBRAIC EXPRESSION AN EXPRESSION THAT CONTAINS AT LEAST ONE VARIABLE.
Computer Science 111 Fundamentals of Programming I Iteration with the for Loop.
13-3: Radian Measure Radian Measure There are 360º in a circle The circumference of a circle = 2r. So if the radius of a circle were 1, then there a.
CC0002NI – Computer Programming Computer Programming Er. Saroj Sharan Regmi Week 7.
Python Programming, 2/e1 Python Programming: An Introduction to Computer Science Chapter 2.
COMP 171: Functions, for loops and range John Barr Section 03 Slides by Toby Dragon.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 6 Value- Returning Functions and Modules.
CS 127 Writing Simple Programs.  Stages involved  Analyze the problem  Understand as much as possible what is trying to be solved  Determine Specifications.
The College of Saint Rose CIS 433 – Programming Languages David Goldschmidt, Ph.D. from Concepts of Programming Languages, 9th edition by Robert W. Sebesta,
Chapter 6 Functions 1. Opening Problem 2 Find the sum of integers from 1 to 10, from 20 to 37, and from 35 to 49, respectively.
Python Programming in Context Chapter 2. Objectives To understand how computers can help solve real problems To further explore numeric expressions, variables,
CSE 102 Introduction to Computer Engineering What is an Algorithm?
Class 2 Introduction to turtle graphics
Computer Science: A Structured Programming Approach Using C1 Objectives ❏ To be able to list and describe the six expression categories ❏ To understand.
Chapter 2: General Problem Solving Concepts
CSC 110 Using Python [Reading: chapter 1] CSC 110 B 1.
COSC 235: Programming and Problem Solving Ch. 2: Your first programs!!! Instructor: Dr. X.
1 Computer Science of Graphics and Games MONT 105S, Spring 2009 Lecture 17 Parameters, Scope, Return values.
Python break,continue and pass Statements. The break Statement: for letter in 'Python': # First Example if letter == 'h': break print 'Current Letter.
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 5: Algorithms Computer Science: An Overview Tenth Edition by J. Glenn.
Chapter 6 Questions Quick Quiz
2. WRITING SIMPLE PROGRAMS Rocky K. C. Chang September 10, 2015 (Adapted from John Zelle’s slides)
Algorithm Discovery and Design Objectives: Interpret pseudocode Write pseudocode, using the three types of operations: * sequential (steps in order written)
How the Session Works Outline Practical on arrival Talk 1 Reflect on practical Clarify concepts Practical exercises at your own pace Talk 2: Further concepts.
Midterm Review Important control structures Functions Loops Conditionals Important things to review Binary Boolean operators (and, or, not) Libraries (import.
Sequences CMSC 120: Visualizing Information 2/26/08.
7-2 Similar Polygons Objectives Students will be able to:
Computer Program Flow Control structures determine the order of instruction execution: 1. sequential, where instructions are executed in order 2. conditional,
Python Programming, 2/e1 Python Programming: An Introduction to Computer Science Chapter 2.
March 8 th,  Problem 1) A) What is the formula for the area of a circle? B) What is the formula for the circumference of a circle? C) How do these.
Chapter 2 Writing Simple Programs
Program design Program Design Process has 2 phases:
Computer Programming.
Topic: Recursion – Part 2
Topic: Iterative Statements – Part 1 -> for loop
Introduction to Programming
Python: Experiencing IDLE, writing simple programs
COSC 1306 COMPUTER SCIENCE AND PROGRAMMING
While loop Get names up to five times count=0 while count< 5:
FIGURE 4-10 Function Return Statements
Chapter 6 Functions.
Algebra 1 Section 2.3 Subtract real numbers
Chapter 6 Repetition Objectives ❏ To understand basic loop concepts:
Teaching KS3 Computing Session 4 Theory: Boolean logic AND/OR/NOT
3-3 Side Effects A side effect is an action that results from the evaluation of an expression. For example, in an assignment, C first evaluates the expression.
Foundations for Algebra
CSc 110, Spring 2017 Lecture 4: Nested Loops and Loop Figures
Computer Science — An Overview J. Glenn Brookshear
Notes Over 3.7 Solve for the indicated variable. 1. Area of a Triangle.
Computer Science Core Concepts
Evaluating Expressions
Topics Introduction to Value-returning Functions: Generating Random Numbers Writing Your Own Value-Returning Functions The math Module Storing Functions.
Introduction to Value-Returning Functions: Generating Random Numbers
Unit 3 lesson 2-5 The Need For Algorithms- Creativity in Algorithms – Simple Commands - Functions Day 18.
Introduction to Computer Science
Chopin’s Nocturne.
CMPT 120 Lecture 16 – Unit 3 – Graphics and Animation
CMPT 120 Lecture 15 – Unit 3 – Graphics and Animation
CMPT 120 Lecture 18 – Unit 3 – Graphics and Animation
STATE STANDARDS S.P.I Apply properties to evaluate expressions, simplify expressions, and justify solutions to problems. S.P.I Write.
Presentation transcript:

Chapter 1

Objectives To provide examples of computer science in the real world To provide an overview of common problem- solving strategies To introduce Python’s numeric data types To show examples of simple programs To introduce loops and simple functions To introduce turtle graphics

Computer Science Problem Solving Algorithms Abstraction Programming

Problem Solving Simplification Generalization

Figure 1.1

Figure 1.2

Python Overview Data Objects Operators Expressions Assignment Statements (variables, names) Python Interpreter (read, evaluate, print)

Figure 1.3

Figure 1.4

Figure 1.5

Figure 1.6

Figure 1.7

Abstraction and Functions Black Box Container for a sequence of actions Use the function by name

Figure 1.8

turtle module Simple graphics programming Abstraction Fun and easy

Figure 1.9

Defining Functions Name Parameters Body

Listing 1.1 def functionName(param1,param2,...): statement1 statement2...

Listing 1.2 def drawSquare(myTurtle,sideLength): myTurtle.forward(sideLength) myTurtle.right(90) # side 1 myTurtle.forward(sideLength) myTurtle.right(90) # side 2 myTurtle.forward(sideLength) myTurtle.right(90) # side 3 myTurtle.forward(sideLength) myTurtle.right(90) # side 4

Figure 1.10

Figure 1.11

Iteration Repeat a sequence of steps Use a for statement range function

Listing 1.3 def drawSquare(myTurtle,sideLength): for i in range(4): myTurtle.forward(sideLength) myTurtle.right(90)

Figure 1.12

Listing 1.4 def drawSpiral(myTurtle,maxSide): for sideLength in range(1,maxSide+1,5): myTurtle.forward(sideLength) myTurtle.right(90)

Figure 1.13

Drawing a Circle Simplify and Generalize Polygon with more and more sides

Listing 1.5 def drawTriangle(myTurtle,sideLength): for i in range(3): myTurtle.forward(sideLength) myTurtle.right(120)

Generalize 3 sides – 120 degrees 4 sides – 90 degrees 5 sides – 72 degrees 8 sides – 45 degrees N sides - ? Degrees

Listing 1.6 def drawPolygon(myTurtle,sideLength,numSides): turnAngle = 360 / numSides for i in range(numSides): myTurtle.forward(sideLength) myTurtle.right(turnAngle)

Figure 1.14

Listing 1.7 def drawCircle(myTurtle,radius): circumference = 2 * * radius sideLength = circumference / 360 drawPolygon(myTurtle,sideLength,360)

Figure 1.15