Turtle Graphics Victor Norman CS104 Calvin College.

Slides:



Advertisements
Similar presentations
ThinkPython Ch. 10 CS104 Students o CS104 n Prof. Norman.
Advertisements

Selection Victor Norman CS104 Calvin College. Reading Quiz Counts toward your grade.
Python Basics: Statements Expressions Loops Strings Functions.
JavaScript Part for Repetition Statement for statement Cpecifies each of the items needed for counter-controlled repetition with a control variable.
1 Objects, Classes, and Packages “Static” Classes Introduction to Classes Object Variables and Object References Instantiating Objects Using Methods in.
Lecture 03 – Sequences of data.  At the end of this lecture, students should be able to:  Define and use functions  Import functions from modules 
CIS101 Introduction to Computing Week 12. Agenda Your questions Solutions to practice text Final HTML/JavaScript Project Copy and paste assignment JavaScript:
Modules and Objects Introduction to Computing Science and Programming I.
COMPSCI 125 Spring 2005 ©TheMcGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter 3: Numeric Data *Variables *Numeric data.
Java Library Java provides a huge library or collection of useful programs A gold mine of well-tested code that can save you countless hours of development.
CS 106 Introduction to Computer Science I 02 / 22 / 2008 Instructor: Michael Eckmann.
Chapter 3 Numerical Data. Topics Variables Numeric data types Assignment Expressions.
The If/Else Statement, Boolean Flags, and Menus Page 180
Classes and Objects, Part 1 Victor Norman CS104. Reading Quiz, Q1 A class definition define these two elements. A. attributes and functions B. attributes.
1 CS101 Introduction to Computing Lecture 35 Mathematical Methods (Web Development Lecture 12)
Tutoring Dos and Donts Unofficial alien of CS 5 Gold Unofficial alien of CS 5 Black Unofficial turtle of CS 5 Green Unofficial alien of CS 42 Official.
Python: Classes By Matt Wufsus. Scopes and Namespaces A namespace is a mapping from names to objects. ◦Examples: the set of built-in names, such as the.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 6 Value- Returning Functions and Modules.
FUNCTIONS. Function call: >>> type(32) The name of the function is type. The expression in parentheses is called the argument of the function. Built-in.
Programing Concept Ken Youssefi/Ping HsuIntroduction to Engineering – E10 1 ENGR 10 Introduction to Engineering (Part A)
MCB 5472 Assignment #6: HMMER and using perl to perform repetitive tasks February 26, 2014.
Python Libraries Importing and Calling functions.
Introduction to: Python and OpenSesame Part I. Python A high-level programming language It can do a lot of things We will use python in this course in.
JavaScript, Fourth Edition
Hello, little turtles. Hello, little turtles! There are many modules in Python that provide very powerful feature that we can use in our own program.
CS 320 Assignment 1 Rewriting the MISC Osystem class to support loading machine language programs at addresses other than 0 1.
Files Victor Norman CS104. Reading Quiz, Q1 A file must be ___________ before a program can read data from it. A. accessed B. unlocked C. opened D. controlled.
Math With Java The Math Class. First, A Quick Review of Math Operators in Java Primitive Data type in Java that represent numbers: Primitive Data type.
Q and A for Chapter 7 Students of CS104, and me, your benevolent professor, Victor T. Norman, PhD.
Q and A for Sections 2.9, 4.1 Victor Norman CS106 Fall 2015.
For loops in programming Assumes you have seen assignment statements and print statements.
Simple Python Data Victor Norman CS104 Calvin College.
Counter-Controlled Loops CSIS 1595: Fundamentals of Programming and Problem Solving 1.
Functions Victor Norman CS104 Calvin College. Reading Quiz Counts toward your grade.
© 2006 Pearson Education 1 Obj: to use assignment operators HW: Prelab Exercises 2 Quiz 3.1 – 3.4 in two class days  Do Now: 1.Read p.144 – 145 (3.4 “more.
Counting Loops.
1 Printing in Python Every program needs to do some output This is usually to the screen (shell window) Later we’ll see graphics windows and external files.
Chapter 7 Problem Solving with Loops
Structuring Data: Arrays ANSI-C. Representing multiple homogenous data Problem: Input: Desired output:
Classes and Objects, Part 1 Victor Norman CS104. “Records” In Excel, you can create rows that represent individual things, with each column representing.
Introduction to Functions CSIS 1595: Fundamentals of Programming and Problem Solving 1.
Python Basics  Functions  Loops  Recursion. Built-in functions >>> type (32) >>> int(‘32’) 32  From math >>>import math >>> degrees = 45 >>> radians.
CS 5JA Introduction to Java Graphics One of the powerful things about Java is that there is.
Functions Chapter 4 Python for Informatics: Exploring Information Slightly modified by Recep Kaya Göktaş on March 2015.
BIT 115: Introduction To Programming Professor: Dr. Baba Kofi Weusijana (say Doc-tor Way-oo-see-jah-nah, Doc-tor, or Bah-bah)
JavaScript and Ajax (JavaScript Functions) Week 5 Web site:
Unit 1 Lessons 2&3 Solving Equations by Adding, Subtracting, Multiplying, or Dividing Standards: CC.9-12.A.REI.1, CC.9-12.A.REI.3, CC.9-12.A.CED.1 EQ:
Computer Program Flow Control structures determine the order of instruction execution: 1. sequential, where instructions are executed in order 2. conditional,
Winter 2016CISC101 - Prof. McLeod1 CISC101 Reminders Quiz 3 next week. See next slide. Both versions of assignment 3 are posted. Due today.
CS 115 Lecture 5 Math library; building a project Taken from notes by Dr. Neil Moore.
Q and A for Sections 2.9, 4.1 Victor Norman CS106 Fall 2015.
More about Iteration Victor Norman CS104. Reading Quiz.
IE 8580 Module 4: DIY Monte Carlo Simulation
Computer Programming.
While loop Get names up to five times count=0 while count< 5:
Introduction To Repetition The for loop
JavaScript Functions.
Frozen Graphics Lesson 3.
CS 100: Roadmap to Computing
CS 100: Roadmap to Computing
CISC101 Reminders Quiz 2 this week.
Loops CIS 40 – Introduction to Programming in Python
Driving Test 1 Revision.
CS2011 Introduction to Programming I Loop Statements (II)
Winter 2019 CISC101 2/17/2019 CISC101 Reminders
Topics Introduction to Value-returning Functions: Generating Random Numbers Writing Your Own Value-Returning Functions The math Module Storing Functions.
CS 1111 Introduction to Programming Spring 2019
Class 6 using the math library
JavaScript 101 Lesson 8: Loops.
Using Modules.
Presentation transcript:

Turtle Graphics Victor Norman CS104 Calvin College

Reading Quiz Counts toward your grade.

Quick Introduction to Objects You have to instantiate the object, making a variable refer to it: – turt = turtle.Turtle() You call (or "invoke") methods on it: – turt.forward(10) – turt.doSomething(33, 22, 11) It is like asking the object to do something to itself: give me back a value or move yourself, or draw something, or change a value. The object stores its own state (or characteristics, properties, or attributes).

Clicker Question

for Loop Syntax Pattern: for in : # multiple statements Examples: for aVal in [3, 11, 22, 0, -3]: print(aVal) for aVal in [“I’m”, “a”, “lumberjack”, “and”, “I’m”, “ok”, 8, math.pi]: print(aVal)

for Loop Examples for val in [0, 1, 2, 3, 4, 5]: turt.forward(50) turt.left(60) total = 0 for val in [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]: total = total + val print(total) total = 0 for val in range(1, 21): total = total + val print(total)

range(start, stop, step) Built-in function Generates list of integers starting at start, going up to (but not including) stop, by increments of step. Can skip start  uses 0. E.g., range(10) Can skip step  uses 1. E.g., range(3, 7)

range() Examples range(30) generates list of numbers 0, 1, 2, …, 29. range(2, 30) generates list of numbers 2, 3, 4, 5, …, 29. range(-3, 3, 2) generates list of numbers -3, -1, 1. range(20, 0, -1) generates list of numbers 20, 19, 18, 17, …, 2, 1.

Clicker Questions

import statement import pulls a module in to your program. A module is a file with code and variables in it. – math module has sin(), cos(), round(), pi, e, etc. – myro has init(), forward(), backward(), etc. import loads the module in, but all the stuff in it is still in it. Access it via the “dot operator”. –import loads the “box” in but your code still has to reach into the box to get at the functions, variables, etc. e.g., math.sin(), math.pi

import (cont) If you want to pull something (everything) out of the “box”, you can do this from math import * from math import sin Then you don’t need to tell your code to reach into the module to get the function/variable. – e.g., can use sin() instead of math.sin() – init() instead of myro.init().

Assignments Do the few TuringsCraft questions before lab on Thursday.