CMPT 120 Lecture 15 – Unit 3 – Graphics and Animation

Slides:



Advertisements
Similar presentations
Python November 18, Unit 7. So Far We can get user input We can create variables We can convert values from one type to another using functions We can.
Advertisements

Main task -write me a program
1 CSC 221: Introduction to Programming Fall 2012 course overview  What did you set out to learn?  What did you actually learn?  Where do you go from.
Welcome to CSIS10A Computer Science: Beginning Programming Please, take a syllabus.
Chapter 1. Objectives To provide examples of computer science in the real world To provide an overview of common problem- solving strategies To introduce.
LAB.  Name : Maram ALdakheel   Web page:  O.H : --  My schedule:
Computer Security coursework 3 (part 1) Dr Alexei Vernitski.
CMSC 104, Section 301, Fall Lecture 18, 11/11/02 Functions, Part 1 of 3 Topics Using Predefined Functions Programmer-Defined Functions Using Input.
Today… The for loop. Introducing the Turtle! Loops and Drawing. Winter 2016CISC101 - Prof. McLeod1.
Welcome to CMPT 225 Data Structures and Programming Anne Lavergne
CMSC201 Computer Science I for Majors Lecture 19 – Recursion
Topic: Introduction to Computing Science and Programming + Algorithm
Topic: Python’s building blocks -> Variables, Values, and Types
Topic: Recursion – Part 2
Topic: Functions – Part 1
Topic: Iterative Statements – Part 1 -> for loop
CompSci 101 Introduction to Computer Science
Topic: Introduction to Computing Science and Programming + Algorithm
Intro CS – Loops & Creating Shapes
Topic: Python’s building blocks -> Statements
CompSci 101 Introduction to Computer Science
Topic: Python’s building blocks -> Variables, Values, and Types
It’s called “wifi”! Source: Somewhere on the Internet!
Topic: Recursion – Part 1
CMPT 120 Topic: Functions – Part 4
CMPT 120 Topic: Python strings.
Topic: Functions – Part 2
CMSC201 Computer Science I for Majors Lecture 11 – Program Design
Looping and Random Numbers
Functions.
CMSC201 Computer Science I for Majors Lecture 16 – Recursion
Last Class We Covered Data representation Binary numbers ASCII values
Mr. Smith’s Schedule 1st Period Computer Science I
Log onto a computer first then ….
CMSC201 Computer Science I for Majors Lecture 19 – Recursion
CISC101 Reminders Quiz 2 this week.
CSc 110, Spring 2017 Lecture 4: Nested Loops and Loop Figures
Unit 3: Lesson 9-Looping and Random Numbers
Faculty of Computer Science & Information System
Introduction to Programming
Portfolio Statement Your Name UCAS No.
Section 1 Introduction To Programming
Winter 2019 CISC101 2/17/2019 CISC101 Reminders
Lecture 8:The For Loop AP Computer Science Principles.
CISC101 Reminders Assignment 2 due this Friday.
Just Basic Lessons 9 Mr. Kalmes.
Introduction to Programming
CMPT 120 Lecture 2 - Introduction to Computing Science – Problem Solving, Algorithm and Programming.
CMPT 120 Lecture 3 - Introduction to Computing Science – Programming language, Variables, Strings, Lists and Modules.
CMPT 120 Lecture 12 – Unit 2 – Cryptography and Encryption –
CMPT 120 Lecture 16 – Unit 3 – Graphics and Animation
def-ining a function A function as an execution control structure
CMSC201 Computer Science I for Majors Lecture 12 – Program Design
Lecture 7 – Unit 1 – Chatbots Python – For loops + Robustness
CMPT 120 Lecture 10 – Unit 2 – Cryptography and Encryption –
CMPT 120 Lecture 4 – Unit 1 – Chatbots
CMPT 120 Lecture 13 – Unit 2 – Cryptography and Encryption –
Midterm - 1 Instructions
CMPT 120 Lecture 19 – Unit 3 – Graphics and Animation
Lecture 5 – Unit 1 – Chatbots Python – More on Conditional statements
Lecture 17 – Practice Exercises 3
CMPT 120 Lecture 18 – Unit 3 – Graphics and Animation
CMPT 120 Lecture 22 – Unit 4 – Computer Vision
Lecture 20 – Practice Exercises 4
Lecture 20 – Practice Exercises 4
Lecture 17 – Practice Exercise 3 SOLUTIONS
Introduction to Computing Science and Programming 1 Anne Lavergne
Week 7 - Friday CS 113.
Welcome to CMPT 225 Data Structures and Programming My name is Anne Lavergne Lecture 1 – Overview.
Review and Instructions
Presentation transcript:

CMPT 120 Lecture 15 – Unit 3 – Graphics and Animation Python – Introducing Turtle

This week, we will have … Weekly Exercise 6 Lab – Functions and Turtle Posted beside our Weekly Exercise 6 To be done during Wednesday’s open lab in CSIL or on your own time Not submitted, not marked – but an opportunity for you to practice developing software using Python Solutions will be posted on Friday – June 14 Assignment 1 Will be posted on our course web site this week

Last week, we looked at … What are these comments? Why are we returning plain? Should we not be returning cipher instead? Why are we returning cipher? Should we not be returning plain instead? https://repl.it/repls/TimelyJovialAssociate

Software Development Process Incremental Software development Part of the software development process is the idea of developing a program (software) incrementally – one piece at a time Once this piece has been tested and shown to work, we move on to the next piece Example of incremental software development using our Encryption/Decryption program (with functions) Piece 1 -> Main part of program + functions encrypt() and decrypt() without body -> called STUB Piece 2 -> Implement encrypt() function -> change return value from plain to cipher Piece 3 -> Implement decrypt() function -> change return value from cipher to plain

Solution: Different kinds of functions Activity: Fill this table using functions we have used so far! Function takes parameters Function does not take parameters Function returns a result (i.e., a returned value) upper( … ) <- does not take parameters strip( … ) len( … ) input( … ) upper( ) strip( ) input( ) isalpha( ) Function does not return a result (i.e., a returned value) print( … ) print( )

Are there “functions” in the real world? Mom says to Louise “Please, can you go make your bed?“ Specific task: Make bed Parameter(s): None required Returned value: None returned Mom says to Louise “Here’s $5, please, can you go buy a bag of apples?“ Specific task: Parameter(s): Returned value:

Are there “functions” in the real world? Mom says to Louise “Please, can you find my cell phone?“ Specific task: Parameter(s): Returned value: Mom says to Louise “Please, can you put these bags on the kitchen counter?“ Specific task: Put bags on kitchen counter

While loop using a sentinel – From our Weekly Exercise 5 https://repl.it/repls/IdenticalInterestingScans

Unit 3 - Graphics and Animation Pixar movies and your favourite 3D animated films these days are built with code Indeed, animated movies and video games today rely heavily on 2D and 3D graphics and animation technology In this unit, we’ll make basic animations using code, and learn how to build complex and beautiful graphics

Unit 3 - Graphics and Animation APPLICATIONS In this unit, we’ll learn about the computing science field of graphics and animation ALGORITHMS One of the algorithms we shall learn is called recursion Python We’ll learn about Turtle graphics, functions and loops

2. Choose this one, not regular Python Python (with Turtle) 1. Click on … 2. Choose this one, not regular Python

Let’s try it! Problem Statement: Write a program that draws a blue square with our Turtle We may need to know the Turtle coordinate system: ? (100,100) (0,0) ? (-100, -100)

How about this! Problem statement: Write a program that draws a chocolate chip cookie with our Turtle

But what if I want many cookies? Solution 1 Could I use a for loop?

But what if I want many cookies? Solution 2: Could I copy and modify the code many times, each instance drawing one cookie? Hum… This solution would lead to a lot of repeating code, which is not a good idea! See GPS! Why is that?

But what if I want many cookies? Solution 3: Best solution would be to use a __________________

But what if I want many cookies? But our function draws many cookies in the same spot! We have not solve our problem! Solution 4: So, the ultimate solution would be to design our function such that it takes __________________ !

Review - For next lecture How do we create a Turtle object, given the turtle module? What is the keyword necessary to make a while loop? What is the keyword necessary to create a function? What is the difference between function parameters and function arguments? What are the commands necessary to create an animation with Turtle? Why do we place our functions at the top of our program?