Silver Announcements


Lesson 11: Python Turtle

posted Jan 16, 2020, 9:05 AM by Attila Lengyel

import turtle

bob = turtle.Turtle()
bob.forward(80)

bob.left(90)
bob.forward(80)

bob.left(90)
bob.forward(80)

bob.left(90)
bob.forward(80)

bob.clear()

bob.shape("turtle")
bob.pencolor("red")

for i in range(4):
bob.left(90)
bob.forward(80)
bob.clear()

bob.left(90)

for i in range(5):
bob.fd(80)
bob.right(144)

bob.clear()

sides = int(input("How many sides?:"))
side_length = int(input("Length?:"))

for i in range(sides):
bob.forward(side_length)
bob.right(360/sides)

Lesson 10: First 100 prime numbers

posted Jan 9, 2020, 8:00 AM by Attila Lengyel

print(10%3)
print(15%6)

n = int(input("Give me a number:"))

isprime = True
for i in range(2,n):
if n%i == 0:
isprime = False
break

if isprime:
print(n, "is a prime number")
else:
print(n, "is not a prime number")

def spoungebob(n):
isprime = True
for i in range(2,n):
if n%i == 0:
isprime = False
break
return isprime

if spoungebob(n):
print("Spounge Bob says", n, "is a prime number")
else:
print("Spounge Bob says", n, "is not a prime number")

counter = 0
n = 0
while counter <= 1000:
n = n + 1
if spoungebob(n):
print(counter, n)
counter = counter + 1





Lesson 9: Binary search

posted Dec 19, 2019, 8:02 AM by Attila Lengyel

target = int(input("Think of a number:"))
lower = 1
upper = 100

while target < 1 or target > 100:
print("Please think between 1 and 99!")
target = int(input("Try again:"))

guess = 0

import math
while guess != target:
guess = lower + math.floor((upper - lower)/2)
print("Is the number", guess, "? (yes/lower/higher):")
answer = input()
if answer == "yes":
print("I knew it!!!")
elif answer == "lower":
upper = guess - 1
elif answer == "higher":
lower = guess + 1

Lesson 8: Rolling the dice

posted Dec 12, 2019, 7:59 AM by Attila Lengyel

import random as r

print("Let's roll the dice!")
roll = r.randint(1,6)
print("I rolled ", roll)

rolls = [0,0,0,0,0,0]

for x in range(0, 100):
roll = r.randint(1,6)
rolls[roll-1] = rolls[roll-1] + 1

print(rolls)

rolls2 = [0,0,0,0,0,0,0,0,0,0,0,0]

for x in range(0,1000000):
roll1 = r.randint(1,6)
roll2 = r.randint(1,6)
num = roll1 + roll2
rolls2[num-1] = rolls2[num-1] + 1

for x in range(0,12):
print(x + 1, ":", rolls2[x])



Lesson 7: Fibonacci sequence with for loop and list

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

a = 1
b = 1
c = a + b
print(a,b,c)

a = b
b = c
c = a + b
print(c)

a = b
b = c
c = a + b
print(c)

print("I'm the while loop")
x = 0
while x < 10:
a = b
b = c
c = a + b
print(c)
x = x + 1

a = 1
b = 1
c = a + b
print("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 = 4
b = 5
print(a * b)

a = int(input("Give me a:"))
b = int(input("Give me b:"))
print(a * b)

import random as r
a = 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 = 0
while 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[1])

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 random
iplayer1 = 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 random
answer = 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 random

guess = random.randint(0,2)

if guess == 0:
print("Rock")
if guess == 1:
print("Paper")
if guess == 2:
print("Scissors")

1-10 of 101