Skip to content

Instantly share code, notes, and snippets.

@tlasica
Last active June 16, 2020 10:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tlasica/4c5cc69eb72cad5ad41af79c5639b8b2 to your computer and use it in GitHub Desktop.
Save tlasica/4c5cc69eb72cad5ad41af79c5639b8b2 to your computer and use it in GitHub Desktop.
def wypisz_sume(a, b, c):
suma = a + b + c
print("suma liczb", a, "+", b, "+", c, "wynosi", suma)
wypisz_sume(5, 6, 7)
wypisz_sume(1, 7, 9)
def policz_sume(liczby):
print("dodajemy liczby:", liczby)
wynik = 0
for x in liczby:
print("aktualny wynik to", wynik)
print("dodaje", x)
wynik = wynik + x
print("teraz wynik to", wynik)
print()
print("suma to", wynik)
return wynik
# policz_sume(list(range(11)))
s = policz_sume([1,3,5]) + policz_sume([7,8,9])
print("ostatecxny wuyn", s)
print(policz_sume([1, 2, policz_sume([8,9,10,11])]))
100 + policz_sume([10,20,30,40])
import turtle
import random
t = turtle.Pen()
t.speed(20)
# narysujemy czarno biala szachownice
# plan:
# 1. rysujemy kwadrat
# 2. rysujemy linie 8 kwadratow
# 3. kolorujemy na zmiane bialy / czarny
# 4. rysujemy 8 linii kwadratow
def kwadrat(pbok, pkolor):
# rysujemy kwadrat o boku bok
t.fillcolor(pkolor)
t.begin_fill()
for i in range(4):
t.forward(pbok)
t.left(90)
t.end_fill()
# kwadrat(100, 'yellow')
# kwadrat(90, 'orange')
# kwadrat(80, 'red')
def linia_kwadratow(bok_kwadratu, kolor_pierwszego_kwadratu):
kolor = kolor_pierwszego_kwadratu
for n in range(8):
kwadrat(bok_kwadratu, kolor)
# przesun o bok
t.forward(bok_kwadratu)
# zmien kolor
if kolor == "black":
kolor = "white"
else:
kolor = "black"
bok = 40
kolor = "black"
for linia in range(8):
if linia % 2 == 0:
kolor = "white"
else:
kolor = "black"
print(linia, kolor)
# rysowanie linii kwadratow
linia_kwadratow(bok, kolor)
# cofam sie do poczatku
t.backward(8 * bok)
t.left(90)
t.forward(bok)
t.right(90)
turtle.done()
# HOMEWORK
# napisz program, ktory przy pomocy funkcji wielokat() z jakimis parametrami
# narysuje szesciokat o boku 100
# przesunie sie w prawo o 200
# narysuje osmiokat o boku 80
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment