Quiz: Intro to Python
Main.PythonQuiz7 History
Hide minor edits - Show changes to markup
5. Which of the following are valid functions in Python?
6. Which of the following are valid functions in Python?
- (:toggle hide q5a button show="Select":)
(:div id=q5a:)
- (:toggle hide q6a button show="Select":)
(:div id=q6a:)
- (:toggle hide q5b button show="Select":)
(:div id=q5b:)
- (:toggle hide q6b button show="Select":)
(:div id=q6b:)
- (:toggle hide q5c button show="Select":)
(:div id=q5c:)
- (:toggle hide q6c button show="Select":)
(:div id=q6c:)
- (:toggle hide q5d button show="Select":)
(:div id=q5d:)
- (:toggle hide q6d button show="Select":)
(:div id=q6d:)
- (:toggle hide q5e button show="Select":)
(:div id=q5e:)
- (:toggle hide q6e button show="Select":)
(:div id=q6e:)
5. Which of the following are valid functions in Python?
(:source lang=python:)
- A
def square_me(x)
return x^2
- B
def square_me(x)
return x**2
- C
function square_me(x)
return x**2
- D
function square_me(x) :
return x^2
- E
def square_me(x) :
return x**2
(:sourceend:)
(:div id=q5a:)
- Incorrect. There are 2 problems: no ":" and x^2 should be x**2
(:divend:)
(:div id=q5b:)
- Incorrect. No, there needs to be a ":" at the end of the first line
(:divend:)
(:div id=q5c:)
- Incorrect. The keyword is "def" not "function", and we need a ":"
(:divend:)
(:div id=q5d:)
- Incorrect. The keyword is "def" not "function"
(:divend:)
(:div id=q5e:)
- Correct.
(:divend:)
- Correct.
- Correct. Ignore the lines with the comment character.
- Incorrect.
- Incorrect. Ignore the lines with the comment character
- Incorrect.
- Incorrect. Ignore the lines with the comment character
- Incorrect.
- Incorrect. Ignore the lines with the comment character
- Correct. This formula would work but takes longer than a simpler one.
- Correct. This formula would work but takes longer to write than a simpler one.
- Correct. '!' Has a purpose in python so it can't be used in a variable name.
- Incorrect. '!' Has a purpose in python so it can't be used in a variable name.
- (:toggle hide q1a button show="Select":)
(:div id=q1a:)
- (:toggle hide q2a button show="Select":)
(:div id=q2a:)
- (:toggle hide q1b button show="Select":)
(:div id=q1b:)
- (:toggle hide q2b button show="Select":)
(:div id=q2b:)
- (:toggle hide q1c button show="Select":)
(:div id=q1c:)
- (:toggle hide q2c button show="Select":)
(:div id=q2c:)
- (:toggle hide q1a button show="Select":)
(:div id=q1a:)
- (:toggle hide q3a button show="Select":)
(:div id=q3a:)
- (:toggle hide q1b button show="Select":)
(:div id=q1b:)
- (:toggle hide q3b button show="Select":)
(:div id=q3b:)
- (:toggle hide q1c button show="Select":)
(:div id=q1c:)
- (:toggle hide q3c button show="Select":)
(:div id=q3c:)
- (:toggle hide q1d button show="Select":)
(:div id=q1d:)
- (:toggle hide q3d button show="Select":)
(:div id=q3d:)
- (:toggle hide q1e button show="Select":)
(:div id=q1e:)
- (:toggle hide q3e button show="Select":)
(:div id=q3e:)
- (:toggle hide q1a button show="Select":)
(:div id=q1a:)
- (:toggle hide q4a button show="Select":)
(:div id=q4a:)
- (:toggle hide q1b button show="Select":)
(:div id=q1b:)
- (:toggle hide q4b button show="Select":)
(:div id=q4b:)
- (:toggle hide q1c button show="Select":)
(:div id=q1c:)
- (:toggle hide q4c button show="Select":)
(:div id=q4c:)
- (:toggle hide q1a button show="Select":)
(:div id=q1a:)
- (:toggle hide q5a button show="Select":)
(:div id=q5a:)
- (:toggle hide q1b button show="Select":)
(:div id=q1b:)
- (:toggle hide q5b button show="Select":)
(:div id=q5b:)
- (:toggle hide q1c button show="Select":)
(:div id=q1c:)
- (:toggle hide q5c button show="Select":)
(:div id=q5c:)
- (:toggle hide q1d button show="Select":)
(:div id=q1d:)
- (:toggle hide q5d button show="Select":)
(:div id=q5d:)
(:divend:)
(:divend:)
- (:toggle hide q1a button show="Select":)
(:div id=q1a:)
- (:toggle hide q1d button show="Select":)
(:div id=q1d:)
- (:toggle hide q1b button show="Select":)
(:div id=q1b:)
- (:toggle hide q1e button show="Select":)
(:div id=q1e:)
- (:toggle hide q1c button show="Select":)
(:div id=q1c:)
- (:toggle hide q1f button show="Select":)
(:div id=q1f:)
- (:toggle hide q1a button show="Select":)
(:div id=q1a:)
- (:toggle hide q1d button show="Select":)
(:div id=q1d:)
- (:toggle hide q1b button show="Select":)
(:div id=q1b:)
- (:toggle hide q1e button show="Select":)
(:div id=q1e:)
- (:toggle hide q1c button show="Select":)
(:div id=q1c:)
- (:toggle hide q1d button show="Select":)
(:div id=q1d:)
(:title Quiz: Intro to Python:) (:keywords quiz, test, Python, variable, expression, introduction, course:) (:description Learning assessment on Introduction to Python with variables and expressions.:)
1. Which of the following is a correct way to name a variable and set its value to 5 in python? There may be more than one correct answer.
(:div id=q1a:)
- Correct. This is an acceptable variable name.
(:divend:)
(:div id=q1b:)
- Incorrect. Variable names cannot contain spaces.
(:divend:)
(:div id=q1c:)
- Correct. This is an acceptable variable name.
(:divend:)
(:div id=q1a:)
- Incorrect. The variable name should be on the left with the assigned value on the right.
(:divend:)
(:div id=q1b:)
- Incorrect. ':' Has a purpose in python so it can't be used in a variable name.
(:divend:)
(:div id=q1c:)
- Correct. '!' Has a purpose in python so it can't be used in a variable name.
(:divend:)
2. What is wrong with this 'if' statement that will keep it from working?
(:source lang=python:) if y > 3 print(x) (:sourceend:)
(:div id=q1a:)
- Incorrect. It is actually the correct symbol for 'greater than'.
(:divend:)
(:div id=q1b:)
- Correct. There is a missing indentation and colon.
(:divend:)
(:div id=q1c:)
- Incorrect. They are in the correct order as shown
(:divend:)
3. Which is the simplest correct way to program the following equation in python?
$$y = 5x^4 + 2x^3 + 14x^2 + 3x + 7$$
(:div id=q1a:)
- Incorrect. You will need to use the multiplication symbol in python as well as a symbol that will make an exponent.
(:divend:)
(:div id=q1b:)
- Incorrect. You will need to use a multiplication symbol and the correct symbol for creating an exponent.
(:divend:)
(:div id=q1c:)
- Incorrect. The correct symbol for making an exponent is **, not ^.
(:divend:)
(:div id=q1a:)
- Correct. The variable name should be on the left with the assigned value on the right.
(:divend:)
(:div id=q1b:)
- Correct. This formula would work but takes longer than a simpler one.
(:divend:)
4. What is the final value of z?
(:source lang=python:) x = 3.897 y = 4.125 w = 8.796 z = x**2 + 3*y**3 + 2*w z = z/z (:sourceend:)
(:div id=q1a:)
- Incorrect.
(:divend:)
(:div id=q1b:)
- Correct.
(:divend:)
(:div id=q1c:)
- Incorrect.
(:divend:)
5. What is the final value of x?
(:source lang=python:) y = 2 x = 3
- x = 4
z = 55
- y = 3
x = z + x + y (:sourceend:)
(:div id=q1a:)
- Correct.
(:divend:)
(:div id=q1b:)
- Incorrect.
(:divend:)
(:div id=q1c:)
- Incorrect.
(:divend:)
(:div id=q1c:)
- Incorrect.
(:divend:)