1 / 12

Vaja

Vaja. Prebere ime in starost – izpiše „tvoje ime je jakob in si star 18 let“ Prebere stranico kocke in izpiše njen volumen in površino. (POW(,) **) Imamo znesek v €. Imamo bankovce po 100€, 50€, 20€, 10€, 5€ in 1€. Program naj izpiše kak bi znesek predstavili s temi bankovci.

minnie
Download Presentation

Vaja

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Vaja • Prebere ime in starost – izpiše „tvoje ime je jakob in si star 18 let“ • Prebere stranico kocke in izpiše njen volumen in površino. (POW(,) **) • Imamo znesek v €. Imamo bankovce po 100€, 50€, 20€, 10€, 5€ in 1€. Program naj izpiše kak bi znesek predstavili s temi bankovci. • 399€ = 3*po100+1*po50+2*po20+1*po5+4*po1

  2. Python Turtle

  3. Getting Started with Graphics Programming • >>> import turtle # Import turtle module • >>> turtle.showturtle() • >>> turtle.write("Welcome to Python") • >>> turtle.forward(100)

  4. 6 • Type the following commands to turn the arrowhead right 90 degrees, change the • turtle’s color to red, and move the arrowhead 50 pixels forward to draw a line, as • shown in Figure 1.15d: • >>> turtle.right(90) • >>> turtle.color("red") • >>> turtle.forward(50)

  5. 7 • Now, type the following commands to turn the arrowhead right 90 degrees, set the color to • green, and move the arrowhead 100 pixels forward to draw a line, as shown in Figure 1.15e: • >>> turtle.right(90) • >>> turtle.color("green") • >>> turtle.forward(100)

  6. 8. • Finally, type the following commands to turn the arrowhead right 45 degrees and move • it 80 pixels forward to draw a line, as shown in Figure 1.15f: • >>> turtle.right(45) • >>> turtle.forward(80)

  7. 1.9.2 Moving the Pen to Any Location • Restart Python and type the following command to move the pen to (0, 50) from (0, 0), as • shown in Figure 1.16b. • >>>fromturtleimport * • >>> goto(0, 50) #ni več besede turtle!!

  8. Turtle 2

  9. Move • The center of the Turtle Graphics window is at the coordinates (0, 0). (b) Move to (0, 50). (c) Move the • pen to (50, –50). (d) Set color to red. (e) Draw a circle using the circle command

  10. penup() pendown() • You can also lift the pen up or put it down to control whether to draw a line when the pen • is moved by using the penup() and pendown() commands. For example, the following • commands move the pen to (50, -50), as shown in Figure 1.16c. • >>> penup() • >>> goto(50, -50) • >>> pendown() • >>> color("red") • >>> circle(50) # Draw a circle with radius 50

  11. Drawing the Olympic Rings Logo • 1 importturtle • 2 • 3 turtle.color("blue") • 4 turtle.penup() • 5 turtle.goto(-110, -25) • 6 turtle.pendown() • 7 turtle.circle(45) • 8 • 9 turtle.color("black")

  12. 10 turtle.penup() • 11 turtle.goto(0, -25) • 12 turtle.pendown() • 13 turtle.circle(45) • 14 • 15 turtle.color("red") • 16 turtle.penup() • 17 turtle.goto(110, -25) • 18 turtle.pendown() • 19 turtle.circle(45) • 20 • 21 turtle.color("yellow") • 22 turtle.penup() • 23 turtle.goto(-55, -75) • 24 turtle.pendown() • 25 turtle.circle(45) • 26 • 27 turtle.color("green") • 28 turtle.penup() • 29 turtle.goto(55, -75) • 30 turtle.pendown() • 31 turtle.circle(45) • 32 • 33 turtle.done()

More Related