WorksheetsPython revision
Total questions: 15
Worksheet time: 11mins
What is the output of this code?
1
2
"a"
Error
Which of the following creates a dictionary?
{"apple", 1}
["apple": 1]
{"apple": 1}
(apple:1)
How do you add a new key-value pair to a dictionary?
my_dict.add("color", "blue")
my_dict["color"] = "blue"
my_dict("color") = "blue"
my_dict += {"color": "blue"}
What will this code print?
1
2
10
20
What is the result of this code?
5
7
3
2
Which line causes an error?
{"a": 1, "b": 2}
d={"a": 1, "b": 2}
print(d["c"])
None
What does this function return?
None
Hi!
greet
Error
Which keyword is used to define a function?
fun
define
def
func
How do you call this function?
hello
hello[ ]
hello( )
call hello
What is the output?
7
34
a + b
error
Which line defines a function with one parameter?
def my_func[x]:
def my_func(x):
def my_func x:
my_func def(x)
What is the output?
10
25
5
x *x
What does this code do?
Shows error
Returns value
Prints Done when called
Defines nothing
What is the output of this?
10
9
1
11
Which line is invalid?
def my_func():
print("Hello")
return 5
def (x, y):
