Variable Names
Variable Names 2
Compound Assignment Operators
Variable Names 3
General Variable Knowledge
100

is this a valid variable name? 104tree

No, it starts with a number

100

Would this work as a variable name? global = "global"

No, because global is a keyword in python.

100

What is the output? var = 300

var += 500

print(var)

800

100

What do you use to assign a value to a variable name?

An equal sign (=)

100

What are these called? elif, False, and, class, continue

Reserved keywords in Python

200

is this a valid variable name? var1

YES

200

Would this be a valid variable days_to_christmas_break = 245234134234

Yes, underscores to separate words are allowed.

200

What's the output? a = 20, b = 30

a-= a + b

b *= a

print (a * b + a)

27030

200

Is this valid? myvariable = 3.0

Yes, but you should camelcase

200

What are the two components to a variable?

A name and a value

300

Are these legal variable names? Einbahnstraße, переменная 


yes, other characters can be used. Latin letters and characters specific to languages that use other alphabets are legal.

300

Would this work as a variable? _ = "pizza"

Yes, although it's unconventional, it would in fact be valid.

300
What's the output? x = 5

y = 10

x*= y + 5

print(y + x % 2)

11

300

What's the output?

var = "20"

print("This is text" + var)

This is text 20

300

What's the output? var = 1

var = var + var

var = 100

var = 100 + var

print (var)

200

400

Is this a valid variable name? for

No, for is a keyword in python.

400

Is this a valid variable name? myVar = 10

Yes

400

What's the output? var2  = 10

var2 /= 5

print(var1)

error, var1 isn't declared in the program

400
Is this a valid variable name? var_22 = "for"

Yes, because although for is a keyword, in this case it is a string so it's okay.

400

What are these called?

+=, *=, -=, %=, **=

Compound Assignment Operators

500

Would this work? variable name1

No, there's a space.

500

Is this a valid variable name? Import = "import"

Yes, variable names are case-sensitive. Therefore, Import is valid, while import isn't.

500

What's the output? var1 = 20

var1 %= 8 + 5

print(var1)

9

500

Is this valid? false = "false" + "false"

print(false)

Yep

500

What is the error thrown in the console when you type in this?

var name spaces = 124123

Syntax Error

M
e
n
u