Skip to content

Punjab (PTB) · Chapter test · Free

1st Year Computer Chapter 2 TestPython Programming

30 marks · 40 minutes · 21 questions. Covers: CHAP 2:Python Programming.

Your school name

1st Year Computer Chapter 2 Test

1st Year · Computer · Punjab (PTB)

Name: ____________Roll No: ________Class/Section: ________Date: ________Total marks: 30Time: 40 minutes

Q1. Multiple choice questions (Attempt all · 10 × 1 = 10)

  1. Which of the following is a correct way to output text in Python?

    1. display("Hello")

    2. echo "Hello"

    3. print("Hello")

    4. show("Hello")

  2. How can multiple objects be created from the same class in Python?

    1. By using the new keyword.

    2. By calling the class as a function with different arguments.

    3. By using inheritance.

    4. Multiple objects cannot be created from the same class.

  3. Which of the following statements is true about the if-else statement in Python?

    1. The else block is mandatory

    2. The else block runs only when the condition is true

    3. The if-else statement allows for two code blocks, one for true and one for false conditions

    4. The else block runs only when the condition is false

  4. What is the purpose of the import statement in Python?

    1. To create a new function.

    2. To define a variable.

    3. To include external libraries or modules in your program.

    4. To define a class.

  5. In the expression 2**3*4 , which operation performed first?

    1. Exponentiation

    2. Multiplication

    3. Parentheses

    4. Addition

  6. Which of the following is used to define a class in Python?

    1. Function

    2. Def

    3. Class

    4. Object

  7. What will happen if all conditions in an if-elif-else statement are false?

    1. The program will stop.

    2. The code in the else block will run.

    3. The program will produce an error.

    4. The first condition will run.

  8. Which of the following methods removes an item from the list?

    1. pop( )

    2. append( )

    3. sort( )

    4. insert( )

  9. What symbol is used to start a multi-line comment in Python?

    1. Double quotes

    2. Triple quotes

    3. Forward slash

    4. Curly braces

  10. What happens when the condition in a while loop becomes false?

    1. The loop continues running.

    2. The loop stops and the program moves to the next line of code.

    3. The program produces an error.

    4. The loop restarts from the beginning.

Q2. Short questions (Attempt any 6 of 8 · 6 × 2 = 12)

  1. How do you import a module from a package in Python?

  2. How is the modulus operator % used in Python?

  3. What does the = = operator do in Python?

  4. How do you access an item in a list?

  5. What is exception handling in Python?

  6. What do comparison operators in Python do?

  7. How can parentheses be used in expressions?

  8. What does the not operator do in Python?

Q3. Long questions (Attempt any 2 of 3 · 2 × 4 = 8)

  1. Explain how list slicing works with an example. 

  2. Explain the different comparison operators in Python and provide examples of how each one works. 

  3. Describe the input and output operations in Python. How does the input( ) function work, and how can you display the entered data?