Variables and Numerical Operators
assignment statement
A statement that assigns a value to a variable
what is camel case?
A way to keep a long variable name readable; making each new word start with a capital letter: playerLastName, totalCost, totalRevenue, playerBestScore, playerLivesLeft, etc.
what happens when you enter 4(2+3) after the prompt?
An error. Python does not do implied multiplication. You cannot place a number beside a parentheses to imply multiplication.
the first character of a variable name cannot be a _____
Digit
what are the python keywords?
False, await, else, import, pass, None, break, except, in, raise, True, class, finally, is, return, and, continue, for, lambda, try, as, def, from, nonlocal, while, assert, del, global, not, with, async, elif, if, or, yield
variable
Identifier used to store a value
Assume you previously entered these lines of code. >>> a = 3 >>> b = 2 >>> c = 0 Which lines of code below generate errors? Select 2 options. 1. result = a * b - b / c 2. result = a * b - c / b 3. result = ab + bc 4. result = a * b - b / (c + b) 5. result = a * b - c / (a + c)
Lines 1 and 3 will generate errors. Line 1 results in a ZeroDivision Error: result = a * b - b / c. Line 2 results in an error because there is no implied multiplication. result = ab + bc ...should be... a * b + b * c
Which of the following are valid variable names? Select 3 options. 1. num1 2. player@ 3. playerScore 4. player_score 5. 2nd_num
Options 1, 3, and 4 are valid variable names. This is because variable names can contain letters, digits, and an underscore. They cannot start with a number as in 2nd_num. They cannot contain other characters as in player@.
which order of operations does python follow?
PEMDAS
what happens when you divide a number by zero?
Python will give a division by 0 error.
How can you switch the value held in two variables?
You can switch the value held in two variables by creating a third variable to hold the value of one of them.
variable names =/ ________, but variables= _________
keywords; uppercase and lowercase letters, digits, and underscores
In python, what format is the variable and data value written?
variable = data value