### Bronze Announcements

#### Lesson 18: Events handling with Turtle

import turtle screen = turtle.Screen() turtle.shape("turtle") turtle.fillcolor("blue") turtle.pencolor("blue") speed = 10 turn = 10 def f(): turtle.forward(speed) turtle.fillcolor("red") turtle.pencolor("red") def b(): turtle.backward(speed) turtle.fillcolor("blue") turtle.pencolor("blue") def l(): turtle.left(turn) def r(): turtle.right(turn) def c(): turtle.clear() turtle.speed(0) screen.onkey(f, "Up") screen.onkey(b, "Down") screen.onkey(l, "Left") screen.onkey(r, "Right") screen.onkey(c, "c") screen.listen() |

#### Lesson 17: Drawing with Turtle

import turtle ted = turtle.Turtle() for i in range(0,4): ted.forward(50) ted.left(90) ted.write("Turn left") ted.penup() ted.setposition(-100,-100) ted.pendown() for i in range(0,5): ted.forward(50) ted.right(144) ted.clear() ted.pencolor("blue") ted.circle(100) ted.clear() ted.penup() ted.setposition(0,0) ted.pendown() num_sides = 5 side_length = 10 angle = 360 / num_sides for i in range(0,num_sides): ted.forward(side_length) ted.right(angle) |

#### Lesson 16: What is a palindrome?

word = input("Give me a sentence:") tmp = "" for i in word: if i.isalnum(): tmp = tmp + i.lower() word = tmp s = "" for i in word: s = i + s print(s) print(word) if s == word: print("This is a palindrome") else: print("This is not a palindrome") |

#### Lesson 15: Hangman v1

word = input("Give me the hidden word:") correctletters = "" incorrectletters = "" def drawhangman(word, correctletters, incorrectletters): output = "" for c in word: if c in correctletters: output += c + " " else: output += "_ " print(output) #drawhangman("rule", "eul", "") #drawhangman("rule", "ul", "") #drawhangman("rule", "l", "") #drawhangman("rule", "", "") #drawhangman("rule", "erul", "") while len(word) != len(correctletters) and len(incorrectletters) < 8: guess = input("Guess a letter:") if guess in word and guess not in correctletters: correctletters += guess elif guess not in incorrectletters: incorrectletters += guess drawhangman(word, correctletters, incorrectletters) |

#### Lesson 14: Binary search... for guessing

print("Think of a number between 0 and 100!") answer = "" upper = 100 lower = 0 import math as m while answer != "correct": guess = m.floor((upper - lower)/2 + lower) print("Did you guess", guess, "?") answer = input() if answer == "correct": print("You thought of", guess,".") elif answer == "low": lower = guess elif answer == "high": upper = guess |

#### Lesson 13: Guess game

import random as r a = r.randint(0,100) print("I thought of a number between 0 and 100.") print("Guess the number!") counter = 0 correct = False while(correct == False): guess = int(input(":")) counter = counter + 1 if guess == a: correct = True elif guess < a: print("It is too low") else: print("It is too high") if correct: print("Good guess. The nunber is:", a) print("You tried", counter, "times") |

#### Lesson 12: Rolling dice

import random #print(random.randint(1,6)) result = [] for i in range(0, 10000): a = random.randint(1,6) result.append(a) #print(result) print("Rolling one dice:") for i in range (1,7): a = result.count(i) print(i, a) result2 = [] for i in range(0, 1000000): a = random.randint(1,6) b = random.randint(1,6) result2.append(a + b) print("Rolling two dice:") for i in range(2,13): a = result2.count(i) print(i, a) |

#### Lesson 11: Lists - Raffle

names = ["Tanisha", "Sahana", "Nadezda","Claire", "Zubin", "Cayne", "Boston","Ameya", "Aryan"] print(names) num = len(names) print(num) import random winner = random.randint(0,num - 1) print(winner) print(names[winner]) print(sorted(names)) print(sorted(names, reverse = True)) |

#### Lesson 10: "Repetition makes the master": Fibonacci series with role play

a = 0 #a gets value of 0 b = 1 #b get value of 1 c = a + b #c gets value of a plus b print(a) #a displayed a = b # a gets value of b b = c # b gets value of c c = a + b #c gets value of a plus b print(a) a = b b = c c = a + b print(a) for i in range(0,10000): a = b b = c c = a + b print(a) |

#### Lesson 9: Fibonacci series & 4 corners game

a = 0 b = 1 print(a) print(b) for i in range(0,5): c = a + b print(c) a = b b = c import random import time for i in range(0,10): time.sleep(8) print("Corner", random.randint(1,4), "is out!") print("Run to an other corner!!!") |

1-10 of 42