0% found this document useful (0 votes)
13 views4 pages

Untitled Document

Uploaded by

Sundes Bashir
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views4 pages

Untitled Document

Uploaded by

Sundes Bashir
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Python

Python is used in

Google
Youtube
Codehs

At the end of this class, you will be able to :

Make small games, like hangman!


Write a program that analyzes literature!
Go on to learn other languages with confidence and a solid understanding of programming
fundamentals!
Turtle graphics
Basic python programming
Make simple interactive
Console-based programs
Classes and object
Learn the basics of object-oriented programming ( oop)
Text Analysts
Put all your skills to the test by writing a program that analyzes pieces of liter
who is Tracy?
Tracy is a turtle that will follow commands
we give here when written in python. you have to use the python language
Tracy command: forward
forward (distance)
move Tracy forward a specified distance
forward(100)
if we forget a letter and then Tracy won’t move. Tracy will not move and she will remind
us.
Tracy command: circle
circle (radius )
tells Tracy to draw a circle with a specified redoes
circle(50)
Ex1: slinky
A program that has Tracy draw a slinky with 5 lops.
Where does Tracy live?
Tracy lives in a grid world
Tracy home is in the middle
Tracy always starts at ( 0,0)
The height is the same
Tracy commands backward
forward( distance)
Move Tracy forward a specific distance
→forward(100)
Backward (distance)
Move Tracy backward a specific distance
→ backward(100)
We also have penup and pendown command
penup()
Stops Tracy from leaving a trail
→penup()
forward(100)
pendown ()
Has Tracy started drawing a trail
→ pendown()
forward(100)
Note: Tracy always starts with her pen down!
Ex:
Write a program that has Tracy drow 2 dashes across the x-axis of the canvas command
learned this lesson
Turning Tracy
How do we make Tracy turn?
Tracy always starts facing right
Tracy command: left and right
left(90)
Turns Tracy go degrees to the left
right(90)
Turns Tracy go degrees to the right
Using for loops

For loops are used to repeat code a fixed number of times


For loops help us by :
● Shortening our code
● making it easy to alter our code
Writing for loops
For I in range ( amount of time to repeat ) :
Commands to repeat go here ( indented)
Example: square using loops
Write a program that has Tracy draw a square with sides of 50 pixels using a for loop
Turning Tracy using angles
Turning Tracy - limitations
What if we want Tracy to draw diagonal lines?
Right now, Tracy can only turn at 90-degree angles but we need her to be able to turn at any
angle we wish
Advancing turning commands
left(angle)
Turns Tracy left at a specified angle
→ left(45)
Right(angle)
Turns Tracy right at a specific angle
→right(45)
Tracy command: set position
Set position(x, y)
Moves Tracy to a specıfıed coordinate
→ swtposıtıon(100,100)
Tracy command: speed
Speed( number 0-10)
Sets how quickly Tracy will move through commands
speed( 1 ): slowest
Speed( 5 ): medium
speed( 10 ): fastest
speed( 0 ): immediate

You might also like