Python
/
Language
- 1 Language 9
-
Hello World S
-
Variables S
-
Functions S
-
Conditional A S
-
Operators S
-
While S
-
Turtle S
-
Script Mode S
-
Debugging S
- 2 Strings 7
-
Slice S
-
Raw Strings S
-
Regex A S
-
Validation S
-
Config S
-
Security S
-
Encrypt A S
- 3 Collections 6
-
Lists S
-
Dictionaries S
-
Efficiency S
-
Tree S
-
Tuples S
-
References S
- 4 Functions 5
-
Recursion S
-
Factorial S
-
Modulus S
-
Reassignment S
-
Approximate S
- 5 Storage 8
-
Files S
-
Databases S
-
Pipes S
-
With open S
-
Shelve A S
-
Zip S
-
Csv S
-
Json S
- 6 Class 4
-
Definition S
-
Attributes S
-
Functional S
-
Methods S
- 7 Goodies 5
-
Conditional Expression S
-
List Comprehension A S
-
Generator S
-
Named Tuple S
-
Modules S
- 8 Applications 5
-
Pythagora A S
-
Palindrome A S
-
Binary Search A S
-
Conway Game A S
-
Coin Flip A S
- 9 Scheduler 4
-
Time S
-
Multithreading A S
-
Subprocess S
-
Logging S
- 10 Packages 6
-
Clipboard A S
-
Ocr A S
-
Socket S
-
Image S
-
Virtualenv S
-
Jupyter S
S
R
Q
Python Language Turtle
Small arrow (turtle) Move the arrow forward fd() import turtle bob = turtle.Turtle(); bob.lt(90)
Turtle
1 p65 Python turtle module allows you to create images with turtle graphics.
# Drawing in Python
#
# Create a window with small arrow ...
# that represents the turtle.
#
# To move the turtle forward use fd() method.
# The argument of fd is in pixels, for lt() and rt() in degrees.
import turtle
bob = turtle.Turtle()
print(bob)
bob.fd(100) # pixels
bob.lt(90) # degrees
bob.fd(100)
turtle.mainloop()
Modify the program and draw a square.

# Square draw
#
# Draw a square using turtle module
import turtle
bob = turtle.Turtle()
print(bob)
bob.fd(100)
bob.lt(90)
bob.fd(100)
bob.lt(90)
bob.fd(100)
bob.lt(90)
bob.fd(100)
turtle.mainloop()
Loop
1 p69 The syntax of a for statement is similar to a function definition.
# Square draw - using loop
#
# The syntax of a for statement is similar to a function definition.
# The flow of execution runs through body and then loops back to the top.
import turtle
bob = turtle.Turtle()
print(bob)
for i in range(4):
bob.fd(100) # pixels
bob.lt(90) # degrees
turtle.mainloop()
➥ Questions