Live Coding # 1
Variables, Loops, and Functions
Vocabulary
Live Coding # 2
Codesters
100

a = 5

b = 3

sum = a + b

What is the value of sum?
8
100
This is the type of variable that stores words
What is a string?
100
This describes how we store data
What is a variable?
100
Write the code that would calculate the area of a triangle if the height is 'h' and the base is 'b'
(b * h) /2.0
100
This is the name for all the characters in Codesters
What is a sprite?
200

a = '5'

b = '3'

sum = a + b

What is the value of sum?
'53'
200

if "243" == 243:

return True

else:

return False

False
200
This lets us repeat code again and again and again ...
What is a loop?
200
Write the code that would ask the user for their name and return "Hi, NAME"?

name = sprite.ask("What is your name")

print "Hi, " + name

200
This is the function you use to get user input
What is ask()?
300

a = 10

while a < 100:

print "Hi!"

What will happen if I run this code?
You will get 'Hi!' forever!
300

if "GirlsWhoCode" == "girlswhocode":

return True

else:

return False

False
300
This is a block of code that you can call multiple times, putting in different inputs and getting out different outputs
What is a function?
300
Write code that will print 0 and then 1 and then 2 and then 3 and then 4.

for i in range(0,5):

print i

300
The name of the variable that you use if you want to represent 3.14159 ....
What is math.pi?
400

How do I get all the names to print?

names = ['GiGi', 'Caryn', 'Jamie']

names = ['GiGi', 'Caryn', 'Jamie']

for name in names:

print name

400
The two types of loops we learned
What is 'for' and 'while' loops?
400
This is a series of variables / values that is enclosed by square brackets
What is a list?
400
Write code that prints "Yay" if a variable is greater than 20 and "No!" otherwise

if x > 20:

print "Yay"

else:

print "No!"

400
This is the function that lets you run some code when two objects touch
What is event_collision()?
500
Write a function that takes in the radius of a circle and prints its area

def circle_area(radius):

area = 2 * radius ** 2 * math.pi

print area

500
The function that lets us run a loop for a defined number of times
What is range()?
500
This is when you test a statement using if / else
What is it a conditional?
500
Write a function that takes in three numbers and prints out their sum.

def sum(a, b, c):

val = a + b + c

print val

500
The name of the function that lets objects move around as if they are in space
What is set_gravity()?