Quiz: Intro to Python

Main.PythonQuiz7 History

Show minor edits - Show changes to output

May 17, 2022, at 01:59 AM by 136.36.4.38 -
May 17, 2022, at 01:57 AM by 136.36.4.38 -
Changed lines 199-200 from:
'''5.''' Which of the following are valid functions in Python?
to:
'''6.''' Which of the following are valid functions in Python?
Changed lines 225-226 from:
-->(:toggle hide q5a button show="Select":)
(:div id=q5a:)
to:
-->(:toggle hide q6a button show="Select":)
(:div id=q6a:)
Changed lines 232-233 from:
-->(:toggle hide q5b button show="Select":)
(:div id=q5b:)
to:
-->(:toggle hide q6b button show="Select":)
(:div id=q6b:)
Changed lines 239-240 from:
-->(:toggle hide q5c button show="Select":)
(:div id=q5c:)
to:
-->(:toggle hide q6c button show="Select":)
(:div id=q6c:)
Changed lines 246-247 from:
-->(:toggle hide q5d button show="Select":)
(:div id=q5d:)
to:
-->(:toggle hide q6d button show="Select":)
(:div id=q6d:)
Changed lines 253-254 from:
-->(:toggle hide q5e button show="Select":)
(:div id=q5e:)
to:
-->(:toggle hide q6e button show="Select":)
(:div id=q6e:)
May 17, 2022, at 01:56 AM by 136.36.4.38 -
Added lines 196-258:

----

'''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:)

->'''A.'''

-->(:toggle hide q5a button show="Select":)
(:div id=q5a:)
-->%red%Incorrect.%% There are 2 problems: no ":" and x^2 should be x**2
(:divend:)

->'''B.'''

-->(:toggle hide q5b button show="Select":)
(:div id=q5b:)
-->%red%Incorrect.%% No, there needs to be a ":" at the end of the first line
(:divend:)

->'''C.'''

-->(:toggle hide q5c button show="Select":)
(:div id=q5c:)
-->%red%Incorrect.%% The keyword is "def" not "function", and we need a ":"
(:divend:)

->'''D.'''

-->(:toggle hide q5d button show="Select":)
(:div id=q5d:)
-->%red%Incorrect.%% The keyword is "def" not "function"
(:divend:)

->'''E.'''

-->(:toggle hide q5e button show="Select":)
(:div id=q5e:)
-->%blue%Correct.%%
(:divend:)

----
June 23, 2021, at 08:17 PM by 145.34.0.194 -
Changed line 173 from:
-->%blue%Correct.%%
to:
-->%blue%Correct.%% Ignore the lines with the comment character.
Changed lines 176-177 from:
->'''B.''' 61
to:
->'''B.''' 61 
Changed line 180 from:
-->%red%Incorrect.%%
to:
-->%red%Incorrect.%% Ignore the lines with the comment character
Changed line 187 from:
-->%red%Incorrect.%%
to:
-->%red%Incorrect.%% Ignore the lines with the comment character
Changed line 194 from:
-->%red%Incorrect.%%
to:
-->%red%Incorrect.%% Ignore the lines with the comment character
June 23, 2021, at 08:14 PM by 145.34.0.194 -
Changed line 120 from:
-->%blue%Correct.%% This formula would work but takes longer than a simpler one.
to:
-->%blue%Correct.%% This formula would work but takes longer to write than a simpler one.
June 23, 2021, at 08:13 PM by 145.34.0.194 -
Changed line 48 from:
-->%blue%Correct.%% '!' Has a purpose in python so it can't be used in a variable name.
to:
-->%red%Incorrect.%% '!' Has a purpose in python so it can't be used in a variable name.
May 20, 2021, at 05:15 PM by 10.37.30.151 -
Changed line 58 from:
print(x)
to:
   print(x)
May 20, 2021, at 05:13 PM by 10.37.30.151 -
Changed lines 63-64 from:
-->(:toggle hide q1a button show="Select":)
(:div id=q1a:)
to:
-->(:toggle hide q2a button show="Select":)
(:div id=q2a:)
Changed lines 70-71 from:
-->(:toggle hide q1b button show="Select":)
(:div id=q1b:)
to:
-->(:toggle hide q2b button show="Select":)
(:div id=q2b:)
Changed lines 77-78 from:
-->(:toggle hide q1c button show="Select":)
(:div id=q1c:)
to:
-->(:toggle hide q2c button show="Select":)
(:div id=q2c:)
Changed lines 90-91 from:
-->(:toggle hide q1a button show="Select":)
(:div id=q1a:)
to:
-->(:toggle hide q3a button show="Select":)
(:div id=q3a:)
Changed lines 97-98 from:
-->(:toggle hide q1b button show="Select":)
(:div id=q1b:)
to:
-->(:toggle hide q3b button show="Select":)
(:div id=q3b:)
Changed lines 104-105 from:
-->(:toggle hide q1c button show="Select":)
(:div id=q1c:)
to:
-->(:toggle hide q3c button show="Select":)
(:div id=q3c:)
Changed lines 111-112 from:
-->(:toggle hide q1d button show="Select":)
(:div id=q1d:)
to:
-->(:toggle hide q3d button show="Select":)
(:div id=q3d:)
Changed lines 118-119 from:
-->(:toggle hide q1e button show="Select":)
(:div id=q1e:)
to:
-->(:toggle hide q3e button show="Select":)
(:div id=q3e:)
Changed lines 137-138 from:
-->(:toggle hide q1a button show="Select":)
(:div id=q1a:)
to:
-->(:toggle hide q4a button show="Select":)
(:div id=q4a:)
Changed lines 144-145 from:
-->(:toggle hide q1b button show="Select":)
(:div id=q1b:)
to:
-->(:toggle hide q4b button show="Select":)
(:div id=q4b:)
Changed lines 151-152 from:
-->(:toggle hide q1c button show="Select":)
(:div id=q1c:)
to:
-->(:toggle hide q4c button show="Select":)
(:div id=q4c:)
Changed lines 171-172 from:
-->(:toggle hide q1a button show="Select":)
(:div id=q1a:)
to:
-->(:toggle hide q5a button show="Select":)
(:div id=q5a:)
Changed lines 178-179 from:
-->(:toggle hide q1b button show="Select":)
(:div id=q1b:)
to:
-->(:toggle hide q5b button show="Select":)
(:div id=q5b:)
Changed lines 185-186 from:
-->(:toggle hide q1c button show="Select":)
(:div id=q1c:)
to:
-->(:toggle hide q5c button show="Select":)
(:div id=q5c:)
Changed lines 192-193 from:
-->(:toggle hide q1d button show="Select":)
(:div id=q1d:)
to:
-->(:toggle hide q5d button show="Select":)
(:div id=q5d:)
Changed line 195 from:
(:divend:)
to:
(:divend:)
May 20, 2021, at 04:06 PM by 10.37.30.151 -
Changed lines 32-33 from:
-->(:toggle hide q1a button show="Select":)
(:div id=q1a:)
to:
-->(:toggle hide q1d button show="Select":)
(:div id=q1d:)
Changed lines 39-40 from:
-->(:toggle hide q1b button show="Select":)
(:div id=q1b:)
to:
-->(:toggle hide q1e button show="Select":)
(:div id=q1e:)
Changed lines 46-47 from:
-->(:toggle hide q1c button show="Select":)
(:div id=q1c:)
to:
-->(:toggle hide q1f button show="Select":)
(:div id=q1f:)
Changed lines 111-112 from:
-->(:toggle hide q1a button show="Select":)
(:div id=q1a:)
to:
-->(:toggle hide q1d button show="Select":)
(:div id=q1d:)
Changed lines 118-119 from:
-->(:toggle hide q1b button show="Select":)
(:div id=q1b:)
to:
-->(:toggle hide q1e button show="Select":)
(:div id=q1e:)
Changed lines 192-193 from:
-->(:toggle hide q1c button show="Select":)
(:div id=q1c:)
to:
-->(:toggle hide q1d button show="Select":)
(:div id=q1d:)
May 20, 2021, at 04:05 PM by 10.37.30.151 -
Added lines 1-195:
(: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.

->'''A.''' my_var = 5

-->(:toggle hide q1a button show="Select":)
(:div id=q1a:)
-->%blue%Correct.%%  This is an acceptable variable name.
(:divend:)

->'''B.''' my var = 5

-->(:toggle hide q1b button show="Select":)
(:div id=q1b:)
-->%red%Incorrect.%%  Variable names cannot contain spaces.
(:divend:)

->'''C.''' myvar = 5

-->(:toggle hide q1c button show="Select":)
(:div id=q1c:)
-->%blue%Correct.%%  This is an acceptable variable name.
(:divend:)

->'''D.''' 5 = my_var

-->(:toggle hide q1a button show="Select":)
(:div id=q1a:)
-->%red%Incorrect.%%  The variable name should be on the left with the assigned value on the right.
(:divend:)

->'''E.''' myvar: = 5

-->(:toggle hide q1b button show="Select":)
(:div id=q1b:)
-->%red%Incorrect.%% ':' Has a purpose in python so it can't be used in a variable name.
(:divend:)

->'''F.''' myvar! = 5

-->(:toggle hide q1c button show="Select":)
(:div id=q1c:)
-->%blue%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:)

->'''A.''' Incorrect symbol used for 'greater than'

-->(:toggle hide q1a button show="Select":)
(:div id=q1a:)
-->%red%Incorrect.%%  It is actually the correct symbol for 'greater than'.
(:divend:)

->'''B.''' Incorrect 'if' statement syntax

-->(:toggle hide q1b button show="Select":)
(:div id=q1b:)
-->%blue%Correct.%%  There is a missing indentation and colon.
(:divend:)

->'''C.''' Incorrect order of 3 and y in the if statement

-->(:toggle hide q1c button show="Select":)
(:div id=q1c:)
-->%red%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$}

->'''A.''' y = 5x4 + 2x3 + 14x2 + 3x + 7

-->(:toggle hide q1a button show="Select":)
(:div id=q1a:)
-->%red%Incorrect.%%  You will need to use the multiplication symbol in python as well as a symbol that will make an exponent.
(:divend:)

->'''B.''' y = 5x^4 + 2x^3 + 14x^2 + 3x + 7

-->(:toggle hide q1b button show="Select":)
(:div id=q1b:)
-->%red%Incorrect.%%  You will need to use a multiplication symbol and the correct symbol for creating an exponent.
(:divend:)

->'''C.''' y = 5*x^4 + 2*x^3 + 14*x^2 + 3*x + 7

-->(:toggle hide q1c button show="Select":)
(:div id=q1c:)
-->%red%Incorrect.%%  The correct symbol for making an exponent is **, not ^.
(:divend:)

->'''D.''' 5 = y = 5*x**4 + 2*x**3 + 14*x**2 + 3*x + 7

-->(:toggle hide q1a button show="Select":)
(:div id=q1a:)
-->%blue%Correct.%%  The variable name should be on the left with the assigned value on the right.
(:divend:)

->'''E.''' y = 5*x*x*x*x + 2*x*x*x + 14*x*x + 3*x + 7

-->(:toggle hide q1b button show="Select":)
(:div id=q1b:)
-->%blue%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:)

->'''A.''' 243.347

-->(:toggle hide q1a button show="Select":)
(:div id=q1a:)
-->%red%Incorrect.%%
(:divend:)

->'''B.''' 1

-->(:toggle hide q1b button show="Select":)
(:div id=q1b:)
-->%blue%Correct.%%
(:divend:)

->'''C.''' 0

-->(:toggle hide q1c button show="Select":)
(:div id=q1c:)
-->%red%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:)

->'''A.''' 60

-->(:toggle hide q1a button show="Select":)
(:div id=q1a:)
-->%blue%Correct.%%
(:divend:)

->'''B.''' 61

-->(:toggle hide q1b button show="Select":)
(:div id=q1b:)
-->%red%Incorrect.%%
(:divend:)

->'''C.''' 62

-->(:toggle hide q1c button show="Select":)
(:div id=q1c:)
-->%red%Incorrect.%%
(:divend:)

->'''D.''' 63

-->(:toggle hide q1c button show="Select":)
(:div id=q1c:)
-->%red%Incorrect.%%
(:divend:)