This document is a Python test paper consisting of multiple choice questions, short answer questions, coding exercises, and an advanced problem-solving section. The test is worth a total of 50 marks and covers various Python concepts such as functions, data types, and operators. Instructions emphasize answering all questions and reading carefully.
Download as DOCX, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
1 views
python test paper
This document is a Python test paper consisting of multiple choice questions, short answer questions, coding exercises, and an advanced problem-solving section. The test is worth a total of 50 marks and covers various Python concepts such as functions, data types, and operators. Instructions emphasize answering all questions and reading carefully.
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2
WORLD OF COMPUTERS
PYTHON TEST PAPER
Instructions:
1. Answer all questions.
2. Read each question carefully before answering. 3. This test is worth a total of 50 marks.
Section A: Multiple Choice Questions (2 marks each)
1. What does the print() function do in Python? a) Reads user input
from the console b) Prints output to the console c) Performs mathematical calculations d) Defines a variable 2. Which of the following is a correct way to comment multiple lines in Python? a) // This is a comment b) /* This is a comment */ c) # This is a comment d) <!-- This is a comment --> 3. What is the result of 5 + 3 * 2 in Python? a) 16 b) 11 c) 10 d) 26 4. Which data type is mutable in Python? a) Tuple b) List c) String d) Dictionary 5. What will be the output of the following code? python Copy code my_list = [ 1 , 2 , 3 , 4 , 5 ] print (my_list[ 2 ]) a) 2 b) 3 c) 4 d) 5
Section B: Short Answer Questions (5 marks each)
6. Explain the difference between == and is operators in Python.
7. What is the purpose of the __init__ method in Python classes? 8. Describe the difference between lists and tuples in Python. Section C: Coding Exercises (10 marks each)
9. Write a Python function that takes a list of numbers as input and
returns the sum of all the numbers. 10. Write a Python function to check if a given number is prime or not.
Section D: Advanced Problem Solving (15 marks)
11. Write a Python function to calculate the factorial of a given