WorksheetsPython Programming Quiz
Total questions: 13
Worksheet time: 3hrs 1mins
What is the correct way to define a function in Python?
function myFunc():
def myFunc():
func myFunc():
define myFunc():
Which data type is immutable in Python?
List
Dictionary
String
Set
What is the correct way to check if "apple" exists as a key in fruits = {"apple": 1, "banana": 2}?
"apple" in fruits
fruits.has_key("apple")
"apple" exists in fruits
if fruits("apple"):
What is the output of bool([]) in Python?
True
False
None
Error
Which statement is used to handle exceptions in Python?
catch
try-except
error
handle
What is the result of 3 * "Python"?
"PythonPythonPython"
["Python", "Python", "Python"]
Error
("Python", "Python", "Python")
Is Python a case-sensitive language?
Yes
No
Which of the following is NOT a valid variable name in Python?
_myVar
2ndValue
my_variable
variable2
What happens when executing x = 5; y = "hello"; x, y = y, x
Error
x becomes "hello" and y becomes 5
y becomes "hello" and x remains 5
No change
What will be the output of the following code?
2 5 8
2 3 4 5 6 7 8 9
2 4 6 8 10
2 6 10
Explain the differences between Python’s list, tuple, and set.
List any Python keywords you can remember.
Describe Python in one word.
