Python Programming
Python Programming
14. How can you remove the first occurrence of a value from a list?
a) remove()
b) delete()
c) pop()
d) discard()
15. What will be the output of the following code? list = [1, 2, 3, 4]; print(list[:2])
a) [1]
b) [1, 2]
c) [1, 2, 3]
d) [2, 3]
Python Programming - Assertion and Reasoning Based Questions (10 Marks Each)
Instructions:
1. Assertion (A):
In Python, syntax errors are caught by the interpreter during code compilation.
Reason (R):
Syntax errors occur when the code does not conform to the rules of the Python language
syntax.
2. Assertion (A):
The try-except block is used in Python to handle exceptions and prevent the program from
crashing.
Reason (R):
Python’s try-except block is capable of handling any kind of logical errors in the code.
3. Assertion (A):
The flow of control in Python programs is strictly sequential unless control statements like if-
else or loops are used.
Reason (R):
if-else statements in Python allow decision-making based on conditions, and loops allow
repetitive execution of code blocks.
4. Assertion (A):
The else clause in Python’s if-elif-else structure is mandatory and must always be included to
avoid errors.
Reason (R):
The else clause provides an alternative action when none of the conditions in if or elif blocks
are met.
5. Assertion (A):
A while loop can be replaced with a for loop in every situation in Python.
Reason (R):
Both while and for loops can be used interchangeably, as they serve the same purpose in all
cases.
6. Assertion (A):
Python allows nested conditional statements inside loops.
Reason (R):
Nested conditional statements allow Python to handle complex decision-making scenarios by
placing if-else statements inside loops or other conditional statements.
Section B
Practical question 30 marks
Practical Python Programming Questions (5 Marks Each)
1. Write a Python program that uses conditional statements to determine if a year is a leap
year. A leap year is divisible by 4, but not by 100, unless it is also divisible by 400.
(Hint: Use if-elif-else to handle the conditions for leap year calculation.)
2. Create a Python program that prompts the user to enter a number and then prints whether
the number is positive, negative, or zero using conditional statements.
(Hint: Use an if-elif-else structure to check and print the appropriate result.)
3. Write a Python program that takes a number as input and uses a loop to print whether the
number is even or odd for all numbers from 1 to the input number.
(Hint: Use a for loop and an if statement to check each number and print whether it is even or
odd.)
4. Write a Python program that prompts the user for a number and checks if the number is
divisible by both 3 and 5 using conditional statements. Print an appropriate message.
(Hint: Use the modulus operator (%) with if-elif-else statements to check divisibility.)
6. Dictionary Manipulation
Write a Python program to create a dictionary where keys are names of students and values
are their marks. Then, check if a particular student's name is in the dictionary and print their
marks if found, or print a message if not found.
7. Using if-else
Write a Python program that asks the user to input a number. The program should then print
whether the number is positive, negative, or zero using if-else statements.
8. For Loop
Write a Python program that prints the multiplication table of a number entered by the user,
from 1 to 10.
Section c
Theory questions 10 marks
Q1. Discuss the different types of software used in computing. Explain the distinction between
system software and application software, providing specific examples of each. Additionally, briefly
describe the role of utility software in enhancing system performance.(4 marks)
Q2. Define an operating system (OS) and explain its primary functions. Additionally, describe the
difference between a graphical user interface (GUI) and a command-line interface (CLI).(3 Marks)
Q3. Define Boolean logic and explain its role in computer operations. Additionally, outline the
differences between binary and decimal number systems, and explain why binary is preferred in
computing.(3 marks)
Q4. Define the terms "expression" and "statement" in the context of Python programming. Explain
how they differ from each other. Additionally, discuss the concept of type conversion and provide
examples of both implicit and explicit type conversion in Python. Finally, describe how to take user
input and display output in a Python program.