Which of the following are syntactically correct strings?
"This course is great!"
To display a value in the console, what Python keyword do you use?
In the following code, there is one line starting with
#. What does this line mean to Python?
tax_rate = 0.15 income = 40000 deduction = 10000 # Calculate income taxes tax = (income - deduction) * tax_rate print(tax)
[ ] This text is used as a file name for the code.
[ ] This text is printed on the console.
[ ] This is a syntax error.
[x] This is a comment aimed at the human reader. Python ignores such comments.
Which of the following arithmetic expressions are syntactically correct?
(7 - 2) / (3 ** 2)
5 * 3 (7 - 2)
(8 + (1 + (2 * 4) - 3))
5 - 1 - 3 - 7 - 0
3 * ((2 - 9) + 4)) * (2 + (1 - 3))
You would like to make it so that the variable
ounces has the value 16, thus representing one pound. What simple Python statement will accomplish this?
16 = ounces
ounces == 16
ounces = 16
ounces := 16
A gram is equal to 0.035274 ounces. Assume that the variable
mass_in_ounces has a value representing a given mass in ounces. Which Python statement below uses the variable
mass_in_ounces to compute an equivalent mass
mass_in_grams expressed in grams?
Think about it mathematically, but also test these expressions in CodeSkulptor3. If you are still confused, you might check out this student tutorial video by Kelly on unit conversions.
mass_in_grams = mass_in_ounces * 0.035274
mass_in_grams = 0.035274 / mass_in_ounces
mass_in_grams = mass_in_ounces / 0.035274
mass_in_ounces = 0.035274 * mass_in_grams
Which of the following can be used as a variable name?
Try using each in Python.
Assume you have values in the variables
y. Which statement(s) would result in
x having the sum of the current values of
Test your answer in Python.
[ ] y += x
[ ] y += x+y
[x] x = y + x
[ ] x = x + y
Python file names traditionally end in what characters after a period? Don’t include the period.
We encourage you to save your CodeSkulptor Python files where?
[x] In “the cloud” and on your computer
[ ] In “the cloud” only
[ ] Nowhere — CodeSkulptor automatically saves your files for you
[ ] On your computer only
It is a good practice to save your files locally, as Codeskulptor may delete your files after some time.