Class 11 Computer Science · Chapter 2 · Test 4
Functions, Lists and Tuples
40 MCQs Covers functions, default and keyword arguments, *args, modules, libraries and packages. Also covers lists, tuples, strings, slicing and dictionaries
40 questions · 35 min · 40 marks
Want to try first? Take the free Computer Science test: SDLC and Waterfall Model
Sample questions
The first 5 of 40. Try each one, then tap to see the answer.
Question 1
Which keyword is used to define a function?
- Afunction
- Bdef
- Cdefine
- Dfunc
Show answerHide answer
Answer: B
Functions are defined with the def keyword.
Question 2
What is a default parameter?
- AA parameter with no value
- BA parameter that must be passed
- CA special keyword
- DA parameter with a pre-set value
Show answerHide answer
Answer: D
If no argument is passed, the default value is used.
Question 3
What is the purpose of *args in Python?
- AHandle many arguments
- BReturn a list
- CCreate variables
- DMultiply strings
Show answerHide answer
Answer: A
*args collects any number of positional arguments into a tuple.
Question 4
What does this code return: def add(a, b): return a + b, if add(2, 3) is called?
- A23
- Ba+b
- C5
- DError
Show answerHide answer
Answer: C
The function returns the sum 2 + 3 = 5.
Question 5
What is the use of import in Python?
- AExport values
- BUse built-in libraries
- CCall a function
- DClose files
Show answerHide answer
Answer: B
import brings a module or library into the program so its features can be used.
More tests in Python Programming
Practise with a free account
Save your scores, see which chapters need work, and keep a notebook of every question you got wrong.