Class 10 Computer Science · Chapter 4 · Test 5
Test 5: Short Questions – Part 2
25 questions · 50 min · 63 marks
Want to try first? Take the free Computer Science test: 94hbp-7gz9m-ufent-tsj4r
Sample questions with answers
The first 5 of 25, each with a model answer. Try writing yours first.
Question 1 · 2 marks
What is a library in Python?
Show model answerHide model answer
Libraries are like toolboxes or pre-built toolkits full of useful tools that help you solve different problems without having to build everything from scratch.
Question 2 · 2 marks
How do you import a library in Python?
Show model answerHide model answer
A library is imported using the import keyword, for example import random or import statistics.
Question 3 · 3 marks
Write a program to generate a random number between 1 and 10 using the random library.
Show model answerHide model answer
import random number = random.randint(1, 10) print("The random number is:", number)
Question 4 · 3 marks
Write a program to calculate the mean of the list [23, 45, 67, 89, 12, 44, 56] using the statistics library.
Show model answerHide model answer
import statistics
data = [23, 45, 67, 89, 12, 44, 56]
mean_value = statistics.mean(data)
print("The mean value is:", mean_value)
Output: The mean value is: 48
Question 5 · 2 marks
Why should you only import the libraries you need?
Show model answerHide model answer
When importing libraries, make sure to only import what you need. More libraries can be explored at docs.python.org/3/.
More tests in Control Structures in Python
- Test 1: Decision Making and Loops
MCQs · 30 questions · 25 min · 30 marks
- Test 2: Libraries, Lists, Testing and Debugging
MCQs · 30 questions · 25 min · 30 marks
- Test 3: Complete Chapter Review
MCQs · 30 questions · 25 min · 30 marks
- Test 4: Short Questions – Part 1
Short questions · 25 questions · 50 min · 62 marks
- Test 6: Long Questions
Long questions · 10 questions · 50 min · 59 marks
Practise with a free account
Save your scores, see which chapters need work, and keep a notebook of every question you got wrong.