is this a valid variable name? 104tree
No, it starts with a number
Would this work as a variable name? global = "global"
No, because global is a keyword in python.
What is the output? var = 300
var += 500
print(var)
800
What do you use to assign a value to a variable name?
An equal sign (=)
What are these called? elif, False, and, class, continue
Reserved keywords in Python
is this a valid variable name? var1
YES
Would this be a valid variable days_to_christmas_break = 245234134234
Yes, underscores to separate words are allowed.
What's the output? a = 20, b = 30
a-= a + b
b *= a
print (a * b + a)
27030
Is this valid? myvariable = 3.0
Yes, but you should camelcase
What are the two components to a variable?
A name and a value
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.
Would this work as a variable? _ = "pizza"
Yes, although it's unconventional, it would in fact be valid.
y = 10
x*= y + 5
print(y + x % 2)
11
What's the output?
var = "20"
print("This is text" + var)
This is text 20
What's the output? var = 1
var = var + var
var = 100
var = 100 + var
print (var)
200
Is this a valid variable name? for
No, for is a keyword in python.
Is this a valid variable name? myVar = 10
Yes
What's the output? var2 = 10
var2 /= 5
print(var1)
error, var1 isn't declared in the program
Yes, because although for is a keyword, in this case it is a string so it's okay.
What are these called?
+=, *=, -=, %=, **=
Compound Assignment Operators
Would this work? variable name1
No, there's a space.
Is this a valid variable name? Import = "import"
Yes, variable names are case-sensitive. Therefore, Import is valid, while import isn't.
What's the output? var1 = 20
var1 %= 8 + 5
print(var1)
9
Is this valid? false = "false" + "false"
print(false)
Yep
What is the error thrown in the console when you type in this?
var name spaces = 124123
Syntax Error