---
Class XI – Computer Science (CBSE)
Half Yearly Examination
Maximum Marks: 70 Time: 3 Hours
---
Section – A
(Each question carries 1 mark)
Q.1 to Q.21 – Multiple Choice Questions (MCQs)
Choose the correct answer from the given options:
1. Which of the following is a mutable data type in Python?
(a) Tuple (b) String (c) List (d) Integer
2. Which function is used to find the number of elements in a list?
(a) size() (b) count() (c) length() (d) len()
3. What will be the output of print("Hello".lower())?
(a) HELLO (b) hello (c) Error (d) Hello
4. Which statement is used to check multiple conditions in Python?
(a) switch (b) if-elif-else (c) for (d) while
5. Which of the following is a valid binary representation of 13?
(a) 1100 (b) 1101 (c) 1010 (d) 1001
6. Boolean expression not (True and False) results in:
(a) True (b) False (c) 0 (d) None
7. Which operator is used for logical “AND” in Python?
(a) & (b) && (c) and (d) |
8. Identify the invalid variable name:
(a) _name (b) student1 (c) 1student (d) student_name
9. Which keyword is used to skip the rest of the loop and start next iteration?
(a) exit (b) continue (c) break (d) pass
10. The function [Link](x)
(a) Adds an item at the end (b) Inserts item at start (c) Removes item (d) Clears list
11. Which function removes whitespace from both ends of a string?
(a) trim() (b) strip() (c) split() (d) cut()
12. The binary equivalent of decimal 8 is:
(a) 1000 (b) 1100 (c) 1010 (d) 1110
13. In Boolean logic, “OR” operation gives True when:
(a) both inputs True (b) both False (c) any one True (d) both different
14. What is the output of 3 == 3.0 in Python?
(a) False (b) True (c) Error (d) None
15. Which of these is not a data type in Python?
(a) int (b) float (c) char (d) str
16. Which of the following statements is correct about debugging?
(a) It is testing code (b) It is correcting code errors (c) It is deleting code (d) It is compiling
17. What will be the output of bool(0)?
(a) True (b) False (c) 1 (d) None
18. Which of the following functions reads CSV files in Python?
(a) open() (b) read() (c) read_csv() (d) load()
19. What is the output of len(["A", "B", "C"])?
(a) 2 (b) 3 (c) 1 (d) Error
20. Which function converts a number to binary string?
(a) hex() (b) oct() (c) bin() (d) str()
21. Which loop executes at least once?
(a) for (b) while (c) do-while (d) None
---
Section – B
(Each question carries 2 marks)
Answer the following questions briefly:
22. What is list slicing? Give one example.
23. Differentiate between syntax error and logical error.
24. Write a Python code to reverse a given string.
25. Explain the difference between while and for loop.
26. Convert the binary number 110011 into decimal.
27. Write the truth table for A and not B.
28. What is a CSV file? How can you open it in Python?
---
Section – C
(Each question carries 3 marks)
Answer the following programming-based questions:
29. Write a Python program to input 5 numbers in a list and print the maximum number.
30. Write a program to check whether a given string is a palindrome or not.
31. Write a program that prints all even numbers between 1 and 50 using a while loop.
---
Section – D
(Each question carries 4 marks)
Answer the following questions:
32. Write a Python program to count and display the number of vowels and consonants in a given string.
33. Write a Python program to display the sum of all elements of a list entered by the user.
34. What is debugging? Explain four common types of programming errors with examples.
35. Write a Python program that accepts a string and prints the number of uppercase, lowercase, digits,
and special characters.
---
Section – E
(Each question carries 5 marks)
Answer the following programming-based questions:
36. Write a Python program to input 10 numbers in a list and display only those numbers which are
divisible by both 2 and 3.
37. Write a Python program that takes marks of 5 subjects from the user, calculates total, percentage,
and grade according to the following rules:
Percentage ≥ 90 → Grade A+
80–89 → Grade A
70–79 → Grade B
60–69 → Grade C
Below 60 → Grade D
Answer sheet
Answer Sheet
Class XI – Computer Science (Half Yearly Exam)
---
Section – A (1 Mark Each)
1. (c) List
2. (d) len()
3. (b) hello
4. (b) if-elif-else
5. (b) 1101
6. (a) True
7. (c) and
8. (c) 1student
9. (b) continue
10. (a) Adds an item at the end
11. (b) strip()
12. (a) 1000
13. (c) any one True
14. (b) True
15. (c) char
16. (b) It is correcting code errors
17. (b) False
18. (c) read_csv()
19. (b) 3
20. (c) bin()
21. (d) None
---
Section – B (2 Marks Each)
22.
List slicing: It means accessing a specific portion of a list using indices.
Example:
nums = [10, 20, 30, 40, 50]
print(nums[1:4]) # Output: [20, 30, 40]
23.
Syntax Error: Occurs when Python cannot interpret the code (e.g., missing colon).
Example: if x > 5 print(x)
Logical Error: Code runs but gives wrong output.
Example: using + instead of * in a formula.
24.
s = input("Enter string: ")
print("Reversed:", s[::-1])
25.
for loop: Executes for a fixed range of values.
while loop: Executes as long as a condition is true.
26.
Binary 110011 = (1×32) + (1×16) + (0×8) + (0×4) + (1×2) + (1×1) = 51
27.
A B not B A and not B
0 0 1 0
0 1 0 0
1 0 1 1
1 1 0 0
28.
CSV file: A text file that stores tabular data separated by commas.
Opening:
import pandas as pd
data = pd.read_csv('[Link]')
---
Section – C (3 Marks Each)
29.
nums = []
for i in range(5):
n = int(input("Enter number: "))
[Link](n)
print("Maximum number:", max(nums))
30.
s = input("Enter string: ")
if s == s[::-1]:
print("Palindrome")
else:
print("Not Palindrome")
31.
i=1
while i <= 50:
if i % 2 == 0:
print(i, end=" ")
i += 1
---
Section – D (4 Marks Each)
32.
s = input("Enter string: ")
vowels = consonants = 0
for ch in s:
if [Link]() in "aeiou":
vowels += 1
elif [Link]():
consonants += 1
print("Vowels:", vowels)
print("Consonants:", consonants)
33.
lst = []
n = int(input("Enter number of elements: "))
for i in range(n):
[Link](int(input("Enter number: ")))
print("Sum of elements:", sum(lst))
34.
Debugging: Process of finding and correcting errors in code.
Types of Errors:
1. Syntax Error – Missing colon, brackets, etc.
2. Runtime Error – Division by zero.
3. Logical Error – Wrong logic but valid syntax.
4. Semantic Error – Code meaning doesn’t match intention.
35.
s = input("Enter string: ")
u = l = d = sp = 0
for ch in s:
if [Link]():
u += 1
elif [Link]():
l += 1
elif [Link]():
d += 1
else:
sp += 1
print("Uppercase:", u)
print("Lowercase:", l)
print("Digits:", d)
print("Special:", sp)
---
Section – E (5 Marks Each)
36.
nums = []
for i in range(10):
n = int(input("Enter number: "))
[Link](n)
print("Numbers divisible by both 2 and 3:")
for n in nums:
if n % 2 == 0 and n % 3 == 0:
print(n)
37.
marks = []
for i in range(5):
m = float(input(f"Enter marks of subject {i+1}: "))
[Link](m)
total = sum(marks)
per = total / 5
if per >= 90:
grade = "A+"
elif per >= 80:
grade = "A"
elif per >= 70:
grade = "B"
elif per >= 60:
grade = "C"
else:
grade = "D"
print("Total:", total)
print("Percentage:", per)
print("Grade:", grade)