obrazky
-
  1. The following program works with variables. Without using a computer, say what the program will print:

     km = 8
     c = 30
     s = km * c + 50
      print('For a journey of', km, 'km with our taxi you will pay', s, 'Euros')
    

Use Python on a computer to check whether your calculation was correct.

  1. Create a program called zmena.py that can convert euros into Czech crowns. Use the variables price and excange_rate, and assign initial values to them – how many euros you want to exchange and the current exchange rate. Assign to the variable dostanes an expression that calculates how many crowns you will receive for your amount. The program should print the result, for example, in the following format:

For … euros you will receive … crowns at an exchange rate of … crowns per euro.

  1. Without using a computer, determine and draw on paper approximately how the following rectangles will be positioned. What are the height and width of each one?

     import tkinter
     canvas = tkinter.Canvas()
     canvas.pack()
     canvas.create_rectangle(50, 70, 220, 150)
     canvas.create_rectangle(60, 80, 130, 140)
     canvas.create_rectangle(160, 90, 230, 160)
    

Use Python on a computer to check whether your drawing was correct.

  1. Create a program called rectangle.py and draw a rectangle with one vertex at coordinates [200, 100], with a width of 60 and a height of 140.

  2. Create a new program called next_to.py that draws two squares next to each other, each with sides of length 80. Choose the position of the squares as you wish.

  3. Create a program called concetrical.py that draws two large squares – one with a side length of 100 and the other with a side length of 150. The squares should have the same center.

  4. Create a program called pyramid.py that uses three rectangles with dimensions 150×50, 100×50, and 50×50 to draw a pyramid.

pyramida

  1. Create a program called ornament.py that uses five squares to draw the following ornament. Choose the dimensions of the squares yourself (all smaller squares should be the same size).

ornament

  1. So far, we have been drawing unfilled rectangles. Create a program called colored.py and use the following code to draw a filled rectangle:

             import tkinter
             canvas = tkinter.Canvas()
             canvas.pack()
             canvas.create_rectangle(30, 30, 130, 130, fill='red')
    
  2. Add 3 more commands for drawing rectangles to the program colored.py so that you get the following picture.

styri stvorce

How can we get more colors?

  1. Create a new program called dutch.py that draws the Dutch flag.

  2. Create a new program called flag.py and draw a picture like this:

vlajka

Which country’s flag does the picture resemble?

  1. Nasledujúci program pracuje s premennými. Povedzte bez použitia počítača, čo program vypíše:

     km = 8
     c = 30
     s = km * c + 50
     print('Za jazdu dĺžky', km, 'km s našim taxi zaplatíš', s, 'Eur')
    

Na počítači pomocou Pythonu skontrolujte, či bol váš výpočet správny.

  1. Vytvorte program zmena.py, ktorý bude vedieť zmeniť eurá na koruny. Použite premenné suma a kurz, do ktorých priradíte počiatočné hodnoty - koľko eur chcete vymeniť a aktuálny kurz. Do premennej dostanes priradte hodnotu výrazu, ktorým vypočítate, koľko korun dostanete za svoju sumu. Program vypíše výsledok napríklad v tvare:

             Za ... eur dostaneš ... korun pri kurze ... korun za euro.
    
  2. Bez použitia počítača určite a na papier nakreslite, ako približne budú rozmiestnené nasledujúce obdĺžniky. Aká je výška a šírka každého z nich?

     import tkinter
     canvas = tkinter.Canvas()
     canvas.pack()
     canvas.create_rectangle(50, 70, 220, 150)
     canvas.create_rectangle(60, 80, 130, 140)
     canvas.create_rectangle(160, 90, 230, 160)
    

Na počítači za použitia Pythonu skontrolujte, či bol váš nákres správny.

  1. Vytvorte program obdlznik.py a nakreslite obdĺžnik, ktorý má jeden vrchol na súradniciach [200, 100], a jeho šírka je 60 a výška 140.

  2. Vytvorte nový program vedla_seba.py, ktorý vedľa seba nakreslí dva štvorce so stranami dĺžky 80 (pozíciu štvorcov zvoľte podľa uváženia).

  3. Vytvorte program sustredne.py, ktorý nakreslí dva veľké štvorce - jeden so stranou 100 a druhý 150. Štvorce budú mať spoločný stred.

  4. Vytvorte program pyramida.py, ktorý z troch obdĺžnikov s rozmermi 150x50, 100x50 a 50x50 nakreslí pyramidu.

pyramida

  1. Vytvor program ornament.py, ktorý z piatich štvorcov nakreslí nasledujúci ornament. Rozmery štvorcov zvoľte podľa svojho uváženia (všetky menšie štvorce budú rovnakej veľkosti):

ornament

  1. Doteraz sme kreslili nevyfarbené obdĺžniky. VYtvorte program vyfarbene.py a pomocou nasledujúceho kódu nakreslite vyfarbený obdĺžnik:

             import tkinter
             canvas = tkinter.Canvas()
             canvas.pack()
             canvas.create_rectangle(30, 30, 130, 130, fill='red')
    
  2. Pridajte do programu vyfarbene.py ďalšie 3 príkazy na kreslenie obdĺžnikov, aby ste dostali nasledujúci obrázok:

styri stvorce

Ako získame ďalšie farby?

  1. Vytvorte novýprogram holandsko.py, ktorý nakreslí holandskú vlajku.

holandsko

  1. Vytvorte nový program vlajka.py a nakreslite takovýto obrázok:

vlajka

Vlajke ktorého štátu sa obrázok podobá?

-
Copyright © 2008-2026 Miroslava Valíková