Introduction to Python

Slides:



Advertisements
Similar presentations
CS 100: Roadmap to Computing Fall 2014 Lecture 02: Fun With Turtles.
Advertisements

Introduction to TouchDevelop
Intro to C++. Getting Started with Microsoft Visual Studios Open Microsoft Visual Studios 2010 Click on file Click on New Project Choose Visual C++ on.
Programming Training kiddo Main Points: - Python Statements - Problems with selections.
PYTHON: PART 2 Catherine and Annie. VARIABLES  That last program was a little simple. You probably want something a little more challenging.  Let’s.
You SHOUD HAVE.. C:\100 folder A desktop shortcut to “IDLE (Python34)”
Agent P, I have been hearing some rumours about a Python Turtle.
1 Turtle Graphics and Math Functions And how you can use them to draw cool pictures!
Introduction to TouchDevelop
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.
An introduction to Logo Mike Warriner Engineering Director, Google Note: This course is not an endorsement of Logo by Google. All views in this document.
Python Programming Using Variables and input. Objectives We’re learning to build functions and to use inputs and outputs. Outcomes Build a function Use.
Make a blank window This is a starter activity and should take 5 minutes [ slide 1 ] 1.Log in to your computer 2.Open IDLE 3.In script mode create a file.
Lesson 4 Using Variables in Python – Creating a Simple ChatBot Program.
How to Write Lesson Plan Using the Direct Teach Instructional Model.
Making Python Pretty!. How to Use This Presentation… Download a copy of this presentation to your ‘Computing’ folder. Follow the code examples, and put.
Programming for GCSE 1.0 Beginning with Python T eaching L ondon C omputing Margaret Derrington KCL Easter 2014.
My Python Programmes NAME:.
Introduction to Python Lesson 1 First Program. Learning Outcomes In this lesson the student will: 1.Learn some important facts about PC’s 2.Learn how.
ALAN….ALAN… ALAN. WHO IS ALAN TURING?
1 Building Your Own Turtle Functions For making really cool pictures!
Getting started with the turtle Find the latest version of this document at
How to Write Lesson Plan Using the Project-Based Instructional Model.
Python Lesson 1 1. Starter Create the following Excel spreadsheet and complete the calculations using formulae: 2 Add A1 and B1 A2 minus B2 A3 times B3.
Turtle Graphics Let’s see what we can draw on Python!
Turtle Graphics Lesson 2 1. There are 3 homeworks to complete during the six lessons of this unit. Your teacher will let you know when a homework has.
For Loop GCSE Computer Science – Python. For Loop The for loop iterates over the items in a sequence, which can be a string or a list (we will discuss.
COMPUTER PROGRAMMING Year 9 – lesson 1. Objective and Outcome Teaching Objective We are going to look at how to construct a computer program. We will.
Turtle Graphics Just keep swimming …. Fill Shapes turtle.fillcolor(“#color_code”) turtle.begin_fill() turtle.end_fill() ■You must tell turtle when to.
Using the Python Turtle
Module 1: Investigation 1 Moving, Turning and Stamping
Graphics CIS 40 – Introduction to Programming in Python
Whatcha doin'? Aims: To start using Python. To understand loops.
Broadcasting (Adding a new level)
Bbc microbit Lesson 3 – Temperature hot medium.
COSC 1306 COMPUTER SCIENCE AND PROGRAMMING
Do it now activity Last lesson we used Flowol to create a solution to a problem a computer could solve. Identify what each symbol does:
Unit 3 Lesson 4 & 5- Programming With Simple Commands / Creating Functions Day 26.
turtle module Simple graphics programming How to use it ?
Impress presentation for 1st Level of Secondary Education Students which objective is to learn how to use Impress to make different presentations. Presentation.
Module 1: Investigation 4 Defining your own Pattern Blocks
Microsoft® Small Basic
Agent P, I have been hearing some rumours about a Python Turtle.
Frozen Graphics Lesson 3.
CS 100: Roadmap to Computing
Log onto a computer first then ….
Learning Outcomes –Lesson 4
CS 100: Roadmap to Computing
1. Open Visual Studio 2008.
Learning to Program in Python
WICS - Flappy Anteater Python Tutorial
Math Mania! Randomness Probability Welcome to Marble Mania.
Chap. 3 Functions Start Python IDLE (Shell) and open a new file.
Learning to Program in Python
Section 3 Programming with Turtle Graphics
Introduction to Python
Alice 2.2 Introduction.
Introduction to Turtle Graphics
Explain what touch develop is to your students:
Python Lesson’S 1 & 2 Mr. Kalmes.
Programming In Lesson 4.
Introduction to Python
Software Lesson 3.
Do it now – PAGE 3 You will find your do it now task in your workbook – look for the start button! Thursday, 23 May 2019.
Turtle Graphics Just keep swimming ….
Background for lab: the ord() function
Using Modules.
Bell Work Title: Turtle Intro Date:
Presentation transcript:

Introduction to Python Lesson 4 Modules, Objects and Methods

Learning Outcomes In this lesson the students will: Use in-built libraries (modules) Create a Turtle object and a Screen object Call methods

Modules A module is a file that contains definitions, including variables and functions that you can use. To use a module you just import it into your program.

Turtle Module We are going to use a Python module called turtle The turtle module allows us to create simple graphics. We can tell the turtle to go forward, go right, go left etc. Let’s look at some sample code…

Example import turtle # allows us to use the turtles library win = turtle.Screen() # creates a graphics window alex = turtle.Turtle() # create a turtle named alex alex.forward(150) # move forward by 150 units alex.left(90) # turn by 90 degrees alex.forward(75) # move forward by 75 units

Code Explained The module allows us to create two new data types – Turtle and Screen The Screen data type allows us to create a window we can draw in and the Turtle data type allows us to create a Turtle to draw with The last 3 lines of code tell the turtle what to draw (a straight line, turn left, draw another straight line) Let’s run the code

Run the code Copy and paste the code into IDLE and run it

Other methods We can also change the colours of the Screen and the line printed by the turtle To change the background colour: win.bgcolor("lightgreen") To change the colour and size of the line we draw alex.color("blue") alex.pensize(3) Let’s add this to our program

Note to Teacher Lots of methods here that you could use: http://docs.python.org/3/library/turtle.html Also check out the eBook on Moodle: http://interactivepython.org/courselib/static/thinkcspy/

Lesson Review In this lesson …