0% found this document useful (0 votes)
10 views2 pages

Python Test

Uploaded by

bsee2358
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views2 pages

Python Test

Uploaded by

bsee2358
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Python Basics Test

Total Marks: 20

Section A: Multiple Choice Questions (MCQs) (4 marks)

Each question carries 1 mark.

1. What is the correct command to install Python on Windows using the


command prompt?
a) python install
b) pip install python
c) winget install python
d) install python.exe

2. Which of the following is a valid Python variable name?


a) 2variable
b) my-variable
c) _myVariable
d) my variable

3. What is the correct syntax to print "Hello, World" in Python?


a) echo("Hello, World")
b) printf("Hello, World")
c) print("Hello, World")
d) println("Hello, World")

4. What does the following code return: len([1, 2, 3, 4])?


a) 3
b) 4
c) 5
d) None of the above

Section B: True or False (4 marks)

Each question carries 1 mark.

1. You can use pip to install third-party Python packages.


True / False

2. Lists in Python are immutable.


True / False
3. The Python interpreter executes a .py file line by line.
True / False

4. In Python, you must declare the variable type explicitly before


assigning a value to it.
True / False

Section C: Short Answer Questions (8 marks)

Each question carries 2 marks.

1. What are the steps to install Python on a Windows machine?

2. Explain the difference between a list and a tuple in Python.

3. Write a Python program that asks the user for their name and prints it
in uppercase letters.

4. What is the output of the following Python code?

python

Copy code

my_list = ['apple', 'banana', 'cherry']

my_list.append('date')

print(my_list)

Section D: Practical Question (4 marks)

The question carries 4 marks.

1. Write a Python script that performs the following operations on a list:

o Create a list of 5 numbers.

o Add a new number to the list.

o Remove the third element from the list.

o Print the final list.

You might also like