### Silver Announcements Subscribe to posts

#### Lesson 7: Fibonacci sequence with for loop and list

posted Dec 5, 2019, 8:55 AM by Attila Lengyel

 a = 1b = 1c = a + bprint(a,b,c)a = bb = cc = a + bprint(c)a = bb = cc = a + bprint(c)print("I'm the while loop")x = 0while x < 10: a = b b = c c = a + b print(c) x = x + 1a = 1b = 1c = a + bprint("I'm the for loop")for x in range(0,10): a = b b = c c = a + b print(x, ":", c)print("I'm the list")f = [1,1,2]for x in range(0,11): f.append(f[len(f)-1] - 2 * f[len(f)-2])print(f)

#### Lesson 6: While loop and multiplications

posted Nov 21, 2019, 8:04 AM by Attila Lengyel

 a = 4b = 5print(a * b)a = int(input("Give me a:"))b = int(input("Give me b:"))print(a * b)import random as ra = r.randint(0, 10)b = r.randint(0, 10)print(a, "*", b, "=", a * b)a = r.randint(3,20)b = r.randint(3,20)task = "What is " + str(a) + " * " + str(b) + "? "answer = int(input(task))if answer == a * b: print("Good job!")else: print("Incorrect! It is", a * b)i = 0while i < 10: print(i) a = r.randint(12,30) b = r.randint(12,30) task = "What is " + str(a) + " * " + str(b) + "? " answer = int(input(task)) if answer == a * b: print("Good job!") else: print("Incorrect. It is ", a * b) i = i + 1

#### Lesson 5: The big IF

posted Nov 14, 2019, 7:58 AM by Attila Lengyel

 a = int(input("give me a number:"))if a < 10: print("a is smaller than 10")elif a == 10: print("a equals to 10")else: print("a is greater than 10")print("the task is done")print(10%2)print(9%2)if a % 2 == 0: print("a is an even number")else: print("a is an odd number")if a % 2 == 0 and a < 10: print("a is a even number smaller than 10 ")

#### Lesson 4: Lists

posted Nov 7, 2019, 7:54 AM by Attila Lengyel

 silver = ["Zubin", "Nadezda"]print(silver)silver.append("Sumukh")print(silver)print(silver)silver.append("Enna")silver.append("Anika")silver.append("Sarah")silver.append("Eesha")silver.append("Tanisha")silver.append("Claire")silver.append("Katie")silver.append("Sumedh")silver.append("Micah")silver.append("Alex")silver.append("Mihir")print(silver)print(len(silver))silver.sort()print(silver)silver.reverse()print(silver)import randomiplayer1 = random.randint(0, len(silver) - 1)player1 = silver[iplayer1]silver.remove(player1)iplayer2 = random.randint(0, len(silver) - 1)player2 = silver[iplayer2]silver.remove(player2)print(player1, "play against", player2)print(silver)

#### Lesson 3 - Halloween game

posted Oct 31, 2019, 10:47 AM by Attila Lengyel   [ updated Oct 31, 2019, 10:47 AM ]

 print("Halloweeeeeeen is here...tatata")print("Come in if you dare...print("Don't be scared...question = input("Tell me, why are you here?:")import randomanswer = random.randint(0,2)if question == "trick or treat": if answer == 0: print("Boooooooooooooooooooo") if answer == 0: print("Here is your candy!") if answer == 0: print("Get off my lawn!!!")if question == "to scare you": if answer == 0: print("Roaaaaaaaaarrrr....") if answer == 0: print("Here is your candy, don't scare me!") if answer == 0: print("The one who should be scared is you... ")

#### 2019-2020 - Lesson 1

posted Oct 17, 2019, 11:00 AM by Attila Lengyel

 import randomguess = random.randint(0,2)if guess == 0: print("Rock")if guess == 1: print("Paper")if guess == 2: print("Scissors")

#### Lesson 22: Draw THANK with turtle

posted Jun 7, 2019, 8:07 AM by Attila Lengyel

 import turtle as ttt = t.Turtle()def draw_t(bob,x,y): bob.penup() bob.goto(x,y) bob.pendown() bob.forward(50) bob.left(180) bob.forward(25) bob.left(90) bob.forward(60) bob.left(90)def draw_h(bob,x,y): bob.penup() bob.goto(x,y) bob.pendown() bob.right(90) bob.forward(60) bob.left(180) bob.forward(30) bob.right(90) bob.forward(30) bob.left(90) bob.forward(30) bob.left(180) bob.forward(60) bob.left(90)def draw_a(bob, x,y): bob.penup() bob.goto(x,y) bob.pendown() bob.goto(x + 15, y + 60) bob.goto(x + 30, y + 0) bob.penup() bob.goto(x,y + 30) bob.pendown() bob.goto(x + 30, y + 30)def draw_n(bob, x, y): bob.penup() bob.goto(x,y) bob.pendown() bob.left(90) bob.forward(60) bob.goto(x + 30, y) bob.forward(60) bob.right(90)def draw_k(bob, x, y): bob.penup() bob.goto(x,y) bob.pendown() bob.right(90) bob.forward(60) bob.right(180) bob.forward(25) bob.goto(x + 30 ,y) bob.goto(x,y -35) bob.goto(x + 30 ,y - 60) draw_t(tt, -200, 200)draw_h(tt, -140, 200)draw_a(tt, -100, 140)draw_n(tt, -60, 140)draw_k(tt, -20, 200)

#### Lesson 21: Turtle in corners

posted May 31, 2019, 8:00 AM by Attila Lengyel

 import turtleimport timeimport randomt = turtle.Turtle()def draw(x,y, delay, s): t.clear() t.penup() t.goto(x,y) t.pendown() t.speed(s) for x in range(0,3): t.forward(50) t.left(120) time.sleep(delay)time.sleep(2)draw(0,0,3, 5)for x in range(0,10): time.sleep(1) corner = random.randint(1,4) if corner == 1: draw(200,200,0,0) elif corner == 2: draw(-200, 200,0,0) elif corner == 3: draw(-200, -200,0,0) else: draw(200, -200,0,0) time.sleep(2) draw(0,0,3)

#### Lesson 20: Catch me if you can

posted May 10, 2019, 7:41 AM by Attila Lengyel   [ updated May 10, 2019, 8:04 AM ]

 import turtle as tplayer1 = t.Turtle()player1.shape("turtle")player1.pencolor("white")player1.fillcolor("blue")player2 = t.Turtle()player2.shape("turtle")player2.fillcolor("red")player2.pencolor("white")player2.goto(-180, 180)speed = 10angle = 10screen = t.Screen()def draw_rectangle(player, x, y, width, height, color): startpos = player.pos() startcolor = player.pencolor() player.pencolor(color) player.up() player.goto(x, y) player.down() player.forward(width) player.left(90) player.forward(height) player.left(90) player.forward(width) player.left(90) player.forward(height) player.left(90) player.up() player.goto(startpos) player.down() player.pencolor(startcolor)draw_rectangle(player1, -210, -210, 420, 420, "black")def position(player): if player.xcor() >= 200 : player.up() player.goto(199, player.ycor()) player.down() return False if player.xcor() <= -200: player.up() player.goto(-199, player.ycor()) player.down() return False if player.ycor() >= 200: player.up() player.goto(player.xcor(), 199) player.down() return False if player.ycor() <= -200: player.up() player.goto(player.xcor(), -199) player.down() return False return Trueimport mathdef catch(playera, playerb): x1 = playera.xcor() y1 = playera.ycor() x2 = playerb.xcor() y2 = playerb.ycor() c = math.pow(x1-x2,2) + math.pow(y2-y1,2) c = math.sqrt(c) if c < 10: playera.fillcolor("red") playerb.fillcolor("blue") def f(): if position(player1): player1.forward(speed)def b(): if position(player1): player1.backward(speed)def r(): player1.right(angle)def l(): player1.left(angle)screen.onkey(f, "Up")screen.onkey(b, "Down")screen.onkey(r, "Right")screen.onkey(l, "Left")def f2(): if position(player2): player2.forward(speed) catch(player1, player2)def b2(): if position(player2): player2.backward(speed) catch(player1, player2)def r2(): player2.right(angle)def l2(): player2.left(angle)screen.onkey(f2, "q")screen.onkey(b2, "a")screen.onkey(r2, "x")screen.onkey(l2, "z")screen.listen()

#### Lesson 18: Turtle in a box

posted May 3, 2019, 8:45 AM by Attila Lengyel   [ updated May 10, 2019, 7:28 AM ]

 import turtle as tplayer1 = t.Turtle()player1.shape("turtle")player1.pencolor("white")speed = 10angle = 10screen = t.Screen()def draw_rectangle(player, x, y, width, height, color): startpos = player.pos() startcolor = player.pencolor() player.pencolor(color) player.up() player.goto(x, y) player.down() player.forward(width) player.left(90) player.forward(height) player.left(90) player.forward(width) player.left(90) player.forward(height) player.left(90) player.up() player.goto(startpos) player.down() player.pencolor(startcolor)draw_rectangle(player1, -210, -210, 420, 420, "red")def position(player): if player.xcor() >= 200 : player.up() player.goto(199, player.ycor()) player.down()    return False if player.xcor() <= -200: player.up() player.goto(-199, player.ycor()) player.down()    return False if player.ycor() >= 200: player.up() player.goto(player.xcor(), 199) player.down()    return False if player.ycor() <= -200: player.up() player.goto(player.xcor(), -199) player.down()    return False return Truedef f(): if position(player1): player1.forward(speed)def b(): if position(player1): player1.backward(speed)def r(): player1.right(angle)def l(): player1.left(angle)screen.onkey(f, "Up")screen.onkey(b, "Down")screen.onkey(r, "Right")screen.onkey(l, "Left")screen.listen()

1-10 of 97