complete solutions) 12
If I wanted to take a number, say 5, and assign it to a Variable, let's say the letter y, how would I code
that? - correct answer ✔✔y = 5
How would I print out the variable y? - correct answer ✔✔print(y)
A best practice is to assign variable names that have some sort of meaning - correct answer ✔✔True
What would the following code print?
print('don't skip the coffee') - correct answer ✔✔SyntaxError: invalid syntax
Python understands order of operations but you need to be careful to use python operators.
For example,
(3+4)2 does not work.
(3+4)*2 does work.
What are some of the operators we covered? - correct answer ✔✔+ is addition
* is multiplication
/ is division
% is modulus
The following 4 questions all have a snippet of code, and a comment. The comment following the code in
the questions below makes a statement. Which of these statements is correct? - correct answer ✔✔The
following is a correct comment:
, 1 + 1 # evaluates to 2
The following is not a correct comment:
1 + 1 # evaluates to 3
True + 100 #evaluates to 101 - correct answer ✔✔Correct
1 + 1(7) # evaluates to 8 - correct answer ✔✔False
print_twice('Hello") #evaluates to 'Hello Hello" - correct answer ✔✔Incorrect
The below code is what you see when you open a notebook.
if x < 0:
print('x is negative')
What prints when that notebook cell is run? - correct answer ✔✔an error
The below code is what you see when you open a notebook.
'what subset?' [1:2]
What prints when that notebook cell is run? - correct answer ✔✔h
Complete the following if statement so that when you run it prints "x is even"
x = 10