100% tevredenheidsgarantie Direct beschikbaar na je betaling Lees online óf als PDF Geen vaste maandelijkse kosten 4.2 TrustPilot
logo-home
Samenvatting

Summary Think Python2 Chapter 4

Beoordeling
-
Verkocht
-
Pagina's
6
Geüpload op
07-10-2018
Geschreven in
2018/2019

This is the summary for YOU, if you want to learn the basics of Python quickly. Not everyone has time to read a book of more than 200 pages. That's why I thought, why don't I make a short summary of it! This is a summary of chapter 4 of the book ThinkPython2 (with the exercises!). I can't summarize this book in a day ofcourse so I will keep uploading summaries of the chapters. So don't worry the rest of the chapters will come.

Meer zien Lees minder








Oeps! We kunnen je document nu niet laden. Probeer het nog eens of neem contact op met support.

Documentinformatie

Heel boek samengevat?
Nee
Wat is er van het boek samengevat?
Chapter 4
Geüpload op
7 oktober 2018
Aantal pagina's
6
Geschreven in
2018/2019
Type
Samenvatting

Onderwerpen

Voorbeeld van de inhoud

Chapter 4 Case study: interface design
This chapter is a case study that demonstrates a process for designing functions that work
together. The turtle module is introduced, which allows you to create images. If you’re using
PythonAnywhere, you won’t be able to run the turtle examples(at least not in 2015).

If you don’t have Python installed yet, now is the time to do it. Instructions:
http://tinyurl.com/thinkpython2e. Code examples from this chapter: http://thinkpython2.com/code/ polygon.py.

4.1 The turtle module
To check if you have the turtle module, open the Python interpreter and type:
>>> import turtle
>>> bob = turtle.Turtle()

When you run this code, you should see a new window with a small arrow(the turtle).
Create a file named mypolygon.py and type:
import turtle
bob = turtle.Turtle()
print(bob)
turtle.mainloop()

The turtle module (with ’t’) provides a function called Turtle (with ’T’) that creates a Turtle object,
which we assign to the variable bob. Printing bob displays something like:
<turtle.Turtle object at 0xb7bfbf4c>

This means that bob refers to an object with type Turtle as defined in module turtle. mainloop tells
the window to wait for the user to do something. In this case the user has to just close the window.
Once you create a Turtle, you can call a method to move it around. A method is similar to a
function, but with different syntax. So to move the turtle forward:
bob.fd(100)

The method, fd, is associated with the turtle object bob. Calling a method is like making a request:
you are asking bob to move forward. The argument fd is a distance in pixels, so the actual size
depends on your display.

Other methods you can call on a Turtle are bk to move backward, lt left turn and rt right turn. lt and
rt are in degrees. Each Turtle is holding a pen which is down or up. When it’s down it leaves a trail
when it moves. The methods pu and pd stand for “pen up” and “pen down”. To draw a right angle,
write this (after creating bob and before calling mainloop):
bob.fd(100)
bob.lt(90)
bob.fd(100)
Now modify the program to draw a square!

4.2 Simple repetition
Chances are you wrote something like this:
bob.fd(100)
bob.lt(90)
bob.fd(100)
bob.lt(90)
bob.fd(100)
bob.lt(90)
bob.fd(100)

Maak kennis met de verkoper

Seller avatar
De reputatie van een verkoper is gebaseerd op het aantal documenten dat iemand tegen betaling verkocht heeft en de beoordelingen die voor die items ontvangen zijn. Er zijn drie niveau’s te onderscheiden: brons, zilver en goud. Hoe beter de reputatie, hoe meer de kwaliteit van zijn of haar werk te vertrouwen is.
Yuna429 Hogeschool Rotterdam
Bekijk profiel
Volgen Je moet ingelogd zijn om studenten of vakken te kunnen volgen
Verkocht
185
Lid sinds
8 jaar
Aantal volgers
130
Documenten
38
Laatst verkocht
11 maanden geleden

Ik probeer zo goed mogelijk samenvattingen te maken. Hierbij kijk ik naar de informatie die in je boek staat, de opgaven en ik kijk af en toe op internet.

4,2

92 beoordelingen

5
48
4
23
3
14
2
1
1
6

Recent door jou bekeken

Waarom studenten kiezen voor Stuvia

Gemaakt door medestudenten, geverifieerd door reviews

Kwaliteit die je kunt vertrouwen: geschreven door studenten die slaagden en beoordeeld door anderen die dit document gebruikten.

Niet tevreden? Kies een ander document

Geen zorgen! Je kunt voor hetzelfde geld direct een ander document kiezen dat beter past bij wat je zoekt.

Betaal zoals je wilt, start meteen met leren

Geen abonnement, geen verplichtingen. Betaal zoals je gewend bent via iDeal of creditcard en download je PDF-document meteen.

Student with book image

“Gekocht, gedownload en geslaagd. Zo makkelijk kan het dus zijn.”

Alisha Student

Veelgestelde vragen