Python Programming January 2018 Lesson 4 of 10

Python Programming January 2018 Lesson 4 of 10

Python Programming January 2018 Lesson 4 of 10 Do Now in Pairs What do you think the mystery() function does? PRIMM Draw in here label colours

Do Now Answer Green square with red border Lesson objectives In this lesson we will use the Python turtle graphics to draw shapes You will learn about loops in Python that use the keyword for You will learn the term iteration All of you should be able to modify programs with a for loop Some of you will be able to write your own programs with a for loop

Activity 1: 10 minutes PRIMM Download the program starter_activity_sheet_4.py Save it into your area and check that it runs and gives you the same square Answer the questions on the Activity Sheet 4a Programming: 15 minutes Try the exercises on Activity Sheet 4a

PRIMM Moving on What does this code do? What is different here? PRIMM Draw in here

Moving on Answer What does this code do? Draw in here And what about this one? What does this code do? What is different here? PRIMM

Draw in here And what about this one? Answer What does this code do? Draw in here PRIMM Investigating the for loop B

A 1 These two lines will repeat four times 2 This is a stepper variable that goes up by one every time the code

repeats 3 This tells us the code inside the loop will repeat four times 4 This word is a Python keyword used for loops

(known as iteration) C D Match the description to the bit it is pointing to Investigating the for loop - answers B A

1 These two lines will repeat four times D 2 3 C D

4 This is a stepper variable that goes up by one every time the code repeats A This tells us the code inside the loop will repeat four times B This word is a Python

keyword used for loops (known as iteration) C Now try these exercises PRIMM 1. Download the next starter program with the for loop 2. Change your triangle function so that it uses a for loop 3. Write a program to create a pentagon and hexagon

Extension exercise Create an envelope() function which draws an envelope and check it works (Hint: it will call square() and triangle()) Review PRIMM Fill in the SIX gaps in this program to draw a triangle. 2 1 def

triangle(): 4 3 for counter in range(3): 5 forward(100) 6 right(120) Review - answers

PRIMM Fill in the SIX gaps in this program to draw a triangle. 2 1 def triangle(): 4 3 for counter in range(3): 5

forward(100) 6 right(120) Next lesson In our next programming lesson we will draw more graphics using Python for drawing

Recently Viewed Presentations

  • YEDTEPE NVERSTES GZ HASTANES DISORDERS OF THE CONJUNCTIVA

    YEDTEPE NVERSTES GZ HASTANES DISORDERS OF THE CONJUNCTIVA

    disorders of the conjunctiva and cornea yrd.doç. dr. vİldan ÖztÜrk
  • Skin and Body Membranes

    Skin and Body Membranes

    Cutaneous Membranes Cutaneous - (skin); only epithelial membrane that is dry Integumentary System Most roles are protective Helps maintain homeostasis Insulates body Keeps water and molecules in body Protects organs from bumps, cuts, etc. Make-up of epidermis Epidermis has no...
  • A benchmark for sparse matrix-vector multiplication

    A benchmark for sparse matrix-vector multiplication

    Times New Roman Bitstream Vera Serif StarSymbol Bitstream Vera Sans Mono Bitstream Vera Sans Lucidatypewriter Default Design Microsoft Excel Chart A benchmark for sparse matrix-vector multiplication Topcs for today: Sparse matrix-vector multiplication Register block optimization SMVM benchmarks: Three strategies 1)...
  • Introduction to Programming - Stanford University

    Introduction to Programming - Stanford University

    XQuery. Expression language (compositional) Each expression operates on & returns. sequence of elements. XPath is one type of expression. XQuery
  • Honoring Officers Killed in 2012 United States Canada

    Honoring Officers Killed in 2012 United States Canada

    Police Officer William D. "Bill" Talbert Montgomery County Police Department, MD EOW: Friday, January 27, 2012 Cause of Death: Duty related illness ... Deputy Sheriff Brian Hayden Choctaw County Sheriff's Office, OK EOW: Thursday, April 19, 2012 Cause of Death:...
  • ToNC workshop Next generation architecture H. Balakrishnan, A.

    ToNC workshop Next generation architecture H. Balakrishnan, A.

    Connections to the phone network Interaction of network organization and network economics Volume based charging and its implication for architecture? Other broad areas Wireless and sensor net architecture Topology issues Network design Optical networks Application level networks (P2P) Outreach CS...
  • Disclaimer This document contains data provided to WHO

    Disclaimer This document contains data provided to WHO

    Disclaimer. This document contains data provided to WHO by member states. Note that some member states only provide aggregate data to WHO, and for these, we are unable to generate a country profile.
  • Missional Interpretatio n of Scripture Missional Theology Movement

    Missional Interpretatio n of Scripture Missional Theology Movement

    It is especially obvious in the NT as NT authors use OT texts to describe how one lives "in Christ" The process is important because the process itself is application and thus shows us how to missionally apply biblical texts...