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.
For … euros you will receive … crowns at an exchange rate of … crowns per euro.
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.
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.
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.
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.
Create a program called pyramid.py that uses three rectangles with dimensions 150×50, 100×50, and 50×50 to draw a pyramid.
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')
Add 3 more commands for drawing rectangles to the program colored.py so that you get the following picture.
How can we get more colors?
Create a new program called dutch.py that draws the Dutch flag.
Create a new program called flag.py and draw a picture like this:
Which country’s flag does the picture resemble?
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.
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.
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.
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.
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).
Vytvorte program sustredne.py, ktorý nakreslí dva veľké štvorce - jeden so stranou 100 a druhý 150. Štvorce budú mať spoločný stred.
Vytvorte program pyramida.py, ktorý z troch obdĺžnikov s rozmermi 150x50, 100x50 a 50x50 nakreslí pyramidu.
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')
Pridajte do programu vyfarbene.py ďalšie 3 príkazy na kreslenie obdĺžnikov, aby ste dostali nasledujúci obrázok:
Ako získame ďalšie farby?
Vlajke ktorého štátu sa obrázok podobá?