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.

Slides:



Advertisements
Similar presentations
2D Graphics Drawing Things. Graphics In your GUI, you might want to draw graphics E.g. draw lines, circles, shapes, draw strings etc The Graphics class.
Advertisements

Graphics Shapes. Setup for using graphics You have to import the graphics library You can use either “import graphics” or “from graphics import *” or.
Microsoft Word – Lesson 1
Programs/Algorithms.  Computer Architecture  What is a computer program?  Flow chart  Data states  Data  Variables  History – Why VB?  Procedural.
COMPSCI 105 S Principles of Computer Science
Windows Programming 1 Part 1 dbg --- Getting Acquainted with Visual Studio.NET and C#
Scratch Programming Session 6 of 10 If-then-else statements interactions Final projects specifications.
ObjectDraw and Objects Early Chris Nevison Barbara Wells.
1 Python Programming: An Introduction to Computer Science Chapter 3 Objects and Graphics.
Graphical User Interfaces A Quick Outlook. Interface Many methods to create and “interface” with the user 2 most common interface methods: – Console –
2 What is pyGame? A set of Python modules to make it easier to write games. –home page: –documentation:
Chapter 1: An Introduction to Visual Basic 2005 Programming with Microsoft Visual Basic 2005, Third Edition.
1-1 OBJ Copyright 2003, Paradigm Publishing Inc. Dr. Joseph Otto Silvia Castaneda Christopher deCastro CSULA Macromedia Flash MX Introduction.
BIM211 – Visual Programming Objects, Collections, and Events 1.
Peter Andreae Python for Level 3 CS4HS see website: ecs.vuw.ac.nz/Main/PythonForSchools.
Pep Up Instruction with PREZI Creating a Prezi for your Classroom.
Graphics A graphics program allows you to combine pictures and text in many different ways. Features – General Level Draw graphics Enter Text Common Tools.
Working with Symbols and Interactivity
Graphics and Procedures Programming Right from the Start with Visual Basic.NET 1/e 5.
Microsoft® Small Basic
© 2010 Delmar, Cengage Learning Chapter 3: Working with Symbols and Interactivity.
Computer Science 111 Fundamentals of Programming I Introduction to Graphics.
Extending HTML CPSC 120 Principles of Computer Science April 9, 2012.
Slide 1 Graphics Slide 2 Graphics A graphics package is a general purpose package used to draw pictures (graphics). Once produced, these can be saved.
Agent P, I have been hearing some rumours about a Python Turtle.
EVENT-DRIVEN PROGRAMMING. โปรแกรมและอุปกรณ์ส่วนมากที่ใช้ใน ชีวิตประจำวัน จะตอบสนองกับเหตุการณ์ที่ เกิดขึ้น ตัวอย่างของเหตุการณ์ อาทิ การเคลื่อน หรือ คลิกเมาส์
Unit 5, Lesson 1 Working with Databases. Objectives Identify the parts of the Access screen. Identify the parts of the Access screen. Understand the purpose.
Exploring the Macromedia Flash Workspace – Lesson 2 1 Exploring the Macromedia Flash Workspace Lesson 2.
EDT AutoCAD Layers1 Using AutoCAD Layers Sacramento City College EDT 310.
Macromedia Flash 8 Revealed WORKING WITH SYMBOLS AND INTERACTIVITY.
JavaScript Challenges Answers for challenges
EDT Chapter 41 Using Layers Chapter 4 Sacramento City College EDT 310.
CRE Programming Club - Class 5 Robert Eckstein and Robert Heard.
Click on this button to move to the previous slide of your notebook. Click on this button to move to the next slide of your notebook. Click on this button.
PyGame - Unit 1 PyGame Unit – – Introduction to PyGame.
Turtle Graphics Let’s see what we can draw on Python!
Learning the Basics of ArcMap 3.3 Updated 4/27/2010 Using Arc/View pt. 1 1.
Animation Fall Semester Exam Review James Martin High School Career and Technical Education.
UFCFY5-30-1Multimedia Studio Scripting for Interactive Media Using Interface Fields to Receive and Display Data to the User.
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.
Drawing!. Why Drawing? Drawing is crucial to any graphical application Understanding.
PowerPoint Project 1 These instructions will tell you what TAB you need to go to, but will not give you pictures of the COMMAND buttons you need. 1.Go.
Using the Python Turtle
Unit 5: Canvas Painter.
Pixels, Colors and Shapes
Introduction to Python
COSC 1306 COMPUTER SCIENCE AND PROGRAMMING
LOGO BY Kaotip 9S.
PYGAME.
Chapter 21 – Graphics/Tk Outline 21.1 Introduction 21.2 GD Module: Creating Simple Shapes 21.3 GD Module: Image Manipulation 21.4 Chart Module 21.5 Introduction.
Introduction to Programming: Module #2 Python, Trinket, and Turtle Graphics Lois Delcambre.
Fundamentals of Python: From First Programs Through Data Structures
Agent P, I have been hearing some rumours about a Python Turtle.
Learning to program with Logo
CS 100: Roadmap to Computing
CS 100: Roadmap to Computing
Learning to Program in Python
Module 2 Lesson 3 Over and Over Again
Extend Text Editor to Draw shapes
Otasuke GP-EX! Chapter 1 Menu Screen.
Chap. 3 Functions Start Python IDLE (Shell) and open a new file.
Windows Tutorial 7 Managing Multimedia Files
Topics Graphical User Interfaces Using the tkinter Module
Introduction to Turtle Graphics
Explain what touch develop is to your students:
Class 7 coordinates: pixel and with setCoords aspect ratio Rectangle
Module 2 Lesson 3 Over and Over Again
Module 2 Lesson 3 Over and Over Again
Using Modules.
CAMP 1 – MODULE 3 INSIDE MATHEMATICS
Presentation transcript:

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. The one we’ll look at allow us to create turtles and get them to draw shapes and patterns.

Our first turtle program Create a new turtle And start drawing a rectangle. The variable that refers to our first turtle is called alex

Load module named turtle Select type

Select Screen type Then create and open a window Which assign to variable n. Every window contains a canvas, which is the area inside the window on which we can draw.

Select Turtle type The dot notation turtle.Turtle means “The Turtle type that is defined within the turtle module”.

Instruct the object alex to move forward by 50 units.

Instruct the object alex to turn by 90 degrees

Line 4-6 instruct the object alex to move and to turn by activating alex’s method.

The variable n refer to this window. When we invoke its mainloop method, it enters a state where it wait for events (like keypresses, or mouse movement and clicks) Wait for user to close window

Method Methods are things object can do. An object can have various methods. An object can also have attributes (sometimes called properties) For example, each turtle has a color attribute. alex.color(“red”) will make alex red and drawing will be red too.

The state of the object The color of the turtle, the width of its pen, the position of the turtle within the window are all part of its current state. Similarly, the window object has a background color, and some text in the title bar, and a size and position on the screen. These are all part of the state of the window object.

Extend this program … 1.Modify this program so that before it create the window. It prompts the user to enter the desired background color. It should store the user’s responses in a variable, and modify the color of the window according to the user’s wishes. 2.Do similar changes to allow the user, at runtime, to set tess’ color

Instances We can have many turtles. Each of them is called an instance. Each instance has its own attributes and method – So alex might draw with a thin black pen and be at some position – While tess might be going in her own direction with a fat pink pen

The for loop

This move alex, but no line is drawn

x y 200,0 3.04, , , ,-0.00