0% found this document useful (0 votes)
30 views285 pages

CS QB 2025 - YK-Opt

The document is a comprehensive question bank for Class XII Computer Science, covering topics such as Python, Database Management, and Computer Networks. It includes various question formats like MCQs, assertion-reasoning, finding output, descriptive questions, and case studies, along with five solved sample question papers. The aim is to help students revise concepts effectively to achieve high scores in board exams.

Uploaded by

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

CS QB 2025 - YK-Opt

The document is a comprehensive question bank for Class XII Computer Science, covering topics such as Python, Database Management, and Computer Networks. It includes various question formats like MCQs, assertion-reasoning, finding output, descriptive questions, and case studies, along with five solved sample question papers. The aim is to help students revise concepts effectively to achieve high scores in board exams.

Uploaded by

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

Topic-wise Practice Questions •


MCQs
Assertion-Reasoning
with Answers • Finding Output
• Descriptive Questions
(Python, Database Management, Computer Networks) • Writing Code
• Writing Queries
• Case Studies
With

Five Sample Question Papers (Solved)

COMPUTER SCIENCE
– CLASS XII
Revise your concepts topic-wise in different
question formats to strengthen your concepts
and score excellent marks in board exams.

- Yogesh Kumar
QB/XII/CS-083/2025/YK/Initial Pages

© Author
No part of this Question Bank can be reproduced in any form (print, electronic, or any other)
without prior written permission from the author.
All suggestions for the improvement in this question bank are most welcome. Suggestions
can be emailed to [email protected]
Utmost care has been taken to ensure that there are no mistakes (printing or other) in the
book. But human errors cannot be 100% ruled out. If you find any mistake in the book, please
report it at [email protected] .

www.yogeshsir.com (i) www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Initial Pages

Contents
1. Syllabus
2. Syllabus Coverage Checklist
3. Questions
(I) Python
1. MCQs
(i) Basics-1 Q1
(ii) Basics-2 Q5
(iii) Boolean Expressions Q8
(iv) range() and random Q13
(v) Lists Q16
(vi) Tuples Q21
(vii) Strings Q23
(viii) Dictionaries Q25
(ix) Functions Q27
(x) Text Files Q30
(xi) CSV Files Q36
(xii) Binary Files Q39
(xiii)Exception Handling Q42
2. Assertion Reasoning Q44
3. Finding Output
(i) Compound Assignment Operators Q47
(ii) if..elif..else Q49
(iii) Loops Q55
(iv) Lists Q58
(v) Tuples Q62
(vi) Strings Q64
(vii) Dictionaries Q69
(viii)Functions Q73
4. Correcting the code Q76
5. Writing Single-statement code Q81
6. Writing Functions Q84
7. Text File Operations Q86
8. CSV File Operations Q89
9. Binary File Operations Q92
10. Stacks Q94
(II) Database Management
1. MCQs Q98
2. Assertion Reasoning Q108
3. Descriptive Questions Q111
4. Writing Queries Q113
5. Writing Queries and Finding Output Q115
6. Python - Database Connectivity Q130

www.yogeshsir.com (ii) www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Initial Pages

(III) Computer Networks


1. MCQs Q136
2. Descriptive Questions Q140
3. Case Studies Q141

4. Answers
(I) Python
1. MCQs A1
2. Assertion Reasoning A2
3. Finding Output A5
4. Correcting the code A5
5. Writing Single-statement code A10
6. Writing Functions A12
7. Text File Operations A15
8. CSV File Operations A19
9. Binary File Operations A21
10. Stacks A27
(II) Database Management
1. MCQs A30
2. Assertion Reasoning A30
3. Descriptive Questions A30
4. Writing Queries A31
5. Writing Queries and Finding Output A33
6. Python - Database Connectivity A41
(III) Computer Networks
4. MCQs A44
5. Descriptive Questions A44
6. Case Studies A48

5. Sample Question Papers


(I) Sample Question Papers (1 – 5) SQP1-1
(II) Answer Keys AK1-1

www.yogeshsir.com (iii) www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Initial Pages

www.yogeshsir.com (iv) www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Initial Pages

www.yogeshsir.com (v) www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Initial Pages

www.yogeshsir.com (vi) www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Initial Pages

www.yogeshsir.com (vii) www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Initial Pages

Syllabus Coverage Checklist


Computer Science (083) – 2024-25
Unit No. Unit Name Marks
I Computational Thinking and Programming 40
II Computer Networks 10
III Database Management 20

Unit I: Computational Thinking and Programming


1. Basics - Python tokens (keyword, identifier, literal, operator, punctuator), Variables, Concept of l-
value and r-value, Use of comments
2. Data types: Number (integer, floating point, complex), boolean, sequence(string, list, tuple), None,
Mapping(dictionary), Mutable and Immutable data types.
3. Operators: arithmetic operators, relational operators, logical operators, assignment operators,
augmented assignment operators, identity operators (is, is not), membership operators (in, not in)
4. Precedence of operators, Evaluation of an expression, Type-conversion (explicit and implicit
conversion), Accepting data as input from the console and displaying output.
5. Errors- syntax errors, logical errors, and run-time errors
6. Conditional statements: if, if-else, if-elif-else
7. Iterative Statement: for loop, range(), while loop, break and continue statements, nested loops.
8. Strings: String operations (concatenation, repetition, membership and slicing), traversing a string
using loops, built-in functions/methods–len(), capitalize(), title(), lower(), upper(), count(), find(),
index(), endswith(), startswith(), isalnum(), isalpha(), isdigit(), islower(), isupper(), isspace(),lstrip(),
rstrip(), strip(), replace(), join(), partition(), split()
9. Lists: Indexing, list operations (concatenation, repetition, membership and slicing), traversing a list
using loops, built-in functions/methods–len(), list(), append(), extend(), insert(), count(), index(),
remove(), pop(), reverse(), sort(), sorted(), min(), max(), sum(); nested lists.
10. Tuples: Indexing, tuple operations (concatenation, repetition, membership and slicing); built-in
functions/methods – len(), tuple(), count(), index(), sorted(), min(), max(), sum(); tuple assignment,
nested tuple.
11. Dictionary: introduction, accessing items in a dictionary using keys, mutability of a dictionary (adding
a new term, modifying an existing item), traversing a dictionary, built-in functions/methods – len(),
dict(), keys(), values(), items(), get(), update(), del(), del, clear(), fromkeys(), copy(), pop(), popitem(),
setdefault(), max(), min(), sorted().
12. Introduction to Python modules: Importing module using 'import <module>' and using from
statement.
a. importing math module (pi, e, sqrt(), ceil(), floor(), pow(), fabs(), sin(), cos(), tan());
b. random module (random (), randint(), randrange())
c. statistics module (mean(), median(), mode()).

www.yogeshsir.com (viii) www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Initial Pages

13. Functions:
a. types of function (built-in functions, functions defined in module, user defined functions)
b. creating user defined function
c. arguments and parameters: default parameters, positional parameters
d. function returning value(s), flow of execution
e. scope of a variable (global scope, local scope)
14. Exception Handling: Introduction, handling exceptions using try-except-finally blocks
15. Introduction to files, types of files (Text file, Binary file, CSV file), relative and absolute paths
16. Text file:
a. opening a text file, text file open modes (r, r+, w, w+, a, a+), closing a text file, opening a file
using with clause
b. writing/appending data to a text file using write() and writelines()
c. reading from a text file using read(), readline() and readlines()
d. seek and tell methods
e. manipulation of data in a text file
17. Binary file:
a. basic operations on a binary file: open using file open modes (rb, rb+, wb, wb+, ab, ab+), close
a binary file,
b. import pickle module, dump() and load() method
c. read, write/create, search, append and update operations in a binary file
18. CSV file:
a. import csv module, open / close csv file,
b. write into a csv file using writer(), writerow(), writerows()
c. read from a csv file using reader()
19. Data Structure: Stack, operations on stack (push & pop), implementation of stack using list.

www.yogeshsir.com (ix) www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Initial Pages

www.yogeshsir.com (x) www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

(I) Python

www.yogeshsir.com Page: Q1/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

Python MCQs
Basics-1
1. Who developed Python?
a) Guido Van Rossum b) Bill gates
c) Charles Babbage d) Steve Jobs

2. Python was first released in the year:


a) 2000 b) 1995
c) 1991 d) 2005

3. Python is
a) case-sensitive b) not case-sensitive
c) selectively case-sensitive d) none of these

4. What is the data type of 7


a) int b) float
c) bool d) str

5. What is the data type of 7.0


a) int b) float
c) bool d) str

6. What is the data type of '7'


a) int b) float
c) bool d) str

7. Which of the following operators always produces a float value


a) + b) -
c) * d) /

8. What is the data type of 7+3


a) int b) float
c) bool d) str

9. What is the data type of 7/3


a) int b) float
c) bool d) str

10. What is the data type of 7//3


a) int b) float
c) bool d) str

11. What is the data type of 7//3.0


a) int b) float
c) bool d) str

12. What is the data type of 8.4>6


a) int b) float
c) bool d) str

13. What is the value of the expression 14//3


a) 4 b) 5
c) -4 d) -5

www.yogeshsir.com Page: Q2/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

14. What is the value of the expression -14//3


a) 4 b) 5
c) -4 d) -5

15. What is the value of the expression 14//-3


a) 4 b) 5
c) -4 d) -5

For tutorial on Floor Division (//) and Remainder(%) operators, scan the QR code:

16. What is the value of the expression -14//-3


a) 4 b) 5
c) -4 d) -5

17. What is the value of the expression 14%3


a) 2 b) -2
c) 1 d) -1

18. What is the value of the expression -14%3


a) 2 b) -2
c) 1 d) -1

19. What is the value of the expression 14%-3


a) 2 b) -2
c) 1 d) -1

20. What is the value of the expression -14%-3


a) 2 b) -2
c) 1 d) -1

21. What is the value of the expression (2**3)**2


a) 12 b) 36
c) 64 d) 512

22. What is the value of the expression 2**(3**2)


a) 12 b) 36
c) 64 d) 512

23. What is the value of the expression 2**3**2


a) 12 b) 36
c) 64 d) 512

24. What is the value of the expression 2**2**3


a) 12 b) 64
c) 256 d) 512

www.yogeshsir.com Page: Q3/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

25. What is the value of the expression -3**2


a) 9 b) -9
c) 1/9 d) -1/9

26. What is the value of the expression 3**-2


a) 9 b) -9
c) 1/9 d) -1/9

27. What is the value of the expression (-3)**2


a) 9 b) -9
c) 1/9 d) -1/9

28. What is the value of the expression (-3)**(-2)


a) 9 b) -9
c) 1/9 d) -1/9

29. What is the value of the expression 12+3*4-6/2


a) 27.0 b) 57.0
c) 21.0 d) 9.0

30. What is the value of the expression (12+3)*4-6/2


a) 27.0 b) 57.0
c) 21.0 d) 9.0

31. What is the value of the expression 12+3*(4–6)/2


a) 27.0 b) 57.0
c) 21.0 d) 9.0

32. What is the value of the expression 12+(3**4–6)/2


a) 43.5 b) 46.5
c) 49.5 d) None of these

33. What is the value of the expression 12*(3%4)//2+6


a) 6 b) 24
c) 4.5 d) None of these

34. What is the value of the expression 12%3**4//5+6


a) 6 b) 8
c) 18 d) None of these
𝑥+𝑦+𝑧
35. Identify the correct Python expression representing
2
a) x+y+z/2 b) x+y+(z/2)
c) (x+y+z)/2 d) None of these
𝑥+𝑦
36. Identify the correct Python expression representing
𝑥−𝑦
a) x+y/x-y b) (x+y)/(x-y)
c) x+y/(x-y) d) (x+y)/x-y

37. Identify the correct Python expression representing


3
𝑥𝑦
𝑥−𝑦
a) 3/x-y*x**y b) (3/x-y)*(x**y)
c) 3/x-y*(x**y) d) (3/(x-y))*x**y

www.yogeshsir.com Page: Q4/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

38. Identify the correct Python expression representing


𝑥 2 +𝑦
𝑥𝑦 2
a) x**2+y/x*y**2 b) (x**2+y)/xy**2
c) (x**2+y)/(x*y)**2 d) (x**2+y)/(x*y**2)

39. Identify the correct Python expression representing


√𝑥
𝑥−𝑦
a) x**1/2/x-y b) x**1/2/(x-y)
c) (x**1/2)/(x-y) d) x**(1/2)/(x-y)

40. Identify the correct Python expression representing 3√


3 𝑥+𝑦

√𝑥−𝑦
a) (x+y)**1/3/x**1/3-y b) (x+y)**(1/3)/x**(1/3)-y
c) (x+y)**1/3/x**(1/3)-y d) (x+y)**(1/3)/(x**(1/3)-y)

www.yogeshsir.com Page: Q5/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

Python MCQs
Basics-2
1. Which of the following is an invalid variable name?
a) My Book b) MyBook
c) myBook d) mY_BooK

2. Which of the following is an invalid variable name?


a) INR b) K_D
c) 5_Riyals d) Dollars

3. Which of the following is an invalid variable name?


a) PenandPencil b) Pen_andPencil
c) Pen&Pencil d) none

4. Which of the following is an invalid variable name?


a) true b) false
c) TrueFalse d) True

5. Which of the following is an invalid variable name?


a) cust_name b) cust.name
c) custName d) _CUSTNAME

6. Which of the following is/are invalid variable name(s)?


a) print b) int
c) float d) int float

7. Which of the following can be a valid variable name?


a) a keyword b) a built-in identifier
c) a number d) None of these

8. What will be the values of a and b after execution of the following statement:
a,b=10
a) a=10 and b=10 b) a=10 and b=0
c) a=0 and b=10 d) The given statement is incorrect

9. What will be the values of a and b after execution of the following statement:
a,b=10,20
a) a=10 and b=10 b) a=20 and b=20
c) a=10 and b=20 d) The given statement is incorrect

10. What will be the values of a and b after execution of the following code segment:
a,b=10,20
a+=b
b+=a
a) a=10 and b=10 b) a=30 and b=20
c) a=30 and b=30 d) a=30 and b=50

11. What will be the values of a and b after execution of the following code segment:
a,b=10,20
a=+b
b+=a
a) a=20 and b=20 b) a=20 and b=40
c) a=40 and b=20 d) The given code has an error
www.yogeshsir.com Page: Q6/150 www.youtube.com/LearnWithYK
QB/XII/CS-083/2025/YK/Questions

12. What will be the values of a and b after execution of the following code segment:
a,b=5,15
a+=b
b=a-b
a-=b
a) a=5 and b=15 b) a=15 and b=5
c) a=10 and b=-10 d) The given code has an error

13. What will be the values of a and b after execution of the following code segment:
a,b=5,15
a+=a+b
b-=a-b
a) a=25 and b=5 b) a=5 and b=25
c) a=20 and b=-10 d) a=20 and b=10

14. What will be the values of a and b after execution of the following code segment:
a,b=1,2
a*=a+b
b//=a-b
a) a=2 and b=3 b) a=2 and b=2
c) a=3 and b=3 d) a=3 and b=2

15. What is the value of the following expression?


int(12.8)
a) 12 b) 13
c) 12.8 d) Error

16. What is the value of the following expression?


int('12.8')
a) 12 b) 13
c) 12.8 d) Error

17. What is the value of the following expression?


int(12.3+5)
a) 12 b) 17
c) 17.3 d) Error

18. What is the value of the following expression?


int('12.3+5')
a) 12.3 b) 12
c) 17.3 d) Error

19. What is the value of the following expression?


float(12.8)
a) 12.8 b) 12
c) 13 d) Error

20. What is the value of the following expression?


float('12.8')
a) 12.8 b) 12
c) 13 d) Error

www.yogeshsir.com Page: Q7/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

21. What is the value of the following expression?


float('12.3+5')
a) 12.3 b) 12
c) 17.3 d) Error

22. What is the value of the following expression?


float(12.3+5)
a) 12.3 b) 12
c) 17.3 d) Error

23. What type of parameter/argument dose eval() accept?


a) int b) float
c) str d) all of these

24. What is the value of the following expression?


eval('3')*3
a) 33 b) 9
c) 333 d) Error

25. What is the value of the following expression?


eval('3'*3)
a) 33 b) 9
c) 333 d) Error

26. What is the value of the following expression?


eval(3*3)
a) 33 b) 9
c) 333 d) Error

27. What is the value of the following expression?


eval('3')*'3'
a) '33' b) 333
c) '333' d) Error

28. What is the value of the following expression?


eval('3'+'3')
a) '33' b) 33
c) '333' d) Error

29. What is the value of the following expression?


eval('3'*'3')
a) '33' b) 9
c) '333' d) Error

30. What is the value of the following expression?


eval('9'/'3')
a) '3' b) '3.0'
c) '9/3' d) Error

www.yogeshsir.com Page: Q8/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

Python MCQs
Boolean Expressions
1. Which of the following expressions is True?
a) 2>3 b) 3<4
c) 3!=3 d) 3>3

2. Which of the following expressions is True?


a) 2>3 and 3<4 b) 2>3 and 3>4
c) 2<3 and 3>4 d) 2<3 and 3<4

3. Which of the following expressions is True?


a) 2>3 or 3>4 b) 2<3 or 3<4
c) 2>3 or 2>2 d) 2!=2 or 2==3

4. Which of the following expressions is False?


a) bool(0) b) bool(9)
c) bool(-9) d) bool(9.0)

5. What will be the output of the following statement?


print(2 and 3)
a) 2 b) 3
c) True d) False

6. What will be the output of the following statement?


print(2 and 0)
a) 2 b) 0
c) True d) False

7. What will be the output of the following statement?


print(0 and 2)
a) 2 b) 0
c) True d) False

8. What will be the output of the following statement?


print(2 and -2)
a) 2 b) -2
c) True d) False

9. What will be the output of the following statement?


print(2 or 3)
a) 2 b) 3
c) True d) False

10. What will be the output of the following statement?


print(2 or 0)
a) 2 b) 0
c) True d) False

11. What will be the output of the following statement?


print(0 or 2)
a) 2 b) 0
c) True d) False

www.yogeshsir.com Page: Q9/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

12. What will be the output of the following statement?


print(2 or 2<3)
a) 2 b) 3
c) True d) False

13. What will be the output of the following statement?


print(2<3 or 2)
a) 2 b) 3
c) True d) False

14. What will be the output of the following statement?


print(2 and 2<3)
a) 2 b) 3
c) True d) False

15. What will be the output of the following statement?


print(2<3 and 2)
a) 2 b) 3
c) True d) False

16. What will be the output of the following statement?


print('a' and 'b')
a) a b) b
c) True d) False

17. What will be the output of the following statement?


print('' and 'b')
a) Empty string b) b
c) True d) False

18. What will be the output of the following statement?


print('a' and '')
a) a b) Empty string
c) True d) False

19. What will be the output of the following statement?


print('a' or 'b')
a) a b) b
c) True d) False

20. What will be the output of the following statement?


print('' or 'b')
a) Empty string b) b
c) True d) False

21. Which of the following expressions is True?


a) 'p'>='z' and 'p'>='a' b) 'p'>='z' or 'p'>='a'
c) 'a' != 'b' and 'a'>'b' d) 2>3 or 3>4

22. Which of the following expressions is True?


a) 'Amar'>'am' b) 'Am'>'Amar'
c) 'Amar'>'Amrita' d) 'Amrita'>'Amar'

www.yogeshsir.com Page: Q10/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

23. Which of the following expressions is True?


a) 'force'>'fort' b) 'Fort'>'Force'
c) 'Fort'>'Fortune' d) 'Fortune'>'Misfortune'

24. Which of the following expressions is True?


a) not '5'<='A' and 5<=9 b) not('5'<='A' and 5<=9)
c) '5'<='A' and 5<=9 d) not('5')<='A' and 5<=9

25. Which of the following expressions is True?


a) not 5 or not 5<4 b) not 5 and not 5<4
c) not 5 and (not 5)<4 d) not (5 and not 5) <4

26. Which of the following expressions is True?


a) 2>6<4 b) 2<6>4
c) 2>6>4 d) 2<6<4

27. Which of the following expressions is True?


a) 2>6<14 b) 2<6>14
c) 2>6>14 d) 2<6<14

28. Which of the following expressions is True?


a) 3>2>-2 b) 3<2<-2
c) 3>2<-2 d) 3<2>-2

29. Which of the following expressions is True?


a) 5<=11<=8 b) 5>=11>=8
c) 5>=11<=8 d) 5<=11>=8

30. Which of the following expressions is True?


a) False and False or not False b) False and False and not False
c) False and False or False d) False or False and not False

31. Which of the following expressions is True?


a) False or not (False and False) b) False or not False and False
c) False or not (False or True) d) False or False and True

32. Which of the following expressions is True?


a) True and False or not True b) True and not True or False
c) True and not False or not True d) not True and False or not True

33. Which of the following expression checks the condition: num1 is equal to num2
a) num1=num2 b) num1==num2
c) num1<=num2 d) num1>=num2

34. Which of the following expression checks the condition: num1 is a factor of num2
a) num1/num2==0 b) num1//num2==0
c) num1%num2==0 d) num2%num1==0

35. Which of the following expression checks the condition: num1 is a multiple of num2
a) num1/num2==0 b) num1//num2==0
c) num1%num2==0 d) num2%num1==0

www.yogeshsir.com Page: Q11/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

36. Which of the following expression checks the condition: num1 is a multiple of 3 or 5
a) num1%3 or 5==0 b) num1%3 or num1%5==0
c) num1%3==0 or num1%5==0 d) num1%15==0

37. Which of the following expression checks the condition: ch (an integer) is a digit
a) ch>='0' and ch<='9' b) '0'<=ch<='9'
c) 0<=ch<=9 d) ch>=0<=9

38. Which of the following expression checks the condition: ch (a single character string) is a digit?
a) ch>='0' or ch<='9' b) ch>=0 or ch<=9
c) ch>='0' and ch<='9' d) ch>=0 and ch<=9

39. Which of the following expression checks the condition:


PR is less than 10, or TE is less than 23, or PR+TE is less than 33
a) PR>10 or TE>23 or PR+TE>33 b) PR>10, TE>23, PR+TE>33
c) PR<10 or TE<23 or PR+TE<33 d) PR<10, TE<23, PR+TE<33

40. Which of the following expression checks the condition:


ENG is greater than 50, and at least one of MTH and PHY is greater than 60
a) ENG>50 and MTH>60 or PHY>60 b) ENG>50 and (MTH>60 or PHY>60)
c) (ENG>50 and MTH>60) or PHY>60 d) ENG>50 and MTH and PHY>60

41. Which of the following expression checks the condition:


For three given variables a, b, c, the sum of every pair of variables is greater than the third variable.
a) a+b>c or b+c>a or c+a>b b) a+b>c and b+c>a and c+a>b
c) a>b and b>c and c>a d) a+b+c>b+c, b+c>c+a, c+a>a+b

42. Which of the following expression checks the condition:


p is a two-digit integer and starts with 3 or it is a three-digit integer ending in 5
a) 30<p<39 or 100<p<999 and b) p>=10 and p<=99 and p//10==3 or
p%5==0 p%5==0
c) p//10==3 or p%5==0 and p<100 d) 30<=p<=39 or 100<=p<=999 and
or p<999 p%10==5

43. Which of the following expression checks the condition:


p is a two digit even number
a) p%2==0 and 10<=p<=99 b) p/2==0 and p>=10 and p<100
c) p%2==0 or p>=0 or p<=100 d) p%2==0 and p>10 and p<99

44. Which of the following expression checks the condition:


ch (a single character string) is a lowercase consonant.
a) p=='a-z' - 'aeiou' b) p=='a'<='z' or 'aeiou'
c) p in 'a-z' and p not in d) 'a'<=p<='z' and p not in
'aeiou’ 'aeiou'

45. What condition is being checked by the following Python expression:


v=='AEIOU'
a) v is a 5 character string b) v is a vowel
c) v is an uppercase vowel d) v is exactly equal to 'AEIOU'

www.yogeshsir.com Page: Q12/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

46. What condition is being checked by the following Python expression:


ch in 'aeiou' or p in '0123456789'
a) ch is a vowel and p is a digit b) ch is a lowercase vowel and p is a digit
c) ch is a lowercase vowel or p is a digit d) ch is a vowel or p is a digit

47. What condition is being checked by the following Python expression:


a>0 and b>0 and c>0 and a+b+c==180
a) a, b, c are positive numbers and their sum b) At least one of a, b, c is positive and their
is 180 sum is 180
c) a, b, c are non-negative numbers which d) The sum of a, b, and c is 180
add upto 180.

48. What condition is being checked by the following Python expression:


a>b>c or a<b<c
a) a, b, c are in ascending order b) a, b, c are in descending order
c) a, b, c are in either ascending or in d) None of these
descending order.

49. What condition is being checked by the following Python expression:


(x%y==0 or y%x==0) and x!=y
a) x is a factor of y or y is a multiple of x, b) x is a multiple of y, or y is a multiple of x,
and x is not equal to y. but x and y are unequal
c) x and y are unequal. d) None of these

50. The following condition will be True iff:


x%y==0 and y%x==0
a) x and y are 0 b) either x or y is 1
c) x and y are equal but not 0. d) x and y are unequal

www.yogeshsir.com Page: Q13/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

Python MCQs
range() and random
1. Which sequence of values will be generated by the function call range(5)?
a) 1,2,3,4,5 b) 0,1,2,3,4,5
c) 0,1,2,3,4 d) 1,2,3,4

2. Which sequence of values will be generated by the function call range(1,5)?


a) 1,2,3,4,5 b) 0,1,2,3,4,5
c) 0,1,2,3,4 d) 1,2,3,4

3. Which sequence of values will be generated by the function call range(2,10,3)?


a) 2,4,6,8 b) 2,5,8
c) 2,3,4 d) None of these

4. Which sequence of values will be generated by the function call range(10,1,-4)?


a) 10,6,2 b) 10,9,8,7,6, . . . ,-2,-3
c) 9, 5, 1 d) 30 15 10

5. Which sequence of values will be generated by the function call range(1,2)?


a) 1 b) 2
c) 1,2 d) None of these

6. Which of the following functions does not belong to random module?


a) random() b) randint()
c) randfloat() d) randrange()

7. Which of the following functions from random module generate floating point random numbers?
(Select two correct options)
a) random() b) randint()
c) uniform() d) randrange()

8. Which of the following function from random module does not take any argument?
a) random() b) randint()
c) uniform() d) randrange()

9. Which of the following function from random module accept exactly two arguments? (Select two
correct options)
a) random() b) randint()
c) uniform() d) randrange()

10. What is the minimum and maximum number of arguments accepted by randrange() function of
random module?
a) 0,2 b) 1,2
c) 0,3 d) 1,3

11. Which function of random module always generates a random number less than 1?
a) random() b) randint()
c) uniform() d) randrange()

www.yogeshsir.com Page: Q14/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

12. Identify the number which cannot be generated with the following code:
random.random()
a) 1 b) 0
c) 0.9643 d) 0.0012

13. Identify the number which cannot be generated with the following code:
random.randint(1,10)
a) 1 b) 5
c) 10 d) 1.5

14. Identify the number which cannot be generated with the following code:
random.randrange(1,10)
a) 1 b) 5
c) 10 d) 9

15. Identify the number which cannot be generated with the following code:
random.randrange(1,10,3)
a) 1 b) 3
c) 4 d) 7

16. Which of the following statement(s) is/are invalid?


a) random.randint(10) b) random.randrange(10)
c) random.randint(1, 10) d) random.randrange(1, 10)

17. Identify the output(s) which is/are not possible with the following code:
import random
a=random.randint(1,10); b=random.randrange(1,10)
print(a+b)
a) 1 b) 10
c) 11 d) 20

18. Identify the output(s) which is/are not possible with the following code:
import random
a=random.uniform(2,10); b=round(a,2)
print(b)
a) 1.23 b) 3.23
c) 5.31 d) 9.99

19. Identify the output(s) which is/are not possible with the following code:
import random
a=random.random()*100
b=round(a,2)
print(b)
a) 0.53 b) 1.23
c) 100.23 d) 9.99

20. Identify the output(s) which is/are not possible with the following code:
import random
a=random.uniform(3,30); b=int(a)%4; c=round(a,b)
print(c)
a) 4.5 b) 3.534
c) 24.0 d) 13.5

www.yogeshsir.com Page: Q15/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

21. Identify the output(s) which is/are not possible with the following code:
import random
a=random.randint(1,4)
for i in range(4):
print(i%a,end="@")
a) 0@0@0@0@ b) 0@1@0@1@
c) 0@1@2@0@ d) 0@1@1@0@

22. Identify the output(s) which is/are not possible with the following code:
import random
a=random.randrange(1,6,2)
for i in range(a):
print(i+a,end="#")
a) 3#4#5# b) 1#2#
c) 5#6#7#8#9# d) 1#

23. Identify the output(s) which is/are not possible with the following code:
import random
a=random.randint(1,5); b=random.randrange(a,a+5)
for i in range(a,b):
print(i,end="#")
a) 3#4#5# b) 1#2#
c) 5#6#7#8# d) 5#6#7

24. Identify the output(s) which is/are not possible with the following code:
import random
r='random'
a=random.randrange(4)
for i in range(4):
n=abs(a-i); print(r[n],end="@")
a) r@a@n@d@ b) a@n@d@o@
c) a@r@a@n@ d) d@n@a@r@

25. Identify the output(s) which is/are not possible with the following code:
r='random'
a=random.randrange(4)
for i in range(4):
n=a-i
print(r[n],end="@")
a) r@m@o@d@ b) a@r@m@o@
c) a@r@a@n@ d) d@n@a@r@

www.yogeshsir.com Page: Q16/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

Python MCQs
Lists
If nums=[5,3,1,8,6,7,4]
1. then what will be the value of the following expression?
len(nums)
a) 4 b) 5
c) 6 d) 7

2. If nums=[5,3,1,8,6,7,4] then what will be the value of the following expression?


nums[1]+nums[-1]
a) 7 b) 9
c) 10 d) 0

3. If nums=[5,3,1,8,6,7,4] then what will be the value of the following expression?


min(nums)
a) 5 b) 4
c) 1 d) -1

4. If nums=[5,3,1,8,6,7,4] then what will be the value of the following expression?


max(nums)-min(nums)
a) 1 b) 7
c) 5 d) 6

5. If nums=[5,3,1,8,6,7,4] then what will be the value of the following expression?


nums[3:]
a) [5,3,1] b) [1,8,6,7,4]
c) [8] d) [8,6,7,4]

6. If nums=[5,3,1,8,6,7,4] then what will be the value of the following expression?


nums[:3:]
a) [5,3,1] b) [5,3,1,8]
c) [5,3] d) [8,6,7,4]

7. If nums=[5,3,1,8,6,7,4] then what will be the value of the following expression?


nums[::3]
a) [5,3,1] b) [5,8,4]
c) [5,3] d) [3,1,8,6,7,4]

8. If nums=[5,3,1,8,6,7,4] then what will be the value of the following expression?


nums[-3:]
a) [4,7,6] b) [6,7,4]
c) [1,3,5] d) [8,1,3,5]

9. If nums=[5,3,1,8,6,7,4] then what will be the value of the following expression?


nums[:-3:]
a) [5,3,1,8] b) [5,3,1,8,6]
c) [6,7,4] d) [4,7,6]

10. If nums=[5,3,1,8,6,7,4] then what will be the value of the following expression?
nums[::-3]
a) [5,8] b) [5,8,4]
c) [4,8] d) [4,8,5]

www.yogeshsir.com Page: Q17/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

11. If nums=[5,3,1,8,6,7,4] then what will be the value of the following expression?
nums[1:4]
a) [5,6] b) [5,3,1,8,6]
c) [3,1,8] d) [ ]

12. If nums=[5,3,1,8,6,7,4]then what will be the value of the following expression?


nums[1::4]
a) [3,7] b) [5,3,1,8,6]
c) [3,1,8] d) [5,6 ]

13. If nums=[5,3,1,8,6,7,4] then what will be the value of the following expression?
nums[:1:4]
a) [ ] b) [5]
c) [3,1,8] d) [5,3,1,8,6]

14. If nums=[5,3,1,8,6,7,4] then what will be the value of the following expression?
nums[3:3:3]
a) [ ] b) [3]
c) [8] d) [ 8,6,7]

15. If nums=[5,3,1,8,6,7,4] then what will be the value of the following expression?
nums[1:2:3]
a) [5] b) [3]
c) [1] d) [ 3,1]

For tutorial slicing, scan the QR code:

16. If nums=[5,3,1,8,6,7,4]then what will be the value of the following expression?


nums[2:20:2]
a) [1,8,6,7,4] b) [3,1,8,6,7,4]
c) [ 1,6,4] d) [ ]

17. If nums=[5,3,1,8,6,7,4] then what will be the value of the following expression?
nums[-2:20:2]
a) [7,4] b) [6,4]
c) [6] d) [ 7]

18. If nums=[5,3,1,8,6,7,4] then what will be the value of the following expression?
nums[-2:7:2]
a) [7,4] b) [6,4]
c) [6] d) [ 7]

19. If nums=[5,3,1,8,6,7,4] then what will be the value of the following expression?
nums[-2:7:-2]
a) [7,8] b) [7,8,3]
c) [3,8] d) [ ]

www.yogeshsir.com Page: Q18/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

20. If nums=[5,3,1,8,6,7,4] then what will be the value of the following expression?
nums[-2:-7:-2]
a) [7,8] b) [7,8,3]
c) [3,8] d) [ ]

21. If nums=[5,3,1,8,6,7,4]then what will be the value of the following expression?


nums[-1:4]
a) [5,6] b) [5,3,1,8,6]
c) [3,1,8] d) [ ]

22. If nums=[5,3,1,8,6,7,4] then what will be the value of the following expression?
nums[1:-4]
a) [3,1] b) [3,1,8,6]
c) [3,1,8] d) [ ]

23. If nums=[5,3,1,8,6,7,4] then what will be the value of the following expression?
nums[-1:-4]
a) [5,6] b) [5,3,1,8,6]
c) [3,1,8] d) [ ]

24. If nums=[5,3,1,8,6,7,4] then what will be the value of the following expression?
nums[-1::-4]
a) [7] b) [7,3]
c) [4] d) [4,1 ]

25. If nums=[5,3,1,8,6,7,4] then what will be the value of the following expression?
nums[:-1:-4]
a) [4] b) [8]
c) [4,7,6] d) [ ]

26. Identify the list created with the following statement:


[alpha for alpha in range(7)]
a) [1,2,3,4,5,6,7] b) [0,1,2,3,4,5,6,7]
c) [1,2,3,4,5,6] d) [0,1,2,3,4,5,6]

27. Identify the list created with the following statement:


[k+2 for k in range(7)]
a) [2,3,4,5,6,7,8] b) [2,3,4,5,6,7]
c) [2,3,4,5,6] d) [0,1,2,3,4,5,6,7,8]

28. Identify the list created with the following statement:


[k*2 for k in range(2,7)]
a) [2,4,6,8,10,12] b) [4,6,8,10,12]
c) [4,6,8,10,12,14] d) [2,4,6,8,10,12,14]

29. Identify the list created with the following statement:


[k-2 for k in range(2,7)]
a) [0,1,2,3,4,5] b) [-2,-1,0,1,2,3]
c) [0,1,2,3,4] d) [7,6,5,4,3,2]

www.yogeshsir.com Page: Q19/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

30. Identify the list created with the following statement:


[2*k-1 for k in range(2,8,2)]
a) [2,6,10] b) [3,7,11]
c) [2,6,10,14] d) [3,7,11,15]

31. Identify the list created with the following statement:


[3]*4
a) [12] b) [3,3,3,3]
c) [3333] d) [4,4,4]

32. Identify the list created with the following statement:


[3]*len([3])
a) [ ] b) [3]
c) [9] d) [3,3,3

33. Identify the list created with the following statement:


[]*4
a) [ ] b) [4]
c) [ , , , ] d) Error

34. Identify the list created with the following statement:


[None]*4
a) [ ] b) [None]
c) [ None, None, None, None] d) Error

35. Identify the list created with the following statement:


[None]*3 + [4]*3
a) [ None,None,None,4,4,4] b) [None,None,None]
c) [4,4,4] d) Error

36. If A=[5,3,8] and B=[A,8,66,45], then which of the following expressions is/are True?
a) A in B b) [A] in B
c) B in A d) [B] in A

37. If A=[5,3,8] and B=[5,8,3] then which of the following expressions is/are True?
a) A == B b) A<B
c) A>B d) A<=B

38. If A=list('madhur') and B=list('Madhuri') then which of the following expressions is/are
True?
a) A < B b) A <= B
c) A > B d) A >= B

39. If A=list(range(5)) and B=list(range(1,4)) then which of the following expressions


is/are True?
a) A < B b) A <= B
c) A > B d) A >= B

40. If A=list(range(5)) and B=list(range(len(A))) then which of the following expressions


is/are True?
a) A == B b) A < B
c) A <= B d) A > B

www.yogeshsir.com Page: Q20/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

41. If A=[2,3,7,6,[3,5,8],5,7] then which of the following expressions is/are invalid?


a) A[1:][2:][1:][2:] b) A[1:][2:][1:][2]
c) A[1:][2:][1][2] d) A[1:][2][1][2]

42. If A=[2,3,7,6,[3,5,8],5,7] then which of the following expressions is/are invalid?


a) A[1] = 3 b) A[1] = [3]
c) A[1:]=3 d) A[1:]=[3]

43. If A=[5,3,2,8,7,9] then which of the following statements will insert (NOT Over right) 4 at A[0]?
a) A[0] = 4 b) A[0].insert(4)
c) A.insert(0,4) d) A.insert(4,0)

44. If A=[5,3,2,8,7,9] then which of the following statements will increase the length of A?
a) A[0] = 0 b) A[0]=[0]
c) A[0]=0, d) A[:0]=0,

45. If A=[5,3,2,8,7,9] then which of the following statements will decrease the length of A?
a) A[5:] = [5,6] b) A[:5]=[5,6]
c) A[::5]=[5,6] d) A[5]=[5,6]

www.yogeshsir.com Page: Q21/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

Python MCQs
Tuples
1. Which of the following statements will create a tuple?
a) a=1 b) a=1,
c) a=(1) d) a=tuple(1)

2. Which of the following statements will not create a tuple?


a) a=1,2,3 b) b=([1,2,3])
c) c=(1,2,3) d) d=tuple('tuple')

3. Which variable will not represent a tuple after execution of the following code snippet?
a=1,2,3,4,5,6
b=a[1],
c,d=a[2],a[3]
e=a[4],a[5]
a) a b) b
c) c d) e

4. Which of the following statements is/are correct?


a) Both tuples and lists are immutable b) Tuples are immutable and lists are
mutable
c) Both tuples and lists are mutable d) Tuples are mutable and lists are
immutable

5. Which of the following statements is/are correct?


a) We can concatenate tuple to tuple. b) We can concatenate list to tuple.
c) We can concatenate tuple to list. d) We can concatenate list to list

6. If A=tuple([3,6,7]); B=list(A) then which of the following expressions is/are valid?


a) A+=B b) B+=A
c) A+B d) B+A

To understand how += is different for lists and tuples, scan the QR code:

7. If A=1,2,3,4,5
then which of the following statements is/are valid?
a) A[1]=1 b) A+=1
c) A.pop() d) A=A[1:]

8. If a=('ant','bat','cat') then which of the following statements is/are correct?


a) a.count('rat') b) a.append('cat')
c) a+=('dog') d) a+=('dog',)

9. If a=(1,2); b= ['a','b'] then which of the following statements is/are valid?


a) c=a+[b] b) d=[a]+[b]
c) e=a+(b) d) f=a+(b,)

www.yogeshsir.com Page: Q22/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

10. If a=(1,2,3,[4,5,6],7,8) then which of the following statements is/are valid?


a) len(a[2]) b) a[3]=5
c) a[3][1]=2 d) len(a[3])=3

11. If a=[1,2,3,(4,5,6),7,8] then which of the following statements is/are valid?


a) len(a[2]) b) a[3]=5
c) a[3][1]=2 d) len(a[3])=3

12. What is the length of A as defined below:


A='beautiful',
a) 1 b) 2
c) 9 d) The statement is not correct

13. What is the length of A as defined below:


A=('beautiful',)
a) 1 b) 2
c) 9 d) The statement is not correct

14. What is the length of A as defined below:


A=tuple('beautiful')
a) 1 b) 2
c) 9 d) The statement is not correct

15. What is the length of A as defined below:


A=tuple('beautiful',)
a) 1 b) 2
c) 9 d) The statement is not correct

16. What is the length of A as defined below:


A=tuple('beautiful'),
a) 1 b) 2
c) 9 d) The statement is not correct

17. What is the length of A as defined below:


A=tuple(range(5))
a) 1 b) 2
c) 5 d) The statement is not correct

18. What is the length of A as defined below:


A=tuple(range(5)),
a) 1 b) 2
c) 5 d) The statement is not correct

19. What is the length of A as defined below:


A=tuple(3,5,8)
a) 1 b) 2
c) 3 d) The statement is not correct

20. What is the length of A as defined below:


A=tuple('hello'),list('Hello')
a) 1 b) 2
c) 10 d) The statement is not correct

www.yogeshsir.com Page: Q23/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

Python MCQs
Strings
1. Which of the following is/are invalid string(s) in Python?
a) string b) 'string'
c) "string" d) """string"""

2. Which of the following is/are invalid string(s) in Python?


a) "computer scie\nce" b) 'Comp. Sc"
c) '''Computer Sc''' d) """Computer
Science"""

3. Given s="December" then which of the following expression(s) is/are valid?


a) s[0]='d' b) len(s)=8
c) s+=2023 d) s+="2023"

4. Given s="December" then which of the following expressions will be True?


a) s.isupper() b) s.islower()
c) s.isalpha() d) s.isalnum()

5. Given s="DECEMBER 2023" then which of the following expressions will be True?
a) s.isupper() b) s.islower()
c) s.isalpha() d) s.isalnum()

6. Given s="april2023" then which of the following expressions will be True?


a) str.isupper(s) b) str.islower(s)
c) str.isalpha(s) d) str.isalnum(s)

7. Given s="april@2023" then which of the following expressions will be True?


a) str.isupper(s) b) str.islower(s)
c) str.isalpha(s) d) str.isalnum(s)

8. Given s="2023" then which of the following expressions will be True?


a) str.isupper(s) b) str.islower(s)
c) str.isalpha(s) d) str.isalnum(s)

9. what will be the output of the statement:


print("gOOd DeedS".capitalize())
a) Good deeds b) Good Deeds
c) GOOD DEEDS d) GOOD deeds

10. what will be the output of the statement:


print("gOOd DeedS".title())
a) Good deeds b) Good Deeds
c) GOOD DEEDS d) GOOD deeds

11. If s='an apple';b=s.index('a') then what will be the value of b?


a) 0 b) 1
c) 2 d) 3

12. If s='an apple';b=s.index('a',2) then what will be the value of b?


a) 0 b) 1
c) 2 d) 3

www.yogeshsir.com Page: Q24/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

13. If s='an apple' then which of the following expressions is/are invalid?
a) list(s) b) tuple(s)
c) str(s) d) None of these

14. If s='an apple';b=s.split() then what is the data type of b?


a) list b) str
c) tuple d) None of these

15. If a='an apple';b=a.count(a) then what will be the value of b?


a) 0 b) 1
c) 2 d) 3

16. If a='an apple';b=a.count('a') then what will be the value of b?


a) 0 b) 1
c) 2 d) 3

17. If s='an apple' then which of the following is/are an invalid expression(s)?
a) s[0] b) s[0:]
c) s[:0] d) s[0:0:0]

18. If s='an apple' then which of the following expressions will represent an empty string?
a) s[0] b) s[0:]
c) s[:0] d) s[0:0:0]

19. If s='mathematics' then which of the following will return a list of three elements?
a) s.split() b) s.split('3')
c) s.split('e') d) s.split('m')

20. If s='mathematics' then which of the following will represent a list of two elements?
a) s.split('a',0) b) s.split('a',1)
c) s.split('a',2) d) s.split('a',3)

21. If s='mathematics'.partition('xyz') then what is the data type of s?


a) list b) str
c) tuple d) None of these

22. If s='mathematics'.partition('algebra') then what is the length of s?


a) 0 b) 1
c) 2 d) 3

23. If s='mathematics' then which of the following expressions is/are True?


a) s[1]==s[-2] b) s[3]==s[-4]
c) s[5]==s[-6] d) s[7]==s[-8]

24. If s='mathematics' then which of the following expressions will raise an error?
a) s.find('book') b) s.index('book')
c) s.count('book') d) s.split('book')

25. If s='mathematics' then which of the following expressions will raise an error?
a) s.partition() b) s.partition('book')
c) s.split() d) s.index(s)

www.yogeshsir.com Page: Q25/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

Python MCQs
Dictionaries
Which
1. of the following statements is/are correct?
a) Dictionaries are immutable b) A dictionary can have all keys and no
values
c) Keys of a dictionary must be of the same d) Keys of a dictionary must be of immutable
type. types.

2. Which of the following cannot be a key of a dictionary?


a) 5 b) '5'
c) [5] d) (5,)

3. The values in a dictionary:


a) must be strings b) should be of mutable type only
c) should be of immutable type only d) can be of any type

4. Which of the following statements is/are correct?


a) Dictionary elements can be accessed b) Dictionary elements can be accessed
using index as in a list. using keys only.
c) Dictionary elements can be accessed d) Dictionary elements can be accessed
using values only. using index, keys, and values.

5. Which of the following statements is/are correct?


a) A dictionary can have two same keys with b) A dictionary can have two different keys
different values with same values.
c) A dictionary can have two same keys with d) A dictionary can have two different keys
same values with different values

6. Which of the following statements will create a dictionary?


a) {'a':1,'b':2} b) ('a':1,'b':2)
c) ['a':1,'b':2] d) 'a':1,'b':2

7. Which of the following methods takes any iterable as a parameter?


a) update() b) clear()
c) key() d) fromkeys()

8. Which of the following statements will create a dictionary?


a) dict.fromkeys([1,2,3]) b) dict.fromkeys([1,2,3],'abc')
c) dict.fromkeys('abc',[1,2,3]) d) All of these

9. Which of the following statements will create a dictionary?


a) dict.fromkeys(123) b) dict.fromkeys(1,2,3)
c) dict.fromkeys('123':'abc') d) dict.fromkeys('123','abc')

10. If d={1:"One",2:"Two"} , then what is the value of len(d)?


a) 1 b) 2
c) 3 d) 4

11. If d={1:"One",2:"Two"} , then Which of the following statements will create a dictionary?
a) dict.fromkeys(d) b) dict.fromkeys(d.keys())
c) dict.fromkeys(d.values()) d) All of these

www.yogeshsir.com Page: Q26/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

12. If d={1:"One",2:"Two"} , then Which of the following expressions is/are True?


a) 1 in d b) 2 in d
c) "One" in d d) "Two" in d

13. If d={1:"One",2:"Two"} , then Which of the following expressions will raise an exception?
a) del d[1] b) del d["Two"]
c) del d d) None of these

14. Which of the following methods will delete the last element from a dictionary?
a) pop() b) popitem()
c) remove() d) clear()

15. If a={1:2,3:4,5:6}.popitem() , then what is the value of a?


a) {1:2,3:4,5:6} b) {1:2,3:4}
c) (5, 6) d) None of these

16. Which of the following methods will raise an exception if no argument is given?
a) popitem() b) clear()
c) copy() d) setdefault()

17. Which of the following dictionary methods always returns a tuple from a non-empty dictionary?
a) setdefault() b) get()
c) pop() d) popitem()

18. Which of the following is not a dictionary method?


a) del() b) copy()
c) values() d) items()

19. Which of the following statements is invalid?


a) {}.update({}) b) {}.update({1:2})
c) {1:2}.update({}) d) None of these

20. If d is an empty dictionary then which of the following expressions will raise an exception?
a) d.get(5) b) d.setdefault(5)
c) d.pop() d) del d

www.yogeshsir.com Page: Q27/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

Python MCQs
Functions
1. Which keyword is used to define a function?
a) def b) define
c) func d) function

2. Which of the following items is/are optional in a function header?


a) function name b) parameters
c) keyword def d) None of these

3. Which of the following items is/are mandatory in a function header?


a) function name b) parameters
c) keyword def d) None of these

4. A function without any return statement will return:


a) An arbitrary value b) 0
c) 'None' d) None

5. How many return statements can a function have?


a) 0 b) 1
c) 2 d) as many as needed

6. Which of the following statements is/are true?


a) default arguments should follow non- b) non-default arguments should follow
default arguments default arguments
c) A default argument can be between two d) A non-default argument can be between
non-default arguments two default arguments

7. Which of the following statements is/are true?


a) positional arguments should follow b) keyword arguments should follow
keyword arguments positional arguments
c) A keyword argument can be between two d) A positional argument can be between two
positional arguments keyword arguments

8. Which of the following statements is/are correct?


a) formal parameters get their values from b) actual parameters get their values from
corresponding actual parameters corresponding formal parameters
c) The number of actual parameters must d) None of these
always be equal to the number of formal
parameters

9. Which of the following function headers is/are invalid?


a) def test(a=0,b): b) def test(a=0,b=2):
c) def test(b=0,a=2): d) def test(a,2):

10. Which of the function calls is/are invalid for the following function:
def test(a,b=0):
print(a-b)
a) test(5) b) test(5,3)
c) test(b=5,a=3) d) test(a=4,7)

www.yogeshsir.com Page: Q28/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

11. Which of the function calls is/are invalid for the following function:
def test(a=10,b=20):
pass
a) test(5) b) test(5,3)
c) test(b=5,a=3) d) test(a=4,7)

12. Which of the function calls is/are valid for the following function:
def test(a,b,c):
print(a+b+c)
a) test(5,c=4,6) b) test(5,b=4,6)
c) test(a=5,b=4,6) d) test(4,5,c=4)

13. Observe the following code:


def test(a,b,c):
print(a+b+c)
test(4,5,c=6)
This code has:
a) Two positional arguments and one b) Two keyword arguments and one
keyword argument positional argument
c) Two positional arguments and one default d) Two default arguments and one keyword
argument argument

14. Which of the following statements is/are correct?


a) All variables defined inside a function are b) Global variables can be defined inside a
local variables. function.
c) Keyword global can be used outside a d) Keyword global can be used inside a
function also. function only.

15. Pick the correct output generated by the following code:


def function1():
pass
print(type(function1))
a) <class 'int'> b) <class 'NoneType'>
c) <class 'function'> d) <class 'list'>

16. Pick the correct output generated by the following code:


def function1():
pass
print(type(function1()))
a) <class 'int'> b) <class 'NoneType'>
c) <class 'function'> d) <class 'list'>

17. Pick the correct output generated by the following code:


def function2():
return
print(type(function2()))
a) <class 'int'> b) <class 'NoneType'>
c) <class 'function'> d) <class 'list'>

www.yogeshsir.com Page: Q29/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

18. Pick the correct output generated by the following code:


def function1():
return 1
print(type(function1()))
a) <class 'int'> b) <class 'NoneType'>
c) <class 'function'> d) <class 'list'>

19. Pick the correct output generated by the following code:


def function1():
return [1]
print(type(function1()))
a) <class 'int'> b) <class 'NoneType'>
c) <class 'list'> d) <class 'tuple'>

20. Pick the correct output generated by the following code:


def function1():
return 1,2
print(type(function1()))
a) <class 'int'> b) <class 'NoneType'>
c) <class 'list'> d) <class 'tuple'>

www.yogeshsir.com Page: Q30/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

Python MCQs
Text Files
1. A text file contains:
a) Lines of text b) Lines of formatted text
c) Only one line of text d) Text and images

2. A text file can be created using:


a) Any text editor b) A Python program
c) Any word processor d) All of the these

3. A text file can be meaningfully read using:


a) Any text editor b) A Python program
c) Any word processor d) All of the these

4. A text file created using a text editor can be processed using:


a) Any text editor b) A Python program
c) Any word processor d) All of the these

5. A text file created using a Python program can be processed using:


a) Any text editor b) A Python program
c) Any word processor d) All of the these

6. The extension of a text file must be:


a) .py b) .txt
c) .dat d) It can be any extension

7. Each line of a text file is terminated by:


a) '.' b) None
c) '\n' d) Any random character

8. Which of the following specify (there may be multiple correct options) read only mode for a text
file?
a) 'r' b) 'rt'
c) 'rb' d) 'r+'

9. The file opening mode 'rt' is the same as (there may be multiple correct options):
a) 'r' b) 'tr'
c) 'r+' d) 'rb'

10. If a text file is opened in 'r+' mode, then:


a) Data can only be read from the file b) Data can only be written to the file
c) Data can be read from and written to the d) None of these
file

11. What is the data type of the argument of write() method of file object?
a) int b) float
c) str d) any iterable

12. The writelines() method of file object accepts any iterable as a parameter. What should be
the data type of the elements of this iterable?
a) int b) float
c) str d) any type

www.yogeshsir.com Page: Q31/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

For a quick understanding of iterables, scan the QR code:

13. A text file 'sample.txt' contains the text 'Beep' only. What will be the contents of the file after
execution of the following code:
f=open("sample.txt",'w')
f.write("D")
f.close()
a) D b) Deep
c) BeepD d) DBeep

14. A text file 'sample.txt' contains the text 'Beep' only. What will be the contents of the file after
execution of the following code:
f=open("sample.txt",'a')
f.write("D")
f.close()
a) D b) Deep
c) BeepD d) DBeep

15. A text file 'sample.txt' contains the text 'Beep' only. What will be the contents of the file after
execution of the following code:
f=open("sample.txt",'w+')
f.write("D")
f.close()
a) D b) Deep
c) BeepD d) DBeep

16. A text file 'sample.txt' contains the text 'Beep' only. What will be the contents of the file after
execution of the following code:
f=open("sample.txt",'a+')
f.write("D")
f.close()
a) D b) Deep
c) BeepD d) DBeep

17. A text file 'sample.txt' contains the text 'Beep' only. What will be the contents of the file after
execution of the following code:
f=open("sample.txt",'r+')
f.write("D")
f.close()
a) D b) Deep
c) BeepD d) DBeep

www.yogeshsir.com Page: Q32/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

18. A text file 'sample.txt' contains the text 'Beep' only. What will be the contents of the file after
execution of the following code:
f=open("sample.txt",'a')
f.seek(0)
f.write("D")
f.close()
a) D b) Deep
c) BeepD d) DBeep

19. A text file 'sample.txt' contains the text 'Beep' only. What will be the contents of the file after
execution of the following code:
f=open("sample.txt",'r+')
f.seek(2)
f.write("D")
f.close()
a) D b) BeDp
c) BDep d) DBeep

20. If a text file 'sample.txt' contains multiple lines of text, what will be the data type of variable txt
after execution of the following code:
f=open("sample.txt",'rt')
txt = f.read()
print(txt)
a) int b) float
c) str d) list

21. If a text file 'sample.txt' contains multiple lines of text, what will be the output of the following code:
f=open("sample.txt",'rt')
data = f.read()
print(data)
a) first character of the file b) first word of the file
c) first line of the file d) Entire file content

22. If a text file 'sample.txt' contains multiple lines of text, what will be the output of the following code:
f=open("sample.txt",'rt')
data = f.read(5)
print(data)
a) 5 b) first 5 characters of the file
c) 5 character of the file
th
d) Entire file content 5 times

23. If a text file 'sample.txt' contains multiple lines of text, what will be the output of the following code:
f=open("sample.txt",'rt')
f.seek(5)
data = f.read(1)
print(data)
a) first 5 characters of the file b) first 6 characters of the file
c) 5th character of the file d) 6th character of the file

www.yogeshsir.com Page: Q33/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

24. Pick the correct option to be filled in the given code so as to read data from 8th character to 20th
character from the file:
f=open("sample.txt",'rt')
f.seek(7)
data = f.read(__)
a) 12 b) 13
c) 14 d) 20

25. If a text file 'sample.txt' contains multiple lines of text, what will be the data type of variable txt
after execution of the following code:
f=open("sample.txt",'rt')
txt = f.readline()
a) int b) float
c) str d) list

26. If a text file 'sample.txt' contains multiple lines of text, what will be the output of the following code:
f =open("sample.txt",'rt')
data = f.readline()
print(data)
a) first character of the file b) first word of the file
c) first line of the file d) Entire file content

27. If a text file 'sample.txt' contains multiple lines of text, what will be the output of the following code:
f=open("sample.txt",'rt')
data = f.readline(50)
print(data)
a) First line of the file b) First 50 characters of the file
c) First 50 lines of the file d) First 50 characters or first line, whichever
is smaller.

28. If a text file 'sample.txt' contains multiple lines of text, what will be the output of the following code:
f=open("sample.txt",'rt')
for i in range(5):
f.readline()
print(f.readline())
a) first 5 lines of the file b) first 6 lines of the file
c) 5 line of the file
th
d) 6th line of the file

29. If a text file 'sample.txt' contains multiple lines of text, what will be the output of the following code:
f=open("sample.txt",'r')
for i in range(5):
print(f.readline())
a) first 5 lines of the file b) first 6 lines of the file
c) 5 line of the file
th
d) 6th line of the file

30. If a text file 'sample.txt' contains 10 lines of text, what will be the data type of variable txt after
execution of the following code:
f=open("sample.txt",'rt')
txt = f.readlines()
a) int b) float
c) str d) list

www.yogeshsir.com Page: Q34/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

31. If a text file 'sample.txt' contains 10 lines of text, what will be the output of the following code:
f=open("sample.txt",'r')
data=f.readlines()
print(data[3])
a) 3rd character of the file b) 3rd line of the file
c) 4th character of the file d) 4th line of the file

32. If a text file 'sample.txt' contains 10 lines of text, what will be the output of the following code:
f=open("sample.txt",'r')
data=f.readlines()
print(data[-1])
a) Last character of the file b) Last line of the file
c) '\n' d) A blank line

33. If a text file 'try.txt' contains 5 lines of text & lengths of these lines are 10, 15, 10, 15, 20
respectively, what will be the output of the following code:
f=open("sample.txt",'rt')
data = f.readlines(40)
for s in data:
print(s.strip())
a) Entire file content b) First 40 characters of the file
c) First 4 lines of the file d) First 3 lines of the file

34. How many arguments does seek() accept for a text file?
a) 0 or 1 b) 1 or 2
c) Exactly 1 d) Exactly 2

35. Which of the statements is/are incorrect for the following file object:
f=open("sample.txt")
a) f.seek(5) b) f.seek(5,0)
c) f.seek(0,1) d) f.seek(5,1)

36. How many arguments does tell() accept for a text file?
a) 0 b) 1
c) 2 d) 1 or 2

37. What will be the contents of the file 'sample.txt' after execution of the following script:
f=open("sample.txt",'w')
f.write('Seven')
a) Seven b) The file will be empty as the file is not
closed
c) The code has syntax error d) The code will raise an exception.

38. What will be the output of the following code?


f=open("sample.txt",'w')
f.write('Seven')
f=open("sample.txt",'r')
print(f.read())
f.close()
a) Seven b) Blank line
c) The code has a syntax error d) The code will raise an exception.

www.yogeshsir.com Page: Q35/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

39. What will be the output of the following code?


f=open("sample.txt",'w')
f.seek(7)
f.write('seven')
f.close()
f=open("sample.txt",'r')
data=f.read()
print(len(data))
f.close()
a) 5 b) 7
c) 12 d) The code will raise an exception.

40. What will be the output of the following code?


f=open("sample.txt",'w')
f.write('seven')
f1=open("sample.txt",'r')
print(f1.read())
f1.close()
a) Seven b) Blank line
c) The code has syntax error d) The code will raise an exception.

www.yogeshsir.com Page: Q36/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

Python MCQs
CSV Files
1. CSV stands for:
a) Comma Spaced Values b) Comma Separated Values
c) Completely Separated Values d) Common Separated Values

2. Default delimiter for csv files is:


a) Comma b) Tab
c) Space d) Semi-colon

3. Which character can work as a delimiter for csv files?


a) Comma only b) Comma and Tab
c) Comma, Tab, and Space d) Any character

4. We can manage (create/read/update) csv files using:


a) A text editor b) A Python program
c) A spreadsheet application d) All of the these

5. A csv file, created using a Python program, can be processed by:


a) A text editor b) A Python program
c) A spreadsheet application d) All of the these

6. The extension of a csv file must be:


a) .txt b) .csv
c) .dat d) It can be any extension

7. File opening modes for csv files are:


a) same as those for text files b) same as those for binary files
c) different from text files and binary files d) a mix of text files and binary files

8. Which Python module is used to process CSV files?


a) random b) pickle
c) csv d) reader

9. Which method of writer object allows writing of multiple records in a csv file?
a) writerow() b) writerows()
c) writeline() d) writelines()

10. The contents of a text file "sample.txt" are shown below:


1,2,3,4
'a','b','c'
5,2,'aim','peace'
'to','be','or','not',2,'b'
Pick the correct statement(s) w.r.t. this file:
a) It can be treated as a csv file b) It cannot be treated as a csv file since it is
a text file.
c) It cannot be treated as a csv file as it d) It cannot be treated as a csv file as it
contains mixed data types in some lines. contains different number of elements in
different lines.

www.yogeshsir.com Page: Q37/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

11. The contents of a csv file "sample.csv" are shown below:


sno,name,age
1,Amit,12
2,Mohini,13
Pick the correct statement(s) w.r.t. this file:
a) It can be treated as a text file. b) It cannot be treated as a text file as it is a
csv file.
c) It cannot be opened in a text editor as it is d) Python will raise an error while reading
a csv file. data from this file as the strings are not
enclosed within quotation marks.

12. The contents of a text file "sample.txt" are:


sno$name$age
1$Amit$12
2$Mohini$13
Below is a script to read the contents of this file:
import csv
f=open("sample.txt")
r=csv.reader(f)
for rec in r:
print(rec)
Pick the correct statement(s) w.r.t. the given contents and code:
a) rec is a list of one element b) rec is a list of three elements
c) rec is a nested list of one element d) rec is a nested list of three element

13. The contents of a text file "sample.txt" are:


sno$name$age
1$Amit$12
2$Mohini$13
Below is a script to read the contents of this file:
import csv
f import csv
f=open("sample.txt")
r=csv.reader(f, delimiter='$')
for rec in r:
print(rec)
Pick the correct statement(s) w.r.t. the given contents and code:
a) rec is a list of one element b) rec is a list of three elements
c) rec is a nested list of one element d) rec is a nested list of three element

14. The following code is raising an exception::


import csv
f=open("sample.csv",'w',newline='')
w=csv.writer(f)
row=[1,2,3]
w.writerows(row)
To correct the code, we have to:
a) close the file at the end b) use writerow() instead of
writerows()
c) make row a tuple instead of list d) import pickle

www.yogeshsir.com Page: Q38/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

15. The following code is inserting an unwanted blank line after every row in the file sample.csv::
import csv
with open("sample.csv",'w') as f:
w=csv.writer(f)
data=[['a','b','c'],[1,2,3]]
w.writerows(data)
To correct this, we have to:
a) close the file at the end b) use keyword argument newline='' or
newline='\n' with the open() function
c) make data a tuple instead of list d) use '\n' as the last element of each record

For tutorial on csv Files, scan the QR code:

www.yogeshsir.com Page: Q39/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

Python MCQs
Binary Files
What
1. kind of data can be stored in a Binary file?
a) Numbers only b) Strings only
c) lists only d) Any kind of data

2. The extension of a binary file must be:


a) .txt b) .bin
c) .dat d) It can be any extension

3. A binary file, created using a Python program, can be processed by:


a) Any text editor b) A Python program
c) Any word processor d) All of the these

4. Which module in Python is used to process (read/write) binary files?


a) pickle b) load
c) dump d) csv

5. Select the correct statement(s) in context of pickle module (There may be multiple answers):
a) load() writes data into a binary file b) dump() writes data into a binary file
c) load() reads data from a binary file d) dump() reads data from a binary file

6. The method pickle.load() always reads:


a) one record from the file b) all the records from the file
c) first record from the file d) None of these

7. Pickling (serialization) is the process of:


a) converting a Python object into byte b) converting a byte stream into a Python
stream object
c) mixing different data objects into one d) using pickle module in a script

8. Unpickling (deserialization) is the process of:


a) converting a Python object into byte b) converting a byte stream into a Python
stream object
c) mixing different data objects into one d) using pickle module in a script

9. Which of the following specifies the read-only mode for a binary file?
a) 'r' b) 'rb'
c) 'r+' d) 'rb+'

10. Which of the following modes will open a binary file in read-write mode without deleting the
existing file contents?
a) 'rb+' b) 'rw'
c) 'rw+' d) 'wb+'

11. Which of the following modes will create a binary file and open it in read-write mode?
a) 'rb+' b) 'rw'
c) 'rw+' d) 'wb+'

www.yogeshsir.com Page: Q40/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

12. Which of the following commands will open the binary file "d:\emp\log\temp.dat" in read-write
mode without deleting the existing file content?
a) open("d:\emp\log\temp.dat", "rb")
b) open("d:\emp\log\temp.dat", "rw")
c) open("d:\\emp\\log\\temp.dat", "r+b")
d) open("d:\\emp\\log\\temp.dat", "rw+")

13. Which of the following commands will open the binary file "d:\emp\log\temp.dat" in read-only
mode?
a) open(r"d:\emp\log\temp.dat", "rb")
b) open(r"d:\emp\log\temp.dat", "rw")
c) open(r"d:\\emp\\log\\temp.dat", "rb+")
d) open("d:\\emp\\log\\temp.dat", "rw+")

14. Which of the following commands will raise an exception if the binary file "books.dat" does not
exist?
a) open("books.dat","rb") b) open("books.dat",'ab')
c) open("books.dat",'wb') d) open("books.dat",'w')

15. Pick the statement which correctly differentiates between 'wb+' and 'ab+' modes of opening an
already existing binary file:
a) 'wb+' deletes the existing data from the b) 'wb+' does not delete the existing data
file whereas 'ab+' does not delete. from the file whereas 'ab+' deletes.
c) 'wb+' will raise an exception because the d) There is no difference
file already exists whereas 'ab+' will not
raise any exception.

16. Pick the statement which correctly differentiates between 'rb' and 'rb+' modes of opening an
already existing binary file:
a) In 'rb' mode we can read only one record b) In 'rb' mode we can only read data from
at a time, whereas in 'rb+' we can read the file, whereas in 'rb+' we can read as
multiple records at a time. well as write data in the file.
c) In 'rb' mode the file pointer starts at 0, d) 'rb' mode does not allow seek(),
whereas in 'rb+' the file pointer starts whereas 'rb+' allows seek() on the
from the end of the file. file.

17. Select the correct statement to write a list, named Data, into a binary file represented by file object
outfile.
a) pickle.write(Data,outfile) b) pickle.write(outfile,Data)
c) pickle.dump(Data,outfile) d) pickle.dump(outfile,Data)

18. If the statement pickle.dump(one, two) is executed successfully, then:


a) data one will be written into the file two b) data two will be written into the file one
c) data one will be read from file two d) data two will be read from file one

19. If the statement rec=pickle.load(fo) is executed successfully, it will:


a) read all the records from the file fo b) read all the records from the file rec
c) read one record from the file fo d) read one record from the file rec

www.yogeshsir.com Page: Q41/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

20. If the statement rec=pickle.load(fo) is executed successfully, it will read:


a) first record from the file b) last record from the file
c) current record (indicated by file pointer) d) all records from the file
from the file

21. The statement b=pickle.load(f) will execute successfully, if:


a) the file has been opened in 'r' mode b) the file has been opened in 'rb' mode
c) the file has been opened in 'w' mode d) the file has been opened in 'wb' mode.

22. If f is the file object representing a binary file opened in 'rb' mode, which of the following
statements will set the file pointer to the end of the file?
a) f.seek(-1) b) f.seek(0,0)
c) f.seek(0,1) d) f.seek(0,2)

23. If f is the file object representing a binary file opened in 'rb+' mode, then which of the following
statements will set the file pointer to 12 bytes before the current position?
a) f.seek(-12) b) f.seek(-12,0)
c) f.seek(-12,1) d) f.seek(-12,2)

24. If f is the file object representing a binary file opened in 'wb' mode, then which of the following
statements will set the file pointer to 12 (There may be multiple answers)?
a) f.seek(12) b) f.seek(12,0)
c) f.seek(12,1) d) f.seek(12,2)

25. If f is the file object representing a binary file opened in 'ab+' mode, which of the following
statements is/are correct in this context?
a) seek() method will raise an exception b) new data will be written at the end of the
file irrespective of the current value of file
pointer.
c) seek() method can be invoked only with d) None of the above
one argument.

www.yogeshsir.com Page: Q42/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

Python MCQs
Exception Handling
1. In Python, an exception is a:
a) syntax error b) run-time error
c) logical error d) break statement in a loop

2. An exception causes:
a) abnormal termination of the script b) an infinite loop
c) an incorrect result d) closing of the IDE

3. In Python, exceptions can be handled using:


a) try-except statement b) if-else statement
c) loops d) for loop only

4. Which of the following is optional in a try-except statement?


a) try clause b) except clause
c) finally clause d) None of these

5. A try-except statement can have:


a) multiple try clauses b) multiple except clauses
c) multiple finally clauses d) Exactly one of try, except, and finally
clauses

6. Which of the following causes NameError exception?


a) usage of an undefined variable b) inappropriate function names
c) an invalid expression d) incorrect names of variables

7. Which of the following will raise ValueError exception?


a) '2'*'3' b) math.sqrt(-8)
c) (-8)**0.5 d) 8/0

8. What exception will be raised if user enters 1.2 in response to the following statement:
a=int(input("Enter an integer: "))
a) NameError b) TypeError
c) ValueError d) DomainError

9. What exception will be raised by the following statement:


a=5%(5//8.0)
a) ZeroDivisionError b) TypeError
c) ValueError d) NameError

10. What exception will be raised if a script tries to read data from a binary file beyond the end of file?
a) FileError b) EOFError
c) ReadError d) BEOFError

11. What exception will be raised by the following statement:


six='6'//0
a) ZeroDivisionError b) TypeError
c) ValueError d) NameError

www.yogeshsir.com Page: Q43/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

12. What exception will be raised by the following statement:


a,b=5
a) ZeroDivisionError b) TypeError
c) ValueError d) NameError

13. Which of the following statements will raise SyntaxError exception?


a) eval(12+3) b) eval(12+a)
c) eval('12'+'*3') d) eval('12'+'a')

14. Which of the following statements will not raise any exception?
a) a=3/(6-6) b) a=2,3
c) a='3'%'2' d) a=eval(2+3)

15. Which of the following statements will raise an exception?


a) int(12.8) b) int(12+3.2)
c) int(12+8) d) int('12.8')

www.yogeshsir.com Page: Q44/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

Python Assertion Reasoning based Questions


Following are Assertion(A) and Reasoning(R) based questions. Mark the correct choice as:
(A) Both A and R are true and R is the correct explanation for A
(B) Both A and R are true and R is not the correct explanation for A
(C) A is True but R is False
(D) A is False but R is True
1. Assertion (A): print is an invalid variable name.
Reasoning (R): Keywords cannot be used as variable names.
2. Assertion (A): if is an invalid variable name
Reasoning (R): keywords cannot be used as variable names
3. Assertion (A): 5Trillion is a valid variable name
Reasoning (R): 5Trillion is not a keyword
4. Assertion (A): x-y is a valid variable name
Reasoning (R): A variable name can start with an alphabet
5. Assertion (A): An inbuilt identifier can be redefined.
Reasoning (R): An inbuilt identifier is not a keyword.
6. Assertion (A): An inbuilt identifier cannot be redefined
Reasoning (R): Keywords cannot be redefined
7. Assertion (A): eval(5*4) is an invalid expression
Reasoning (R): eval() takes only a string as a parameter
8. Assertion (A): eval('3'*4) is a valid expression
Reasoning (R): An expression using eval()is always valid.
9. Assertion (A): eval('3')*'4' is an invalid expression
Reasoning (R): We cannot multiply two strings.
10. Assertion (A): eval('3')*4 is a valid expression
Reasoning (R): A string can be multiplied with an integer
11. Assertion (A): eval('3')*'K' is a valid expression
B: A string can be multiplied with an integer
12. Assertion (A): int(12.5) returns 12
Reasoning (R): int() returns integer part of its numeric parameter
13. Assertion (A): int('12.5') returns 12
Reasoning (R): int() returns integer part of its numeric parameter
14. Assertion (A): int(12+3.5) returns 15
Reasoning (R): int() returns integer part of its numeric parameter
15. Assertion (A): int('12+3') returns 15
Reasoning (R): int() returns integer part of its numeric parameter
16. Assertion (A): int('12+3') raises an exception (run-time error)
Reasoning (R): string parameter of int() function should represent a valid integer only.
17. Assertion (A): If a=(5/4) then datatype of a is float.
Reasoning (R): / (real division operator) always returns a float value.
18. Assertion (A): If a=(5//4) then datatype of a is int.
Reasoning (R): // (floor division operator) always returns an integer value.
19. Assertion (A): Sometimes fractional number calculation does not give exact result.
Reasoning (R): Some fractional numbers do not have exact binary representation.
20. Assertion (A): if a in b is a valid expression in Python, then b can be a list.
Reasoning (R): in is an operator must in Python.

www.yogeshsir.com Page: Q45/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

21. Assertion (A): if a in b is a valid expression in Python, then b can be a list.


Reasoning (R): The second operand of in can be any iterable.
22. Assertion (A): ('a' and 'b' or not 5) is a valid expression in Python.
Reasoning (R): In Python, strings and numbers can be treated as Boolean values.
23. Assertion (A): eval('3.3')*3 is a valid expression in Python .
Reasoning (R): * works as replication operator between a string and an integer.
24. Assertion (A): If L is a list, then L+=range(5) is an invalid statement.
Reason (R): Only a list can be concatenated to a list.
25. Assertion (A): We cannot delete an element from a tuple.
Reasoning (R): tuples are immutable data objects.
26. Assertion (A): A tuple can be concatenated to a list, but a list cannot be concatenated to a tuple.
Reason (R): Lists are mutable and tuples are immutable in Python.
27. Assertion (A): 'Amitabh' > 'Ajit'
Reasoning: Strings of bigger length are greater than strings of smaller length
28. Assertion (A): 'Amitabh' > 'Ajit'
Reasoning: Unicode/ASCII value of 'm' is greater than that of 'j'.
29. s="Alpha"+"Beta"
Assertion (A): Value of s will be "AlphaBeta".
Reasoning (R): Operator '+' adds the operands, if both are numbers & concatenates the operands if both are
strings.
30. Assertion (A): In Python, elements of a string can be accessed using index numbers.
Reasoning (R): Strings are sequences in Python.
31. Assertion (A): Elements of a sequence can always be accessed using index numbers.
Reasoning (R): All iterables are sequences in Python.
32. Assertion (A): All iterables are sequences in Python.
Reasoning (R): Elements of a sequence can be accessed using index numbers.
33. Assertion (A): The number of actual parameters in a function call may not be equal to the number of formal
parameters of the function.
Reasoning (R): During a function call, it is optional to pass the values to default parameters.
34. Assertion (A): [1,2,3] is an invalid key for a dictionary in Python.
Reason (R): Only numbers and strings can be the keys of a dictionary in Python.
35. Assertion (A): 2 in {'a':1, 'b':2, 'c':3} is True
Reasoning (B): 2 is value in the dictionary.
36. Assertion (A): 2 in {'a':1, 'b':2, 'c':3} is False
Reasoning (B): 2 is a key present in the dictionary.
37. Assertion (A): 2 in {'a':1, 'b':2, 'c':3} is False
Reasoning (B): 2 is a value present in the dictionary.
38. Assertion (A): 2 in {'a':1, 'b':2, 'c':3} is False
Reasoning (B): 2 is not a key in the dictionary.
39. Assertion (A) : Keys in a Python dictionary should be unique.
Reasoning (R) : Only immutable data types can be used as keys.
40. Assertion (A): print(f1()) is a valid statement even if the function f1() has no return statement.
Reasoning (R): A function always returns a value even if it has no return statement.
41. Assertion (A): A variable declared as global inside a function is visible outside the function only after the
function is called.
Reasoning (R): All variables declared outside are not visible inside a function till they are redeclared with
global keyword.

www.yogeshsir.com Page: Q46/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

42. Assertion (A): If the arguments in a function call statement match the number and order of arguments as
defined in the function definition, such arguments are called positional arguments.
Reasoning (R): In a function call, keyword argument(s) are followed by positional argument(s).
43. Assertion (A): In Python, the statement return [<expression>] exits a function.
Reasoning (R): return statement transfers the control to the caller. A return statement with no arguments is
the same as return None.
44. Assertion (A):- keyword arguments are related to the function calls.
Reasoning (R):- when you use keyword arguments in a function call, the caller identifies the arguments by
parameter name.
45. Assertion (A): The default value of an argument will be used inside a function if we do not pass a value to
that argument at the time of the function call.
Reasoning (R): the default arguments are optional during the function call.
46. Assertion (A): Built in functions are predefined in the language that are used directly.
Reasoning(R): print() and input() are built in functions in Python.
47. Assertion (A):- The default arguments can be skipped in the function call.
Reasoning (R):- The default argument will take the default values even if the values are supplied in the
function call.
48. Assertion (A): The function definition def calculate(a, b,c=1,d): will give error.
Reasoning (R): All the non-default arguments must precede the default arguments.
49. Assertion (A): A function in Python always returns a value.
Reasoning (R): return statement is optional in Python.
50. Assertion (A): We cannot redefine an inbuilt function in Python.
Reasoning (R): Keywords cannot be redefined in Python.
51. Assertion (A): If a text file already containing some text is opened in write mode the previous contents are
overwritten.
Reasoning (R): When a file is opened in write mode the initial value of file pointer is 0.
52. Assertion (A): If a text file is opened in 'a+' mode, then we can write the data anywhere in the file.
Reasoning (R): seek() method can be used to place the pointer anywhere in a file.
53. Assertion (A): seek() method can be used instead of tell() method.
Reasoning (R): seek(0) returns the value of file pointer without changing it.
54. Assertion (A): We can use any string, instead of a comma, as a delimiter of a csv file.
Reasoning (R): Comma is the default delimiter of a csv file.
55. Assertion (A): CSV (Comma Separated Values) is a file format for data storage which looks like a text file.
Reasoning (R): In a CSV file the information is organized with one record on each line and each field is
separated by semi-colon.
56. Assertion (A): CSV module allows to write a single record in each row in a CSV file using the writerow()
function.
Reasoning (R): writerow() function creates header row in csv file by default.
57. Assertion (A): CSV stands for Comma Separated Values.
Reasoning (R): CSV files are a common file format for transferring and storing data.
58. Assertion (A): Pickling is the process by which a Python object is converted to a byte stream.
Reasoning (R): load() method is used to write the objects in a binary file. dump() method is used to read
data from a binary file.
59. Assertion (A): If only strings are written to a binary file, then it can be treated as a text file.
Reasoning (R): Pickling and unpickling can be done for strings also.
60. Assertion (A): A binary file in python can be used to store any kind of objects that can be later retrieved in
their original form using pickle module.
Reasoning (R): Binary files are just like normal text files and can be read using a text editor like notepad.

www.yogeshsir.com Page: Q47/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

Python - Finding Output


Compound Assignment Operators
1. What will be the output after execution of the following code:
a,b=1,2
a+=b; b+=a*b
print(a,b)

2. What will be the output after execution of the following code:


a=b=5
a+=b+2; b=a*b
print(a,b)

3. What will be the output after execution of the following code:


P,q=14,9
p%=q
q//=p
print(p,q)

4. What will be the output after execution of the following code:


a,b=10,3
c=a%b; a+=b%c; b+=a+b//c
print(a,b,c)

5. What will be the output after execution of the following code:


a,b=4,1
c=a-b
a+=b
b+=a%b+b%c
print(a,b,c)

6. What will be the output after execution of the following code:


a,b=10,3
c=2**b
a+=b**(c//a)
b//=a+b//c
print(a,b,c, sep="#")

7. What will be the output after execution of the following code:


a=83
b=a%10+a//10
c=b%10+b//10
a=b+c
print(a,b,c,sep=", ",end=".\n")

8. What will be the output after execution of the following code:


a,b=-1,3
c=a%b
a+=b%c
b+=a%b%(-c)
print(a,b,c, end="#")

www.yogeshsir.com Page: Q48/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

9. What will be the output after execution of the following code:


a,b,c=5,10,15
a+=a+b+c
b+=a+b+c
c+=a+b+c
print(a,b,c)

10. What will be the output after execution of the following code:
a,b,c=5,10,15
b+=a+b+c
c+=a+b+c
a+=a+b+c
print(a,b,c)

11. What will be the output after execution of the following code:
a,b,c=5,10,15
c+=a+b+c
a+=a+b+c
b+=a+b+c
print(a,b,c)

12. What will be the output after execution of the following code:
a,b,c=1,2,3
a*=a+b
b*=a+b
c*=a+b
print(a,b,c)

13. What will be the output after execution of the following code:
a,b,c=1,2,3
b*=a+b
c+=a+b
a=+b*c
print(a,b,c)

14. What will be the output after execution of the following code:
a,b,c=10,7,5
b//=b//c
a%=a%b
c*=c*a
print(a,b,c)

15. What will be the output after execution of the following code:
a,b,c=10,7,5
a%=4
b%=a
c%=b
print(a,b,c)

www.yogeshsir.com Page: Q49/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

Python - Finding Output


if..elif..else
1. What will be the output of the following code?
n1=12/5
if int(n1)==n1:
print("Integer")
else: print("Non integer")

2. What will be the output of the following code?


age=12
if not age<18:
print("Yes")
else: print("No")

3. What will be the output of the following code?


a,b,c=12,13,14
if (a>=b or a<=c and a+c<=b):
print("A")
else: print("B")

4. What will be the output of the following code?


a,b,c=20,15,10
if a>b:
a-=b
c+=b
if b>c:
a+=c
c+=b
else:
a+=b and c
print(a,b,c)

5. What will be the output of the following code?


n=0
if n:
print(bool(n))
else: print(bool(n-1))

6. What will be the output of the following code?


n=-1
if n:
print(bool(n))
else: print(bool(n-1))

7. What will be the output of the following code?


n=1
if n: print(bool(n))
else: print(bool(n-1))

www.yogeshsir.com Page: Q50/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

8. What will be the output of the following code?


a='False'
if not a and a:
print('a')
elif not a or a:
print('b')
else:
print('c')

9. What will be the output of the following code?


a=False
if not a and a: print('a')
elif not a or a: print('b')
else: print('c')

10. What will be the output of the following code?


a=True
if not a and a:
print('a')
elif not a or a:
print('b')
else:
print('c')

11. What will be the output of the following code?


x,y=12,24
if x%y==0:
print(x and y)
elif y%x==0:
print(x or y)
else: print(not x and not y)

12. What will be the output of the following code?


x,y=13,24
if x%y==0:
print(x and y)
elif y%x==0:
print(x or y)
else: print(not x and not y)

13. What will be the output of the following code?


x,y=24,12
if x%y==0:
print(x and y)
elif y%x==0:
print(x or y)
else: print(not x and not y)

www.yogeshsir.com Page: Q51/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

14. What will be the output of the following code?


a,b,c=6,2,8
if a>b>c:
a+=b*c
elif a<b<c:
b+=c*a
else: c+=a*b
print(a,b,c)

15. What will be the output of the following code?


a,b,c=8,6,2
if a>b>c:
a+=b*c
elif a<b<c:
b+=c*a
else: c+=a*b
print(a,b,c)

16. What will be the output of the following code?


a,b,c=2,6,8
if a>b>c:
a+=b*c
elif a<b<c:
b+=c*a
else: c+=a*b
print(a,b,c)

17. What will be the output of the following code?


a,b,c=6,0,1
if a-b:
res=a%6+b%6+c%5
elif a+b and a*c:
res=a+b-a*b
elif a and b or c:
res=a+b+c
else: res=a*b*c
print(res)

18. What will be the output of the following code?


a,b,c=6,6,0
if a-b:
res=a%6+b%6+c%5
elif a+b and a*c:
res=a+b-a*b
elif a and b or c:
res=a+b+c
else: res=a*b*c
print(res)

www.yogeshsir.com Page: Q52/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

19. What will be the output of the following code?


a,b,c=6,6,1
if a-b:
res=a%6+b%6+c%5
elif a+b and a*c:
res=a+b-a*b
elif a and b or c:
res=a+b+c
else: res=a*b*c
print(res)

20. What will be the output of the following code?


a,b,c='6','3','1'
if a>b:
res=eval(a*3)+eval(a)*3
elif a>'c':
res=eval(a+b-a*b)
elif a and b or c:
res=a+b+c
else: res=a*eval(b)
print(res)

21. What will be the output of the following code?


a,b,c='6','7','1'
if a>b:
res=eval(a*3)+eval(a)*3
elif a>'c':
res=eval(a+b-a*b)
elif a and b or c:
res=a+b+c
else: res=a*eval(b)
print(res)

22. What will be the output of the following code?


a,b,c='0','0','0'
if a>b:
res=eval(a*3)+eval(a)*3
elif a>'c':
res=eval(a+b-a*b)
elif a and b or c:
res=a+b+c
else: res=a*eval(b)
print(res)

23. What will be the output of the following code?


n=2024
if n%100!=0 and n%4==0 or n%400==0:
print("Lp")
else: print("Not Lp")

www.yogeshsir.com Page: Q53/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

24. What will be the output of the following code?


n=1900
if n%100!=0 and n%4==0 or n%400==0:
print("Lp")
else: print("Not Lp")

25. What will be the output of the following code?


n=1980
if n%100!=0 and n%4==0 or n%400==0:
print("Lp")
else: print("Not Lp")

26. What will be the output of the following code?


n=2023
if n%100!=0 and n%4==0 or n%400==0:
print("Lp")
else: print("Not Lp")

27. What will be the output of the following code?


num=-245
if num<0:
num=-num;
if num>=0 and num<=9:
print("Single digit number")
elif num>=10 or num<=99:
print("Two digit number")
elif num<=999:
print("Three digit number")
else: print("More than 3 digits")

28. What will be the output of the following code?


num=4
if num<0:
num=-num;
if num>=0 and num<=9:
print("Single digit number")
elif num>=10 or num<=99:
print("Two digit number")
elif num<=999:
print("Three digit number")
else: print("More than 3 digits")

29. What will be the output of the following code?


num=56
if num<0:
num=-num;
if num>=0 and num<=9:
print("Single digit number")
elif num>=10 or num<=99:
print("Two digit number")
elif num<=999:
print("Three digit number")
else: print("More than 3 digits")

www.yogeshsir.com Page: Q54/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

30. What will be the output of the following code?


num=9564
if num<0:
num=-num;
if num>=0 and num<=9:
print("Single digit number")
elif num>=10 or num<=99:
print("Two digit number")
elif num<=999:
print("Three digit number")
else: print("More than 3 digits")

www.yogeshsir.com Page: Q55/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

Python - Finding Output


Loops
1. What will be the output of the following code?
for i in range(1,10,2):
print(i,end="-")
print(i)
2. What will be the output of the following code?
for i in range(13, 1, -4):
print(i,end=' ')
i=i+1
else: print(i)
3. What will be the output of the following code?
i=1
while i<10:
print(i//2,end=':')
i+=2
if i%8>6:
break
else: print(i)
print(i)
4. What will be the output of the following code?
i=1
while i<10:
print(i//2,end=':')
i+=2
if i%8>6:
continue
else: print(i)
print(i)
5. What will be the output of the following code?
n=46567
while n%10:
if n%10<=5:
n-=1
continue
print(n,end=" and ")
n//=10
6. What will be the output of the following code?
for i in range(1,10):
if i%4:
print(i,end=' ')
elif i>5:
print("i",end=".")
else: print("-")
7. What will be the output of the following code?
for i in range(10,40,3):
j=i%10+i//10
if j%2==0:
continue
else: print(i,j,end=';')

www.yogeshsir.com Page: Q56/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

8. What will be the output of the following code?


n=12034
s=c=0
while n:
s+=n%10
c+=1
n//=10
else: print(s/c)
print(s,c)
9. What will be the output of the following code?
n=12034
s=c=0
while n%10:
s+=n%10
c+=1
n//=10
else: print(s/c)
print(s,c)
10. What will be the output of the following code?
n=46567
s=c=0
while n%10:
if n%10>5:
pass
else:
s+=n
c+=1
n//=10
print(s,c)
11. What will be the output of the following code?
n=46567
while n>1000:
if n%10<=5:
n//=10
break
print(n%10,"$")
n//=10
else: print("#")
print(n)
12. What will be the output of the following code?
for i in range(10):
i=i+1
print(i,end=' ')
if i>5 and i<8:
break
else:
print(i+2)
else:
print("Done")
print("--")

www.yogeshsir.com Page: Q57/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

13. What will be the output of the following code?


i=1
while i<=5:
print(i//2,end=':')
i+=2
for j in range(i,i+1,i):
print(i,j,sep="&",end="-")
else: print(i)
print(i)
14. What will be the output of the following code?
a,b=4,10
start,end=a,b
if a>b:
start,end=b,a
i=start
while i<=end:
if (i%start==0):
print(i,end='--')
i+=1
print(i)
15. What will be the output of the following code, if a,b,c='6','3','1':
a,b=2,-4
start,end=a,b
if a>b:
start,end=b,a
i=start
while i<=end:
if (i%start==0):
print(i,end='--')
i+=1
print(i)

www.yogeshsir.com Page: Q58/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

Python – Finding Output


Lists
1. What will be the output of the following code?
nums=[5,3,1,6,9,6,2]
a=len(nums)
b=nums[1]
c=nums[-1]
d=max(nums)
e=min(nums)
print(a,b,c,d,e)

2. What will be the output of the following code?


a=[1,2,3,4,5,6]
print(a[3])
print(a[:3])
print(a[3:])
print(a[::3])

3. What will be the output of the following code?


a=['ant','bat','cat','dog','eel']
print(a[-3])
print(a[:-3])
print(a[-3:])
print(a[::-3])

4. What will be the output of the following code?


A=[3,6,7,8,10,12,23,33,16,6,2,1]
print(A[3::-2])
print(A[-3::-2])
print(A[3:-3:3])
print(A[3:-3:-3])

5. What will be the output of the following code?


a=[1,2,3,2,1]
for x in a:
print(a[x], end=' ')

6. What will be the output of the following code?


nums=list(range(11,21))
a=len(nums)
b=nums[0]
c=nums[-1]
print(a,b,c)

7. What will be the output of the following code?


nums=[i+2 for i in range(5)]
a=len(nums)
b=nums[0]
c=nums[-1]
print(a,b,c)

www.yogeshsir.com Page: Q59/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

8. What will be the output of the following code?


nums=[i*i for i in range(4,10,2)]
a=len(nums)
b=nums[0]
c=nums[-1]
print(a,b,c)

9. What will be the output of the following code?


nums=[-9,5,6,4,3]
nums=[a+1 for a in nums]
a=len(nums)
b=nums[0]
c=nums[-1]
print(a,b,c,sep="#")

10. What will be the output of the following code?


nums=[None]*3+[4]*3
a=len(nums)
b=nums[0]
c=nums[-1]
print(a,b,c)

11. What will be the output of the following code?


a=[1,2]
b=['a','b']
c=a+b
print(c)

12. What will be the output of the following code?


a=[1,2]
b=['a','b']
c=a+[b]
print(c)

13. What will be the output of the following code?


a=[1,2,3,4]
b=['a','b']
a.append(b)
print(a)

14. What will be the output of the following code?


a=[1,2,3,4]
b=['a','b']
a.extend(b)
print(a)

15. What will be the output of the following code?


a=[1,2]
b=a
c=b.copy()
b.append('a')
print(a,b,c)

www.yogeshsir.com Page: Q60/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

For quick understanding of append() and extend(), scan the QR code:

16. What will be the output of the following code?


a=[3,2,3,4,1,5,3,4,2]
b=a.count(3)
b+=a.count(a[-3])
print(b)

17. What will be the output of the following code?


a=[3,2,3,4,1]
b=sorted(a)
c=a.sort(reverse=True)
print(b,c)

18. What will be the output of the following code?


a=[3,2,3,4,1]
a.insert(2,5)
a.remove(3)
a.pop()
a.pop(0)
print(a)

19. What will be the output of the following code?


a=[3,2,3,4,1]
a.reverse()
b=a.index(3)+a[1:].index(3)
print(b)

20. What will be the output of the following code?


a=[3,2,3,4,1]
b=sorted(a)
print(a[0],b[0])

21. What will be the output of the following code?


a=[1,2,3,4,5]
n=len(a)
for i in range(n):
a[i]=sum(a)
print(a)

22. What will be the output of the following code?


a=[12,15,21,89,56,65,54,78,67]
n=len(a)
for i in range(n):
a[i]%=a[i]%10
print(a)

www.yogeshsir.com Page: Q61/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

23. What will be the output of the following code?


a=[12,15,21,89,56,67]
n=len(a)
for i in range(n):
a[i]=a[i-1]
print(a)

24. What will be the output of the following code?


a=[12,15,21,89,56,65,54,78,67]
s=0
for ele in a:
s+=ele%10+ele//10
print(s)

25. What will be the output of the following code?


a=[12,15,21,89,56,65,54,78,67]
s=0
for ele in a[::-1]:
if s>50:
break
s+=ele%10+ele//10
print(ele,s)

www.yogeshsir.com Page: Q62/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

Python – Finding Output


Tuples
1. What will be the output of the following code?
nums=(5,3,1,6,9,6,2)
a=len(nums)
b=nums[1]
c=nums[-1]
print(a,b,c)

2. What will be the output of the following code?


a=1,2,3,4,5,6
print(a[3])
print(a[:3])
print(a[3:])
print(a[::3])

3. What will be the output of the following code?


nums=tuple(range(5,8))
a,b,c=nums[::-1]
print(a,b,c)

4. What will be the output of the following code?


nums=[1],[2,3],[4,5,6]
a=len(nums)
b=nums[0]
c=nums[-1][1]
print(a,b,c,sep="#")

5. What will be the output of the following code?


nums=([i+2 for i in range(5)],)
a=len(nums)
b=nums[0]
c=nums[-1]
print(a,b,c,sep="\n")

6. What will be the output of the following code?


a=(1,2)
b=('a','b')
c=a+b
print(c)

7. What will be the output of the following code?


a=(1,2)
b=a
a+=(3,)
print(a,b)

8. What will be the output of the following code?


a=(1,2)
b=(a,)
a+=(3,)
print(a)
print(b)

www.yogeshsir.com Page: Q63/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

9. What will be the output of the following code?


a=(3,2,3,4,1,5)
b=a.count(3)
b+=a.count(a[-3])
print(b)

10. What will be the output of the following code?


a=(3,2,4,1)
b=sorted(a)
print(a)
print(b)

11. What will be the output of the following code?


a=(1,2,3,1,2,3)
b=a.index(1,3)
c=a[1:].index(3)
print(b,c)

12. What will be the output of the following code?


A=[1]
B=A,'a','A'
A.append(2)
print(A)
print(B)

13. What will be the output of the following code?


A=[1]
B=A.copy(),'a','A'
A.append(2)
print(A)
print(B)

14. What will be the output of the following code?


A=tuple('red'),'yellow'
print(A)
print(len(A),A[1])

15. What will be the output of the following code?


A=tuple(tuple('red'))
print(A)
print(len(A),A[1])

www.yogeshsir.com Page: Q64/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

Python - Finding Output


Strings
1. What will be the output of the following code?
s="Strings"
a,b,c=len(s),min(s),max(s)
print(a,b,c,sep=":")

2. What will be the output of the following code?


s="The Quiz\n(Strings)"
print(s)
a,b,c=len(s),min(s),max(s)
print(a,b,c,sep=":")

3. What will be the output of the following code?


s="Python Strings"
a,b,c,d=s[0],s[-1],s[4],s[-4]
print(a,b,c,d,sep=":")

4. What will be the output of the following code?


str1="""Na
\tio\nal"""
print(str1)
print(len(str1))

5. What will be the output of the following code?


s1="3"*4
print(s1)

6. What will be the output of the following code?


s1="3"+"4"*3
print(s1)

7. What will be the output of the following code?


s1="-*"
s1=s1*len(s1)
print(s1*len(s1))

8. What will be the output of the following code?


s="National"
a=s[2:]
b=s[:2]
c=s[::2]
print(a,b,c,sep="*")

9. What will be the output of the following code?


s="National"
a=s[-2:]
b=s[:-2]
c=s[::-2]
print(a,b,c,sep="#")

www.yogeshsir.com Page: Q65/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

10. What will be the output of the following code?


s="National"
a=s[2:][2:]
b=s[:2][1]
c=s[::2][:2]
print(a,b,c,sep=":")

11. What will be the output of the following code?


s="Mississippi"
a=s.index('s')
b=s.index('i',2)
c=s[4:].index('i')
d=s.index('i',-1)
print(a,b,c,d,sep="-")

12. What will be the output of the following code?


s="This iss not Thisssss"
a=s.count(s)
b=s.count('is')
c=s.count('ss')
print(a,b,c,sep="-")

13. What will be the output of the following code?


s="a and b and c"
s1=s.split()
print(s1)

14. What will be the output of the following code?


s="""a and b
and c"""
s1=s.split('and')
print(s1)

15. What will be the output of the following code?


s="a and b"
s1=s.split('a')
print(s1)

16. What will be the output of the following code?


s="a and b"
s1=s.split(s)
print(s1)

17. What will be the output of the following code?


s="a and b"
s1=s.split('s')
print(s1)

18. What will be the output of the following code?


s="Vision"
s1="".join(s)
print(s1)

www.yogeshsir.com Page: Q66/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

19. What will be the output of the following code?


s="Vision"
s1=",".join(s)
print(s1)
print(len(s1))

20. What will be the output of the following code?


s=["1",'2','''3''']
s1=" and ".join(s)
print(s1)
print(len(s1))

21. What will be the output of the following code?


d={'a':'ada','b':'basic','c':'c'}
s1="*".join(d)
print(s1)
print(len(s1))

22. What will be the output of the following code?


s="International"
a=s.partition('r')
print(a)

23. What will be the output of the following code?


s="International"
a=s.partition('t')
print(a)

For quick understanding of split() and partition(), scan the QR code:

24. What will be the output of the following code?


s="International"
a=s.partition('n')
print(a)

25. What will be the output of the following code?


s="International"
a=s.partition('na')
print(a)

26. What will be the output of the following code?


s="International"
a=s.partition('I')
print(a)

27. What will be the output of the following code?


s="International"
a=s.partition('al')
print(a)

www.yogeshsir.com Page: Q67/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

28. What will be the output of the following code?


s="International"
a=s.partition('the')
print(a)

29. What will be the output of the following code?


s="Pen and Pencil"
a=s.partition('Pen')
print(a)

30. What will be the output of the following code?


s="Writer writes"
s.replace("write", "read")
print(s)

31. What will be the output of the following code?


s="Writer writes"
t=s.replace("write", "read")
print(s)
print(t)

32. What will be the output of the following code?


s="thier wierd foriegn friends"
s=s.replace("ie", "ei")
print(s)

33. What will be the output of the following code?


s="thier wierd foriegn friends"
s=s.replace("ie", "ei",2)
print(s)

34. What will be the output of the following code?


s="Self Conquest"
a=s.find('e')
b=str.rfind(s,'e')
print(a,b,sep=", ")

35. What will be the output of the following code?


s="Self Conquest"
a=s.find('quest')
b=str.rfind(s,'quest')
print(a,b,sep=", ")

36. What will be the output of the following code?


s="Book, Pen, Pencil, Ink"
a=s.find(',',5,20)
b=str.rfind(s,',',5,20)
print(a,b,sep=", ")

37. What will be the output of the following code?


s="Book, Pen, Pencil, Ink"
a=s.find('-',5,20)
b=str.rfind(s,'-',5,20)
print(a,b,sep=", ")

www.yogeshsir.com Page: Q68/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

38. What will be the output of the following code?


s="live and let live"
a=s.capitalize()
print(a)

39. What will be the output of the following code?


s="Q For Quiz"
s=s.swapcase()
print(s)

40. What will be the output of the following code?


s="Ant"
a,b,c=s
print(a,b,c,sep="-")

www.yogeshsir.com Page: Q69/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

Python – Finding Output


Dictionaries
1. What will be the output of the following code?
d={1:2,3:4}
nums=list(d)
print(nums)

2. What will be the output of the following code?


d={1:2,3:4}
nums=list(d.keys())
print(nums)

3. What will be the output of the following code?


d={1:2,3:4}
nums=list(d.values())
print(nums)

4. What will be the output of the following code?


d={1:2,3:4}
nums=list(d.items())
print(nums)

5. What will be the output of the following code?


a=dict.fromkeys([1,2,3])
print(a)

6. What will be the output of the following code?


a=dict.fromkeys([1,2,3],'a')
print(a)

7. What will be the output of the following code?


a=dict.fromkeys('a',[1,2,3])
print(a)

8. What will be the output of the following code?


a=dict.fromkeys('app','app')
print(a)

9. What will be the output of the following code?


d={1:"One",2:"Two"}
a=dict.fromkeys(d)
print(a)

10. What will be the output of the following code?


d={1:"One",2:"Two"}
a=dict.fromkeys(d.keys())
print(a)

11. What will be the output of the following code?


d={1:"One",2:"Two"}
a=dict.fromkeys(d.values())
print(a)

www.yogeshsir.com Page: Q70/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

12. What will be the output of the following code?


d={1:"One",2:"Two"}
a=dict.fromkeys(d.items())
print(a)

13. What will be the output of the following code?


d={1:"One",2:"Two"}
d.clear()
print(d)

14. What will be the output of the following code?


d={1:"One",2:"Two"}
print(d.get(2))
print(d.get(2,"TTwwoo"))

15. What will be the output of the following code?


d={1:"One",2:"Two"}
print(d.get(3))
print(d.get(3,"Three"))

16. What will be the output of the following code?


d={1:"One",2:"Two"}
print(d.setdefault(2))
print(d.setdefault(2,"Twoo"))
print(d.setdefault(3))
print(d.setdefault(3,"Three"))
print(d)

17. What will be the output of the following code?


d={1:"One",2:"Two"}
print(d.setdefault(3,"Three"))
print(d.setdefault(3))
print(d)

18. What will be the output of the following code?


d={1:"One",2:"Two"}
print(d.pop(2,"-"))
print(d.pop(2,"-"))

19. What will be the output of the following code?


d={1:"One",2:"Two"}
print(d.popitem())
print(d.popitem())

20. What will be the output of the following code?


d={1:"One",2:"To"}
d1={2:"Two",3:"Three"}
d.update(d1)
print(d)
print(d1)

www.yogeshsir.com Page: Q71/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

21. What will be the output of the following code?


d={1:"One",2:"Two"}
for k in d:
print(k,end='-')
print()
for k in d.keys():
print(k,end='-')
print()
for k in d.values():
print(k,end='-')

22. What will be the output of the following code?


d={1:"One",2:"Two"}
for k in d.items():
print(k,end='-')
print()
for k,v in d.items():
print(k,v,sep='-')

23. What will be the output of the following code?


d1={1:1,2:4,3:9}
d2={1:"One",4:"Four",9:"Nine"}
d3={}
for k,v in d1.items():
d3[k]=d2[v]
print(d3)

24. What will be the output of the following code?


d={1:"Pen",3:"Book",2:"Ink"}
a=len(d),max(d),min(d)
b=sorted(d)
print(a)
print(b)

25. What will be the output of the following code?


d1={1:1,2:4,2:8}
print(d1)
d2={1:1,2:3,3:5}
d1.update(d2); d2.update(d1)
print(d1); print(d2)

26. What will be the output of the following code?


d1={1:"One",2:"Two"}
d2=d1
d1.clear()
print(d2)

27. What will be the output of the following code?


d1={1:"One",2:"Two"}
d2=d1.copy()
d1.clear()
print(d2)

www.yogeshsir.com Page: Q72/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

28. What will be the output of the following code?


s='mississippi'
d=dict.fromkeys(s)
for k in d:
d[k]=s.count(k)
print(d)

29. What will be the output of the following code?


s='abba'
d=dict.fromkeys(s,())
n=len(s)
for i in range(n):
d[s[i]]+=(i,)
print(d)

30. What will be the output of the following code?


s='amma'
d=dict.fromkeys(s,[])
n=len(s)
for i in range(n):
d[s[i]].append(i)
print(d)

www.yogeshsir.com Page: Q73/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

Python – Finding Output


Functions
1. What will be the output of the following code?
def test(a,b):
a,b=b,a
x,y=10,20
test(x,y)
print(x,y)

2. What will be the output of the following code?


def test(a,b):
x,y=b,a
x,y=10,20
test(x,y)
print(x,y)

3. What will be the output of the following code?


def test(a,b):
global x,y
x,y=b,a
x,y=10,12
test(x,y)
print(x,y)

4. What will be the output of the following code?


def test(a,b):
global x,y
x,y=b,a
p,q=10,12
test(p,q)
print(x,y)

5. What will be the output of the following code?


def test(a,b):
a+=1; b-=1
p,q=10,12
test(p,q)
print(p,q)

6. What will be the output of the following code?


def test(a,b,c):
print(a,b,c)
test(4,5,6)

7. What will be the output of the following code?


def test(a,b,c):
print(a,b,c)
test(6,c=5,b=12)

8. What will be the output of the following code?


def test(a,b,c):
print(a,b,c)
test(c=6,a=5,b=1)

www.yogeshsir.com Page: Q74/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

9. What will be the output of the following code?


def f1():
print("Hello")
print(f1())

10. What will be the output of the following code?


def f1():
print("Hello")
return "Hi"
print(f1())

11. What will be the output of the following code?


def f1():
return "Hi"
print("Hello")
print(f1())

12. What will be the output of the following code?


def f1(n):
if n<10: return "Hi"
elif n>10: return "Bye"
print("Done")
print(f1(10))

13. What will be the output of the following code?


def f1(n):
if n<10:
return "Hi"
elif n>10:
return "Bye"
print("Done")
print(f1(5)+f1(15))

14. What will be the output of the following code?


def f1(a):
print(a)
return a+1
def f2(a,b):
a=f1(b)
return a,b
print(f1(10))
print(f2(5,7))

15. What will be the output of the following code?


def f1(a):
if a%2:
return a+1
else: return a+2
def f2(a):
s=0
for i in range(a):
s+=f1(i)
return s
print(f2(5))

www.yogeshsir.com Page: Q75/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

16. What will be the output of the following code?


def test(a):
a+="Hi"
x=[1,2]
test(x)
print(x)

17. What will be the output of the following code?


def f1(a):
if type(a)==list:
n=len(a)
for i in range(n):
a[i]+=i
else:
a*=2
x=10
f1(x)
print(x)

18. What will be the output of the following code?


def f1(a):
if type(a)==list:
n=len(a)
for i in range(n):
a[i]+=i
else:
a*=2
x=[1,2,3]
f1(x)
print(x)

19. What will be the output of the following code?


def f1(a,b):
if a>b:
return a%b
else: return b%a
a=[12,65,45,34,54]
for i in range(5):
j=-(i+1)
a[i]=f1(a[i],a[j])
print(a)

20. What will be the output of the following code?


def f1(a):
if a<5:
return a*a
else: return a*2
a=12,65,47,34,52
b=tuple()
for i in range(5):
b=b+(f1(a[i]%10),)
print(b)

www.yogeshsir.com Page: Q76/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

Python – Correcting the Code


1. Find error(s), if any, in the following statements, and rewrite the correct statement underlining the
corrections made:
(i) print("three') (ii) Print(3) (iii) print(44'+'56) (iv) print(3,2 sep=': ')
(v) print "wisdom" (vi) print['33+44'] (vii) PRINT("15 August 1947")

2. Find error(s), if any, in each of the following function calls, and rewrite the correct function call
underlining the corrections made:
(i) input(Enter a number: ) (ii) input("Enter your age: ") (iii) int(56)
(iv) int("56.6") (v) int("fifty6") (vi) int('5six') (vii) int(5six)
(viii) float(12.3) (ix) float("-12.45") (x) float(5) (xi) int(5/4)
(xii) float("5/4") (xiii) eval('10+2') (xiv) eval('10') (xv) eval(10)
(xvi) eval(10*2) (xvii) int(eval("10/3")) (xviii) eval(int(10/3))
(xix) eval(int("10/3")) (xx) eval(float("10/3"))

3. Find error(s), if any, in each of the following scripts, and rewrite the correct code underlining the
corrections made:
(i) n1,n2=5,4
if n1=n2:
print("Equal")

(ii) n1=n2=12/5
if n1!=n2
print"Not equal"
else print"Equal"

(iii) 12=age
if age=<10:
print(Primary)
elseif age=<13:
print(Middle)
elseif age<=15:
print(Secondary)
else age<=17:
print(Sr Secondary)

(iv) num=input("Enter an integer: ")


if num<0:
num=-num;
if num>=0 AND num<=9
print("Single digit number")
elif: num>=10 OR num<=99
print("Two digit number")
elif: num<=999
print("Three digit number")
else: print("Number contains more than 3 digits")

(v) a=b=c=12,13,14
if (a>=b or a<=c and a+c<=b):
print("A")
ELSE print(a+b+c)

www.yogeshsir.com Page: Q77/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

4. Each of the following code segments has some error(s). Rewrite the correct code underlining all the
corrections made. Minimum changes should be made the code so that it executes:
(i) a=int(input("Enter a number: "))
c==1
for b in range (a,a*10.0,a)
c=*b
print(a,b,c)

(ii) a=int(input("Enter a number: "))


b=int(input("Enter another number: "))
start,end=a,b
if a>b:
start,end=b,a
i=start
while i=<end
if (i%start=0):
print(i,end='--',start)
i+=1
print(i)

(iii) a=int(input("Enter a number: ")


b=int(input("Enter another number: ")
if a>b: step=-1
else: step=1
while a!=b:
if (a+b%2>0):
print(a+b,sep="--')
a=+step

(iv) a=int(input("Enter a number: ")


while a%5!=0
if (a%2>0):
print(a,sep="--)
a+=1
else: print(a)

(v) x=123045
while x%10:
x=//10
print(x,sep="--")
else print(a)

(vi) x=123045
while x%10:
d=x%10
for i in range(d):
print(i)
else: print (d)
print(x,sep='--')
x/=10
else print(a)

www.yogeshsir.com Page: Q78/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

(vii) n=100, s=0


for i in range(1,n+1)
if n%i==0:
s+=i
elif: n+=1
print(n;s)

(viii) a==10
while a=>0:
if a%2=0:
print(a)
else:
print(a//2)
a-=1

(ix) d1=dict.fromkeys('banana')
d2=fromkeys('pineapple','apple')
d1.update{d2}
for k in d1.keys:
if k in d2
print(d2[k], end=' ')
else: print(d1[k])

(x) voter = {name: "Alok", age: 30, city: "Agra"}


print(voter{"name"})
voter["country"] = "India"
delete voter["age"]

(xi) 30=To
for K in range(0,To)
IF k%4==0:
print (K*4)
Else:
print (K+3)

(xii) 250 = Number


WHILE Number<=1000:
if Number=>750:
print(Number)
Number=Number+100
else
print(Number*2)
Number=Number+50

5. Each of the following code segments has some error(s). Rewrite the correct code underlining all the
corrections made. Minimum changes should be made the code so that it executes:
(i) a=[1,2,3,2,1]
for x in range(a):
print(x)

(ii) a=["Umang","Usman","Utkarsh","Umedh"]
for x in range(len(a)):
print(a(x))

www.yogeshsir.com Page: Q79/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

(iii) A=[]*5
for i in range(5):
A[i]=i+2
print(A[])
print([A])
A[2:]=A
A[2:5]=8,9,10
6. The following code is written to input a positive integer and display all its even factors in descending
order. This code has some errors. Rewrite the correct code and underline the corrections made.
n=input("Enter a positive integer: ")
for i in range(n):
if i%2:
if n%i==0:
print(i,end=' ')
7. The following code is written to input an integer and display its first 10 multiples (from 1 to 10). This
code has some errors. Rewrite the correct code and underline the corrections made.
n=int(input(Enter an integer: ))
for i in range(1,11):
m=n*j
print(m;End=' ')
8. The following code is written to input an integer and display its factorial. This code has some errors.
Rewrite the correct code and underline the corrections made.
(Note: Factorial of a number n is the product 1x2x3. . .n)
n=int(input("Enter a positive integer: ")
f=0
for i in range(n):
f*=i
print(f)
9. The following code is written to create and display a list of 10 2-digit random integers. This code has
some errors. Rewrite the correct code and underline the corrections made.
import randint from random
nums=list[]
for i in range 10:
nums.append(randint(99,10))
print(nums)
10. The following code is written to create a list of 20 2-digit random integers, and then to remove all the
odd multiples of 3 from the list. This code has some errors. Rewrite the correct code and underline
the corrections made.
Import random
nums=(randint(10,99) for i in range(20))
i=0
while i<nums:
if nums[i]%3==0 and nums[i]%2==0:
del nums[i]
else i+=1
11. The following code is written to create a list of 10 2-digit random integers, and then copy all the
multiples of 5 from this list to a tuple. This code has some errors. Rewrite the correct code and
underline the corrections made.
from randint import random
nums=[randint(10,99) for i in range(10)]
t=tuple
for num in nums:
if num%5=0: t+=(num)

www.yogeshsir.com Page: Q80/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

12. The following code is written to create tuple of 10 integers which are input from the user. The code
then finds the sum of all the multiples of 5 present in the tuple. This code has some errors. Rewrite
the correct code and underline the corrections made.
t=()
for i in range(10):
num=int(input("Enter an integer: ")
t+=num
s=0
for i in range(10):
if t(i)//5==0:
s+=t[i]
13. The following code is written to input an integer and check whether it is prime or not. This code has
some errors. Rewrite the correct code and underline the corrections made.
(Note: A prime number is a number which does not have any factor other than 1 and itself)
def prime():
n=int(input("Enter number to check: ")
for i in range (2, n//2):
if n%i=0:
print("Number is not prime \n")
break
else:
print("Number is prime \n')
14. The following code is written to display all the 2-digit multiples of 4 and 5 in the interval 1 to 50. This
code does not run due to incorrect indentation. Rewrite the code with correct indentation so that it
produces the desired result.
for val in range(1,51):
if val%4==0:
print (val,end=' ')
else:
if val%5==0:
print (val,end=' ')
else:
continue
15. The code given below accepts a number as an argument and returns the reverse number. Observe
the following code carefully and rewrite it after removing all syntax and logical errors. Underline all
the corrections made.
define reverse(n):
rev=0
While n>0:
d=n/10 #
rev=rev*10+d
n//=10
return rev #
print(reverse(1024))

www.yogeshsir.com Page: Q81/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

Python - Writing single statement code


If L1=[1,2,3,2,1,2,4,2, . . . ], and L2=[10,20,30, . . .], then write a statement to perform
each of the following tasks. Each task should be done using one statement only. (Answer using built-in functions
/ methods, Slicing, and +, = ,+= operators only):

1. To create an empty list with name L3.


2. To create a list L4 with the characters of the word 'Campground'.
3. To create a list L5 which contains first 5 elements of L1 followed by last 5 elements of L2.
4. To display the number of elements in L1.
5. To display the total number of elements in L1 and L2.
6. To append L2 as an element to the list L1.
7. To append each element of L2 to the list L1.
8. To insert the list L1 as an element to the list L2 at index 3.
9. To insert all the elements of list L1 before the last element in the list L2.
10. To sort the elements of list L1 in ascending order.
11. To sort the elements of list L2 in descending order.
12. To count the occurrences of 3 in L1.
13. To count the occurrences of L1[3] in L2.
14. To delete the last element of L1 and insert it as the first element in L2.
15. To delete the first occurrence of 3 from list L1.
16. To delete the first occurrence of the last element of L1.
17. To delete the element L1[3] from the list L2. (Assume that L1[3] exists in L2).
18. To display the index of the first occurrence of 5 in the list L1.
19. To display the index of the second occurrence of 5 in the list L1 (Assume that 5 appears multiple times in
the list L1).
20. To shift the first element of L1 to the end of L1.
21. To shift the last element of L2 to the beginning of L2.
22. To remove the last element of L1 and insert it at the beginning of L2.
23. To reverse the list L1.
24. To create a list L6 which stores the sorted elements of L1 without affecting L1.
25. To insert the smallest element of L1 after the 4th element in L2.
26. To display the sum of all the elements of L1.
27. To display the sum of all the elements of L2 which are at even indices, i.e., L2[0]+L2[2]+L2[4]+ ...
28. To display the sum of all the elements of L1 which are at odd indices, i.e., L1[1]+L1[3]+L1[5]+ ...
29. To create a tuple containing the elements of list L1. Name the tuple as T1.
30. To create a tuple containing the elements of tuple T1 and the elements of list L2. Name the tuple as T2.

If S1 = "Atlantic ocEan", S2="bermuda TriangGle", S3=" \n\tAsiatic Lion\n\t\t ",


and ch is a string variable storing a string of length 1, then write a statement to perform each of the following
tasks. Each task should be done using one statement only. (Answer using built-in functions / methods, Slicing,
and +, = ,+= operators only):
31. To display the total number of characters in S1.
32. To display the total number of words in S2.
33. To display the string S1 in uppercase.
34. To display the string S1 in lowercase.
35. To display the string S1 as 'Atlantic ocean'.
36. To display the string S1 as 'Atlantic Ocean' .
37. To display the index number of ch in the string S1. The statement should raise ValueError exception if ch
is not found in S1.

www.yogeshsir.com Page: Q82/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

38. To display the index number of ch in the string S1. The statement should not raise any exception if ch is
not found in S1.
39. To display S3 after removing all the leading whitespaces from it.
40. To display S3 after removing all the trailing whitespaces from it.
41. To display S3 after removing all the leading and trailing whitespaces from it.
42. To display a list of all the words in the string S4, assuming that S4 is already defined.
43. To get a sorted (ascending order) list of the characters of S1.
44. To get a sorted (descending order) list of the characters of S2.
45. To store the largest character of S1 in variable high, and the smallest character of S2 in variable low. (The
largest character is the character with highest Unicode value and the smallest character is the character with
the lowest Unicode value)

If T1 = (1,2,3,2,1,2,4,2, . . . ) and T2= 'E', 'x', 'p', 'e', 'n', 's', 'e', 's', then
write a statement to perform each of the following tasks. Each task should be done using one statement only.
(Answer using built-in functions / methods, Slicing, and +, = ,+= operators only):
46. To create an empty tuple with name T3.
47. To create a tuple T4 with the string 'Campground' as its only element.
48. To create a tuple T5 which contains first 3 elements of T1 followed by last 3 elements of T2.
49. To display the number of elements in T2.
50. To display the total number of elements in T1 and T2.
51. To redefine T1 so that it contains all its existing elements followed by T2 as its last element.
52. To redefine T1 so that it contains all its existing elements followed by all the elements of T2.
53. To redefine T1 so that it contains its first 3 exiting elements, followed by T2 as an element, followed by all
the remaining elements of T1.
54. To count the occurrences of 'e' in T1.
55. To count the occurrences of T1[3] in T2.
56. To display the index of the first occurrence of 's' in the tuple T2.
57. To display the index of the second occurrence of 's' in the list T2.
58. To create a list L6 which stores the sorted elements of T1 without affecting T1.
59. To display the smallest element and the largest element of T1.
60. To display the sum of all the elements of T1.

If D1={1:'a', 2:'b', 3:'c'} and D2={"a":'apple','b':'ball','c':'cat'}, then write a


statement to perform each of the following tasks. Each task should be done using one statement only. (Answer
using built-in functions / methods, Slicing, and +, = ,+= operators only):
61. To create an empty dictionary with name D3.
62. To create a dictionary with the keys of D1 and value of each key should by None.
63. To display the number of elements in the dictionary D1.
64. To display a list of the keys of D1.
65. To display a tuple containing all the values of D2.
66. To display a list containing all the elements (key-value pairs) of the dictionary D1.
67. To add a key-value pairs 4:'d' and 5:'e' in the dictionary D1.
68. To display the value for the key 'b' from dictionary D2.
69. To delete all the elements from dictionary D2.
70. To create a copy of the dictionary D2 and name it as D3.
71. To delete the element D1[2] and display the corresponding value.
72. To delete the last element of D1 and display the corresponding key.
73. To delete the last element of dictionary D2 and display the corresponding value.
74. To display the value of D2[k] , where k is a variable. If the key k is not found in the dictionary D2, then the
statement should display None. D2 should not be changed.

www.yogeshsir.com Page: Q83/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

75. To display the value of D2[k] , where k is a variable. If the key k is not found in the dictionary D2, then
add the key value pair k:'Kite' and display the corresponding value (i.e., Kite).
76. To display a list of sorted keys of D1.
77. To display a list of sorted values of D2.
78. To display the value corresponding to the highest key of D1.
79. To display the value corresponding to the smallest key of D2.
80. To add all the key-value pairs of D1 to D2 (Assuming that D1 and D2 have no common key).

www.yogeshsir.com Page: Q84/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

Python - Writing Functions


1. Write a function sumEven(n1,n2), where n1 and n2 are positive integers such that n1<n2. The function
should return the sum of all the even integers between n1 and n2. For example, if n1=5 and n2=10, the
function should return 14 (6+8).
2. Write a function proDigits(n), where n is a positive integer. The function should return the product of
the digits of n. For example, if n=3214, then the function should return 24 (3x2x1x4).
3. Write a function countOddDigits(n), where n is a positive integer. The function should count and
display the number of odd digits in the number n. For example, if n=3214, then the function should display
"Number of odd digits = 2".
4. Write a function which accepts two lists, say A and B, as parameters. The function should delete all elements
from list A which are present in list B too. For example,
If A=[1,2,2,3,4,5,6,5,9,7,8,9] and B=[2,4,15,9,4,5,10,3], then after execution of the
function, the list A should be [1, 6, 7, 8]
5. Write a function which accepts a list, say A, as a parameter. The function should then exchange the values of
first half side elements with the second half side elements of the list.
For example,
if A=[2,4,1,6,7,9,23,10], then after the function execution, the list A should be
[7,9,23,10,2,4,1,6]
if A=[2,4,1,6,7,9,23], then after the function execution, the list A should be [7,9,23,6,2,4,1]
6. Write a function REVERSE(N), where N is a list. The function should reverse the contents of the list without
slicing the list and without using any second list.
Example: If the list initially contains 2, 15, 3, 14, 7, 9, 19, 6, 1, 10

then after reversal the list should contain 10, 1, 6, 19, 9, 7, 14, 3, 15, 2

7. Write a function Alternate(nums), where nums is a list. The function should rearrange the list nums in
such a way that the values of each pair of consecutive elements are interchanged. For example:
If the list initially contains 2, 5, 9, 14, 17, 8
Then after rearrangement the list should contain 5, 2, 14, 9, 8, 17

If the list initially contains 2, 5, 9, 14, 17, 8,10


Then after rearrangement the list should contain 5, 2, 14, 9, 8, 17,10

8. Write a function combine(A,B,C), where A and B are equi-sized lists of numbers, and C is an empty list.
The function should combine the elements of A and B into C such that C[i]=2*A[i]+3*B[i], where i
is a valid index.
9. Write a function in calculate(A), where A is a list of integers. The function should divide all the elements
of the list by 5 which are divisible by 5, and multiply the other list elements by 2.
10. Write a function merge(A,B,C) where A and B are equi-sized lists and C is an empty list. The function
should merge the elements of A and B into C such that all even positions of C are occupied by the elements of
A and all odd positions of C are occupied by the elements of B. For example:
If A=['a','b','c','d'] and B=[10,2,5,6], then C should be
['a',10,'b',2,'c',5,'d',6]
11. Write a function in replace(A), where A is a list of integers. The function should replace each element
of the list having even value with its half and each element having odd value with its double. For example, if
A=[3, 4, 5, 16, 9] then after execution of the function, the list A should be [ 6, 2, 10, 8, 18]
12. Write a function shortName(ft,md,last), where ft,md, and last are strings respectively
representing the first name, middle name, and the last name of a person. The function should return the short
name of the person. For example, if ft='Chander', md='Mohan', and last='Subramaniam', then
the function should return 'C. M. Subramaniam'.

www.yogeshsir.com Page: Q85/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

13. Write a function that accepts a string as a parameter and checks whether it is a palindrome or not. The checking
should not be case sensitive. The function should display 'Palindrome' or 'Not Palindrome' as per
the case.
14. Write a function to palindrome(n), where n is a positive integer. The function should input n strings from
the user and return the total number of palindrome strings entered by the user.
15. Write a function to input a string from the user and display the number of digits, number of uppercase
alphabets, number of lowercase alphabets, and number of whitespace characters appearing in the string. (space,
'\t', and '\n' are whitespace characters.)
16. Write a function to input a string and replace each occurrence of multiple consecutive spaces, if any, with a
single space in the string. Then return the resultant string. For example, if the user enters '1 2 3 4
5 6666 7 8', then the function should return '1 2 3 4 5 6666 7 8'.
17. Write a function to input a string and count the number of words not starting with an uppercase vowel in the
string. Two consecutive words may be separated by one or more white spaces.
18. Write a function characters(S), where S is a string. The function should return a list of distinct
characters appearing in the string S. For example, if S='Apple in Pineapple', then the function should
return ['A', 'p', 'l', 'e', ' ', 'i', 'n', 'P', 'a']
19. Write a function frequency(S), where S is a string. The function should display the frequency of each
alphabet appearing in the string. (Alphabet counting should not be case-sensitive) For example, if S= 'Shine
in 2025', then the output should be:
S - 1
H - 1
I - 2
N - 2
E - 1
Hint: Use a dictionary to form the frequency table.
20. Write a function sortWords(S), where S is a string. The function should display all the words of the string
in alphabetical order. For example, if S='NCERT CBSE NIOS KV', then the output should be:
['CBSE', 'KV', 'NCERT', 'NIOS']
21. Write a function vowelStar(S,ch), where S and ch are strings. The function should replace each lower
case vowel of the string S with the string ch, and return the resultant string. For example, if S='Enormous
Influence' and ch='i*', then the function should return 'Eni*rmi*i*s Infli*i*nci* '.

www.yogeshsir.com Page: Q86/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

Text File Operations


1. Write a function to count and display the number of spaces (not all white spaces) present in a text file
named "PARA.TXT".
2. Assuming that a text file named TEXT1.TXT already contains some text written into it, write a function
named vowelwords(), that reads the file TEXT1.TXT and creates a new file named TEXT2.TXT,
which shall contain only those words from the file TEXT1.TXT which don't start with an uppercase vowel
(i.e., with 'A', 'E', 'I', 'O', 'U'). For example, if the file TEXT1.TXT contains
Carry Umbrella and Overcoat When It rains
Then the text file TEXT2.TXT shall contain
Carry and When rains
(Consecutive words in TEXT2.TXT should be separated by space)
3. Write a function in PYTHON to count and display the number of lines ending with a vowel from a text
file "STORY.TXT".
4. Write a function in PYTHON to count and display the number of words starting with alphabet 'A' or 'a'
present in a text file "LINES.TXT".
Example:
If the file “LINES.TXT” contains the following lines,
A boy is playing there. There is a playground.
An aeroplane is in the sky.
Are you getting it?
The function should display the output as 5.
5. Write a function copy() that will copy all the words starting with an uppercase alphabet from an existing
file "FAIPS.TXT" to a new file "DPS.TXT". Consecutive words in DPS.TXT should be separated by a
space.
6. Write a function show(n) that will display the nth character from the existing file "MIRA.TXT". If the
total characters present are less than n, then it should display "invalid n". New line character ('\n')
should not be considered a character.
7. Write a function in PYTHON that counts the number of "Me" or "My" words present in a text file
"DIARY.TXT". If the "DIARY.TXT" contents are as follows:
My first book was Me and My
Family. It gave me chance to be
Known to the world.
The output of the function should be:
Count of Me/My in file: 4
8. Write a function in PYTHON to read the contents of a text file "Places.Txt" and display all those lines on
screen which are either starting with 'P' or with 'S'.
9. Write a function CountHisHer() in PYTHON which reads the contents of a text file “Gender.txt”
which counts the words His and Her (not case sensitive) present in the file.
For, example, if the file contains:
Pankaj has gone to his friend's house. His friend's name is Ravya.
Her house is 12KM from here.
The function should display the output:
Count of His: 2
Count of Her: 1
10. Write a function EUCount() in PYTHON, which should read each character of a text file "IMP.TXT",
should count and display the occurrences of alphabets E and U (including small cases e and u too).
Example:
If the file content is as follows:
Updated information
Is simplified by official websites.
www.yogeshsir.com Page: Q87/150 www.youtube.com/LearnWithYK
QB/XII/CS-083/2025/YK/Questions

The EUCount() function should display the output as:


E:4
U:1
11. Write function definition for SUCCESS() in PYTHON to read the content of a text file STORY.TXT,
count the presence of word SUCCESS and display the number of occurrence of this word.
Note :
– The word SUCCESS should be an independent word
– Ignore type cases (i.e. lower/upper case)
– A word in the file may end with a white space, a . (dot), or a , (comma).

Example :
If the content of the file STORY.TXT is as follows :
Success shows others that we can do it. It is possible to
achieve success with hard work. Lot of money does not mean
SUCCESS. Speak to successful people to know more.

The function SUCCESS() should display the following :

12. Write function definition for TOWER() in PYTHON to read the content of a text file WRITEUP.TXT,
count the presence of word TOWER and display the number of occurrences of this word.
Note :
- The word TOWER should be an independent word
- Ignore type cases (i.e. lower/upper case)
- A word in the file may end with a white space, a . (dot), or a , (comma).

Example:
If the content of the file WRITEUP.TXT is as follows:

Tower of hanoi is an interesting problem.


Mobile phone tower is away from here. Views
from EIFFEL TOWER are amazing. Only a few towers
provide such an amazing view.

The function TOWER () should display the following:

13. Write the function definition for WORD4CHAR() in PYTHON to read the content of a text file
FUN.TXT, and display all those words, which have four characters in it.
Example:
If the content of the file Fun.TXT is as follows:
When I was a small child, I used to play in the
garden with my grand mom. Those days were amazingly
funful and I remember all the moments of that time

The function WORD4CHAR() should display the following:

When used play with days were that time

www.yogeshsir.com Page: Q88/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

14. Write function definition for DISP3CHAR() in PYTHON to read the content of a text file
KIDINME.TXT, and display all those words, which have three characters in it. Example:
If the content of the file KIDINME.TXT is as follows:

When I was a small child, I used to play in the garden


with my grand mom. Those days were amazingly funfilled
and I remember all the moments of that time

The function DISP3CHAR() should display the following:

was the mom and all the

15. Write a function in Python to copy the contents of a text file into another text file. The names of the
files should be input from the user.
16. Write a function in Python which accepts two text file names as parameters. The function should
copy the contents of first file into the second file in such a way that all multiple consecutive spaces
are replaced by a single space. For example, if the first file contains:
Self conquest is the
greatest victory .
then after the function execution, second file should contain:
Self conquest is the
greatest victory .
17. Write a function to display the last line of a text file. The name of the text file is passed as an
argument to the function.
18. Write a Python function to read and display a text file 'BOOKS.TXT'. At the end display number of
lowercase characters, uppercase characters, and digits present in the text file.
19. Write a Python function to display the size of a text file after removing all the white spaces (blanks,
tabs, and New line characters).
20. Consider the following code:
ch = "A"
f=open("data.txt",'a')
f.write(ch)
print(f.tell())
f.close()
What is the output if the file content before the execution of the program is the string "ABC"? (Note that
" " are not the part of the string)
21. Write a single statement to display the contents of a text file named "abc.txt"
22. Write a function in PYTHON to display the last 3 characters of a text file "STORY.TXT".

www.yogeshsir.com Page: Q89/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

CSV File Operations


1. Write a Program in Python that defines and calls the following user defined functions:
(i) Append() – To accept and add data of an item to a csv file 'furniture.csv'. Each record of the
file is a list [Fur_id, Description, Price, Discount]. Fur_Id and Description
are of str type, Price is of int type, and Discount is of float type.
(ii) countRec() – To count and display the number of records present in 'furniture.csv' whose
price is less than 5000.
2. Write a Program in Python that defines and calls the following user defined functions:
(i) ADD() – To accept and add data of an employee to a CSV file 'record.csv'. Each record consists
of a list with field elements as empid, name and mobile to store employee id, employee name
and employee mobile number respectively.
(ii) COUNTREC() – To count the number of records present in the CSV file named 'record.csv'.
3. Write a Program in Python that defines and calls the following user defined functions:
(i) addCust(): To add the given records in a csv file "cust.csv". Each record of the file contains
CustCode, CustName, and BillAmt. The records to be added are:
['001'*'Nihir'*8000] and ['104'*'Akshay'*5000]
(Note: The delimiter should be '*' (an asterisk) instead of a ',' (a comma) )
(ii) readCust(): To read the details of the customers and display them.
4. Write a Program in Python that defines and calls the following user defined functions:
(i) getlnventory() : To accept an inventory record from the user and append it to the csv file
Inventory.csv. The record contains I_Code (str), Inv_name (str), Price (int), Reorder
(int).
(ii) Search(code) : To accept an I_Code as a parameter and display the corresponding record
from the file Inventory.csv. The function should display a message 'Record not found',
if the record is not found in the file.
5. Write a Program in Python that defines and calls the following user defined functions:
(i) add() – To accept and add data of a record to a CSV file 'furdata.csv'. Each record consists
of a list with field elements as fid, fname and fprice to store furniture id, furniture
name and furniture price respectively.
(ii) search() - To display the records of the furniture whose price is more than 10000. If
no such record is found, then the function should display the message "No item with
price more than 10000".
6. Ramya is a programmer who has recently been given a task to write a Python code to perform the
following CSV file operations with the help of two user defined functions:
(i) addRecs() : to open a CSV file BOOKS.CSV in append mode and write three records in the
file. Each record of the file contains the information of books – Title, Author and Price.
(ii) readRecs() : to display the records from the CSV file BOOKS.CSV where the field Title
starts with 'K'.
She has succeeded in writing partial code and has missed out certain statements, so she has left
certain queries in comment lines.
import csv
def AdRecs():
with open('books.csv','_',newline='') as csvf: #Statement-1
cw=______ #Statement-2
______ #Statement-3
cw.writerow(['Rapunzel','Jack',300])
cw.writerow(['Barbie','Doll',900])
cw.writerow(['Johnny','Jane',280])

www.yogeshsir.com Page: Q90/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

def CSVRead():
try:
with open('books.csv','r') as csvf:
cr=______ #Statement-4
for r in cr:
if ______: #Statement-5
print(r)
except:
print('File Not Found')
CSVOpen()
CSVRead()

You, as an expert of Python, have to provide the missing statements and other related queries
based on the above code of Ramya.
(a) Write the appropriate mode in which the file is to be opened. (Statement 1)
(b) Which statement will be used to create a csv writer object in Statement 2.
(c) Write the correct option for Statement 3 to write the names of the column headings in the CSV
file books.csv
(d) Write statement to be used to read the csv file in Statement 4.
(e) Fill in the appropriate statement to check the field Title starting with 'K' for Statement 5.
7. Following is an incomplete python code to create a CSV File 'Student.csv' (content shown below).
Complete the code by filling in the missing parts.

CSV File
1,AKSHAY,XII,A
2,ABHISHEK,XII,A
3,ARVIND,XII,A
4,RAVI,XII,A
5,ASHISH,XII,A

Incomplete Code
import__________ #Statement-1
fh = open(________, _____, newline='') #Statement-2
stuwriter = csv._____ #Statement-3
data = []
header = ['ROLL_NO', 'NAME', 'CLASS', 'SECTION']
data.append(header)
for i in range(5):
roll_no = int(input("Enter Roll Number : "))
name = input("Enter Name : ")
Class = input("Enter Class : ")
section = input("Enter Section : ")
rec = [_____] #Statement-4
data.append(rec)
stuwriter. _____ (data) #Statement-5
fh.close()

www.yogeshsir.com Page: Q91/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

8. Following is an incomplete python code to create a CSV File 'Student.csv' (content shown below).
Complete the code by filling in the missing parts by following the hints a) to d)

_________________ #Statement 1
headings = ['Country','Capital','Population']
data = [['India', 'Delhi',130],['USA','WashingtonDC',50],
[Japan,Tokyo,2]]
f = open('country.csv','w', newline="")
csvwriter = csv.writer(f)
csvwriter.writerow(headings)
________________ #Statement 2
f.close()
f = open('country.csv','r')
csvreader = csv.reader(f)
head=_________________ #Statement 3
print(head)
for x in __________: #Statement 4
if int(x[2])>50:
print(x)
a) Statement 1 – Write the python statement that will allow Sudheer work with csv files.
b) Statement 2 – Write a python statement that will write the list containing the data available as a
nested list in the csv file
c) Statement 3 – Write a python statement to read the header row in to the head object.
d) Statement 4 – Write the object that contains the data that has been read from the file.
9. Manoj Kumar is writing a program to create a CSV file "user.csv" which will contain user name and
password for some entries. He has written the following code. As a programmer, help him to
successfully execute the given task.
import ______________ #Line1
def addCsvFile(UserName, Password):
fh=open('user.csv','_',newline='') #Line2
Newfilewriter=csv.writer(fh)
Newfilewriter.writerow([UserName,Password])
fh.close()
# csv file reading code
def readCsvFile(): #to read data from CSV file
with open('user.csv','r') as newFile:
newFileReader=csv.______(newFile) #Line3
for row in newFileReader:
print(row)
addCsvFile('Arjun','123@456')
addCsvFile('Arunima','aru@nima')
addCsvFile('Frieda','myname@FRD')
readCsvFile()

OUTPUT___________________ #Line 4

(a) What module should be imported in #Line1 for successful execution of the program?
(b) In which mode file should be opened to work with user.csv file in #Line2
(c) Fill in the blank in #Line3 to read data from csv file
(d) Write the output he will obtain by executing the code in #Line5

www.yogeshsir.com Page: Q92/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

Binary File Operations


1. Given a binary file "STUDENT.DAT", containing records of the following type:
[S_Admno, S_Name, Percentage]
Where these three values are:
S_Admno – Admission Number of student (string)
S_Name – Name of student (string)
Percentage – Marks percentage of student (float)
Write a function in PYTHON that would read contents of the file "STUDENT.DAT" and display the
details of those students whose percentage is above 75.
2. Assuming the tuple Vehicle as follows:
(vehicletype, no_of_wheels)
Where vehicletype is a string, and no_of_wheels is an integer.
Write a function showfile() to read all the records present in an already existing binary file
SPEED.DAT and display them on the screen. Also, count and display the number of records
present in the file.
3. Write a function in PYTHON to search for a BookNo from a binary file "BOOK.DAT", assuming
the binary file is containing the records of the following type:
{"BookNo":value, "Book_name":value}
Assume that BookNo is an integer.
4. Assuming that a binary file VINTAGE.DAT contains records of the following type, write a function
in PYTHON to read the data VINTAGE.DAT and display those vintage vehicles, which are priced
between 200000 and 250000.
[VNO, VDesc, price]
5. A binary file LAPTOP.DAT contains records of the following type:
[ModelNo, RAM, HDD, Details]
where ModelNo, RAM, HDD are integers, and Details is a string.
Write the following functions:
(a) AddRec(): to append a record to the file by inputting the data from the user.
(b) Search(): to search for a laptop from a binary file "LAPTOP.DAT". The user should enter
the model number and the function should display the details of the laptop.
6. A binary file, MIC.DAT, contains data of some mics in an electronics shop. Each record is stored
as a dictionary in the following format:
{Code: [Brand, Type, Cost]}
(Code, Brand, Type are strings, Price is integer)
Write the following functions in Python:
(a) AddRec():to append a record to the file by inputting the data from the user.
(b) ShowBT(): To display all the records of type 'BT'. Also display the total number of such
records found in the file.
7. Write a function in PYTHON to read the records from binary file GAMES.DAT and display the
details of those games, which are meant for children of AgeRange "8 to 13". Assume that the file
GAMES.DAT contains records of the following type:
[GameCode, GameName, AgeRange]
8. Write the definition for function SALE() in PYTHON to update a binary file GIFTS.DAT. The
function should update the Remarks of each record as "ON SALE", and decrease the Price by
50%. Each record of the GIFTS.DAT is a dictionary with the following structure:
{ID: [Gift, Remarks, Price])
9. Write the definition for function BUMPER() in PYTHON to read each object of a binary file
GIFT.DAT. The function should find and display details of those gifts, which have remarks as "ON
SALE". Assume that each record of the file GIFT.DAT is a tuple with the following structure:
(ID, Gift, Remarks, Price)
www.yogeshsir.com Page: Q93/150 www.youtube.com/LearnWithYK
QB/XII/CS-083/2025/YK/Questions

10. Write a function in PYTHON to update a binary file "LAPTOP.DAT" containing the records of
following type.
[ModelNo, RAM, HDD, Details]
where ModelNo, RAM, HDD are integers, and Details is a string.
The function should update the RAM to 16 for all those records where HDD is 1024 or above.
11. Write a function in PYTHON to update a binary file "BOOK.DAT", assuming the binary file is
containing the records of the following type:
{"BookNo":value, "Book_name":value}
The function should add a key-value pair to each record. The key should be "Edition" and
value should be input from the user.
12. Following is the structure of each record in a data file named "PRODUCT.DAT".
{"p_code":value, "p_desc":value, "stock":value}
The values for p_code and prod_desc are strings, and the value for stock is an integer.
Write a function in PYTHON to delete all those records from the file where prod_desc is a blank
string.
13. A binary file, MIC.DAT, contains data of some mics in an electronics shop. Each record is stored
as a dictionary in the following format:
{Code: [Brand, Type, Cost]}
(Code, Brand, Type are strings, Price is integer)
Write a function in Python to delete all those records from the file whose Type is 'BT'.
14. A binary file, SPEED.DAT, contains records with the following structure:
(vehicletype, no_of_wheels)
Where vehicletype is a string, and no_of_wheels is an integer.
Write a function copy4w() to copy all those records, where no_of_wheels is 4, from SPEED.DAT
to a new file Four_Wheels.DAT.
15. A binary file, MIC.DAT, contains data of some mics in an electronics shop. Each record is stored
as a dictionary in the following format:
{Code: [Brand, Type, Cost]}
(Code, Brand, Type are strings, Price is integer)
Write a function in Python to remove all those records from the file whose Type is 'BT' and write
these to a new binary file BT.DAT.
16. Write a function which takes two file names as parameters. The function should read the first file
(a text file), and stores the index of this file in the second file (a binary file). The index should tell
the line numbers in which each of the words appear in the first file. If a word appears more than
once, the index should contain all the line numbers containing the word.

www.yogeshsir.com Page: Q94/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

Stacks
1. What is a stack? In Python, should we implement stacks using a list or a tuple? Justify your answer.
2. Define PUSH and POP operations w.r.t. stacks.
3. Give any two characteristics of stacks.
4. Expand the term LIFO. Which data structure facilitates LIFO operations?
5. Julie has created a dictionary containing names and marks as key:value pairs of 6 students. Write a program,
with separate user defined functions to perform the following operations:
• Push the keys (name of the student) of the dictionary into a stack, where the corresponding value
(marks) is greater than 75.
• Pop and display the content of the stack.
For example, if the sample content of the dictionary is as follows:
R={"OM":76, "JAI":45, "BOB":89, "ALI":65, "ANU":90, "TOM":82}
The output from the program should be:
TOM ANU BOB OM
6. Alam has a list containing 10 integers. You need to help him create a program with separate user defined
functions to perform the following operations based on this list.
• Traverse the content of the list and push the even numbers into a stack.
• Pop and display the content of the stack.
For Example, if the sample Content of the list is as follows:
N=[12, 13, 34, 56, 21, 79, 98, 22, 35, 38]
Sample Output of the code should be:
38 22 98 56 34 12
7. Jomia has created the following dictionary containing Indian names of some herbs and their corresponding
names in English:
Herbs={'Adrak':'Ginger', 'Amla': 'Gooseberry', 'Babool': 'Indian
Gum', 'Dhania': 'Coriander', 'Lahsun':'Garlic', 'Tulsi': 'Basil'}
Write a program, with separate user defined functions to perform the following operations:
• Push the item (key, value pair) of the dictionary into a stack, where the corresponding value
(English name) starts with 'G'.
• Pop and display the content of the stack.
8. Write a program to input an integer and display all its prime factors in descending order, using a stack. For
example, if the input number is 2100, the output should be: 7 5 5 3 2 2 (because prime factorization of 2100
is 7x5x5x3x2x2)
Hint: Smallest factor of any integer is guaranteed to be prime.
9. Ismail has created the following list:
from random import randint
nums=[randint(10,99) for I in range(20)]
Write a program, with separate user defined functions to perform the following operations:
• Push the even numbers from the list into a stack, and then push all the odd numbers from
the list into the same stack.
• Pop and display the content of the stack.

10. Consider a stack S as follows:

www.yogeshsir.com Page: Q95/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

Assuming standard definitions of functions PUSH() and POP(), redraw the stack after performing each of
the following operations:
POP(S); POP(S); PUSH(S,8); PUSH(S,3); POP(S); PUSH(S,9)
11. Find the output of the following code:
stack=[]
def push(s,n):
s.append(n)
def pop(s):
if s!=[]:
return s.pop()
print(pop(stack))
push(stack,5); push(stack,10)
pop(stack); push(stack,5)
print(pop(stack)*2)
push(stack,6)
push(stack,'a')
pop(stack); push(stack,'b')
print(pop(stack))
print(stack[0],stack[-1])
print(len(stack))

12. Consider a stack S as follows:

Assuming standard definitions of functions PUSH() and POP(), redraw the stack after performing each of
the following set of operations:
PUSH(S,8); POP(S); PUSH(S,3); POP(S); POP(S); PUSH(S,9)

13. A list contains following record of a customer:


[Customer_name, Phone_number, City]
Write the following user defined functions to perform given operations on the stack named 'status':
(i) Push_element() - To Push an object containing name and Phone number of customers
who live in Goa to the stack
(ii) Pop_element() - To Pop the objects from the stack and display them. Also, display
"Stack Empty" when there are no elements in the stack.
For example:
If the lists of customer details are:
["Gurdas", "99999999999","Goa"]
["Julee", "8888888888","Mumbai"]
["Murugan","77777777777","Cochin"]
["Ashmit", "1010101010","Goa"]
The stack should contain
["Ashmit","1010101010"]
["Gurdas","9999999999"]
The output should be:
["Ashmit","1010101010"]
["Gurdas","9999999999"]
Stack Empty
www.yogeshsir.com Page: Q96/150 www.youtube.com/LearnWithYK
QB/XII/CS-083/2025/YK/Questions

14. Write a function in Python, Push(SItem) where , SItem is a dictionary containing the details of stationary
items in the format {Sname:price}.
The function should push the names of those items in the stack who have price greater than 75. Also display
the count of elements pushed into the stack.
For example:
If the dictionary contains the following data:
Ditem={"Pen":106,"Pencil":59,"Notebook":80,"Eraser":25}
The stack should contain
Notebook
Pen
The output should be:
The count of elements in the stack is 2

www.yogeshsir.com Page: Q97/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

www.yogeshsir.com Page: Q98/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

(II) Database Management

www.yogeshsir.com Page: Q99/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

Database Management MCQs


1. RDBMS is:
a) Relational Database Management System b) Relative Database Management System
c) Rational Database Management System d) Relational Data and Management System

2. MySQL is a/an:
a) Database b) Relational Database
c) RDBMS d) Table

3. A Relational Database may contain:


a) Multiple Databases b) Relational Databases
c) Multiple Tables d) All of these

4. The tables in a relational database:


a) are always interrelated b) must be interrelated
c) may be interrelated d) are never interrelated

5. A table in a relational database:


a) always has a Primary Key b) may have a Primary Key
c) must have a Primary Key d) can be a Primary Key

6. The Primary Key of a table:


a) can never have duplicate values b) may have duplicate values
c) may have Null entries d) always has fixed values

7. All the Alternate Keys of a relation are:


a) Candidate Keys b) Primary Keys
c) Foreign Keys d) Composite Keys

8. A Primary Key with multiple columns is called


a) Candidate Key b) Alternate Key
c) Foreign Key d) Composite Key

9. A table cannot have multiple


a) Candidate Keys b) Primary Keys
c) Alternate Keys d) Foreign Keys

10. A table with multiple Candidate Keys


a) may have a Primary Key b) must have a Primary Key
c) may have multiple Primary Keys d) must have multiple Primary Keys

11. Foreign Key of a table must be the:


a) Primary Key of the same table b) Primary Key of another table
c) Alternate Key of the table d) non-Key attribute

12. Which of the following constraints allows Null but does not allow duplicate values?
a) Primary Key b) Foreign Key
c) Not Null d) Unique

13. Which of the following constraints does not allow Null but allows duplicate values?
a) Primary Key b) Foreign Key
c) not null d) unique

14. Number of columns in a table is called its


a) Length b) Domain
c) Cardinality d) Degree

www.yogeshsir.com Page: Q100/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

15. Number of rows in a table is called its


a) Length b) Domain
c) Cardinality d) Degree

16. Domain of a column is a


a) Key b) name
c) table d) set

17. If a table has 5 rows and 3 columns then its degree is:
a) 3 b) 5
c) 8 d) 15

18. If a table has 5 rows and 3 columns then its cardinality is:
a) 3 b) 5
c) 8 d) 15

19. A table contains data of 50 students of a class. The table has 6 columns. The roll numbers of the students
are integers from 51 to 100. What is the degree of this table?
a) 50 b) 6
c) 51 d) set of integers from 51 to 100.

20. A table contains data of 50 students of a class. The table has 6 columns. The roll numbers of the students
are integers from 51 to 100. What is the cardinality of this table?
a) 50 b) 6
c) 51 d) set of integers from 51 to 100.

21. A table contains data of 50 students of a class. The table has 6 columns. The roll numbers of the students
are integers from 51 to 100. What is the domain of the column RollNumber?
a) 50 b) 6
c) 51 d) set of integers from 51 to 100.

22. A table contains data of 10 students of a class. The domain of the column Name is the set {'Aman',
'Daman', 'Gaman', 'Naman', 'Raman', 'Yaman'}. What is the degree of this table?
a) 1 b) 6
c) 10 d) Cannot be determined with the given information.

23. A table contains data of 10 students of a class. The domain of the column Name is the set {'Aman',
'Daman', 'Gaman', 'Naman', 'Raman', 'Yaman'}. What is the cardinality of this table?
a) 1 b) 6
c) 10 d) Cannot be determined with the given information.

24. A table contains data of 10 students of a class. The domain of the column Name is the set {'Aman',
'Daman', 'Gaman', 'Naman', 'Raman', 'Yaman'}. What is the best suitable datatype
for the column Name of this table?
a) char b) varchar
c) int d) float

25. The degree of the cartesian product of two tables is


a) sum of the degrees of the tables b) product of the degrees of the table
c) sum of the cardinalities of the tables d) product of the cardinalities of the tables.

26. The cardinality of the cartesian product of two tables is


a) sum of the degrees of the tables b) product of the degrees of the table
c) sum of the cardinalities of the tables d) product of the cardinalities of the tables.

www.yogeshsir.com Page: Q101/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

27. A relational database contains two tables A and B. The degrees of A and B are 5 and 6 respectively.
The cardinalities of A and B are 15 and 20 respectively. If there is a column named Sno in both the
tables A and B, then what is the degree of the Cartesian Product of A and B?
a) 10 b) 11
c) 35 d) 300

28. A relational database contains two tables A and B. The degrees of A and B are 5 and 6 respectively.
The cardinalities of A and B are 15 and 20 respectively. If there is a column named Sno in both the
tables A and B, then what is the cardinality of the Cartesian Product of A and B?
a) 10 b) 11
c) 35 d) 300

29. A relational database contains two tables A and B. The degrees of A and B are 5 and 6 respectively.
The cardinalities of A and B are 15 and 20 respectively. If there is a column named Sno in both the
tables A and B, then what is the degree of the Natural Join of A and B?
a) 10 b) 11
c) 35 d) 300

30. A relational database contains two tables A and B. The degrees of A and B are 5 and 6 respectively.
The cardinalities of A and B are 15 and 20 respectively. If there is no common column in the tables A
and B, then what is the degree of the Cartesian Product of A and B?
a) 10 b) 11
c) 35 d) 300

31. A relational database contains two tables A and B. The degrees of A and B are 5 and 6 respectively.
The cardinalities of A and B are 15 and 20 respectively. If there is no common column in the tables A
and B, then what is the cardinality of the cartesian product of A and B?
a) 10 b) 11
c) 35 d) 300

32. A relational database contains two tables A and B. The degrees of A and B are 5 and 6 respectively.
The cardinalities of A and B are 15 and 20 respectively. If there is no common column in the tables A
and B, then what is the degree of the natural join of A and B?
a) 10 b) 11
c) 35 d) 300

33. Some SQL commands are categorized as DML commands. DML stands for:
a) Disk Manipulation Language b) Data Management Language
c) Disk Management Language d) Data Manipulation Language

34. Some SQL commands are categorized as DDL commands. DDL stands for:
a) Disk Description Language b) Data Definition Language
c) Disk Definition Language d) Data Description Language

35. DDL commands of SQL:


a) cannot change the structure of the database b) change the structure of the database
c) can change the data in a table d) are used to define DDL commands

36. DML commands of SQL:


a) cannot change the structure of the database b) change the structure of the database
c) can change the data in a table d) are used to define DML commands

37. Which of the following is a DDL command in SQL?


a) Update b) Alter
c) Insert d) Select

www.yogeshsir.com Page: Q102/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

38. Which of the following is not a DDL command in SQL?


a) Create b) Alter
c) Insert d) Drop

39. Which of the following is a DML command in SQL?


a) Create b) Alter
c) Insert d) Drop

40. Which of the following is Not a DML command in SQL?


a) Update b) Alter
c) Insert d) Select

41. Which of the following is a DDL command in SQL?


a) Update b) Select
c) Insert d) Drop

42. Which SQL command is used to create a database?


a) Create b) Alter
c) Insert d) Drop

43. Which SQL command is used to view the list of available databases?
a) View Databases; b) Show Databases;
c) List Databases; d) Desc Databases;

44. Which SQL command is used to activate/select a database?


a) View b) Show
c) Select d) Use

45. Which SQL command is used to view the list of available tables in the current database?
a) View tables; b) Show tables;
c) List tables; d) Desc tables;

46. Which SQL command is used to view the structure of a table?


a) Select b) Show
c) Desc d) Disp

47. Which SQL command is used to add new columns to an existing table?
a) Update b) Alter
c) Insert d) Select

48. Which SQL command is used to remove columns from an existing table?
a) Update b) Alter
c) Insert d) Select

49. Which SQL command is used to add constraints to an existing table?


a) Update b) Alter
c) Insert d) Select

50. Which SQL command is used to remove constraints from an existing table?
a) Update b) Alter
c) Insert d) Select

51. Which SQL command is used to delete a table from a database?


a) Update b) Alter
c) Delete d) Drop

www.yogeshsir.com Page: Q103/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

52. Which SQL command is used to add new records to a table?


a) Update b) Alter
c) Insert d) Select

53. Which SQL command is used to delete records from a table?


a) Update b) Alter
c) Delete d) Drop

54. Which SQL command is used to make changes to existing data in a table?
a) Update b) Alter
c) Insert d) Select

55. Which SQL command is used to retrieve data from a table?


a) Update b) Alter
c) Insert d) Select

56. Which SQL command does not affect the data or structure of a table?
a) Update b) Alter
c) Insert d) Select

57. Which of the following clauses is used to retrieve sorted data from a table?
a) distinct b) group by
c) order by d) like

58. Which of the following clauses is used to specify pattern matching condition in where clause?
a) distinct b) group by
c) order by d) like

59. Which of the following clauses is used to specify that duplicate entries from a column are not required
to be selected?
a) distinct b) group by
c) order by d) like

60. If a table Employee has a column Name, then what will be the output of the following query:
Select * from employee where name like '_A%';
a) All the records of the table. b) All the records of the table in which Name
contains A.
c) All the records of the table in which A is the d) All the records of the table in which A is the
second character of the Name. second last character of the Name.

61. If a table Employee has a column Name, then what will be the output of the following query:
Select * from employee where name like '%A%';
a) All the records of the table. b) All the records of the table in which Name
contains A.
c) All the records of the table in which A is the d) All the records of the table in which A is the
second character of the Name. second last character of the Name.

62. If a table Employee has a column Name, then what will be the output of the following query:
Select * from employee where name like '%A_';
a) All the records of the table. b) All the records of the table in which Name
contains A.
c) All the records of the table in which A is the d) All the records of the table in which A is the
second character of the Name. second last character of the Name.

www.yogeshsir.com Page: Q104/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

63. If a table Employee has a column Name, then what will be the output of the following query:
Select * from employee where name like '%A';
a) All the records of the table in which A is the b) All the records of the table in which Name
last character of Name. does not contain A.
c) All the records of the table in which A is the d) All the records of the table in which A is the
second character of the Name. second last character of the Name.

64. If a table Employee has a column Name, then what will be the output of the following query:
Select * from employee where name like '%A' or name like 'A%';
a) All the records of the table in Name start b) All the records of the table in which Name
with A and ends with A. is AA.
c) All the records of the table in which Name d) All the records of the table in which Name
starts and ends with A. contains A in the beginning or end or at both
places.

65. If a table Employee has a column Name, then choose the query which can replace the following query:
Select * from employee where name like '%A' and name like 'A%';
a) Select * from employee where b) Select * from employee where
name like 'A%A'; name like '%A%';
c) Select * from employee where d) Select * from employee where
name like '%AA%'; name like 'A%A%';

66. If a table Employee has a column Name, then choose the query which can replace the following query:
Select * from employee where name in ('Dua','Jaz','Raj');
a) Select * from employee where name like ('Dua','Jaz','Raj');
b) Select * from employee where name=('Dua','Jaz','Raj');
c) Select * from employee where name='Dua' and name='Jaz' and
name='Raj';
d) Select * from employee where name='Dua' or name='Jaz' or
name='Raj';

67. If a table Employee has a column Name, then choose the query which can replace the following query:
Select * from employee where name not in ('Dua','Jaz','Raj');
a) Select * from employee where name not like ('Dua', 'Jaz',
'Raj');
b) Select * from employee where name!=('Dua','Jaz','Raj');
c) Select * from employee where name!='Dua' and name!='Jaz' and
name!='Raj';
d)Select * from employee where name!='Dua' or name!='Jaz' or
name!='Raj';

68. If a table Employee has a column Age, then choose the query which can replace the following query:
Select * from employee where Age between 24 and 55;
a) Select * from employee where Age>=24 and Age<=55;
b) Select * from employee where Age>=24 or Age<=55;
c) Select * from employee where Age>24 and Age<55;
d)Select * from employee where Age>24 or Age<55;;

www.yogeshsir.com Page: Q105/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

69. If a table Employee has a column Age, then what will be the output of the following query:
Select * from employee where Age>35;
a) All the records of the table in which Age is b) All the records of the table in which Age is
more than 35. 35 or more.
c) All the records of the table in which Age is d) No output - The query has an error.
35 and more.

70. If a table Employee has a column Age, then what will be the output of the following query:
Select * from employee having Age>=35;
a) All the records of the table in which Age is b) All the records of the table in which Age is
more than 35. 35 or more.
c) All the records of the table in which Age is d) No output - The query has an error.
35 and more.

71. Which of the following is not an aggregate function in SQL?


a) sum() b) avg()
c) count() d) mean()

72. Which aggregate function in SQL can be used to find the cardinality of a table?
a) sum() b) max()
c) count() d) None of these

73. Which aggregate function in SQL never returns a negative number?


a) sum() b) max()
c) count() d) None of these

74. Aggregate functions ignore:


a) zeroes b) NULL entries
c) Negative numbers d) Date data

75. Which aggregate function in SQL is valid for numeric data only?
a) sum() b) max()
c) count() d) min()

76. A table T1 has a field F1 of char(10) type. The table contains only two records and the column
F1contains the values 'p' and '8'. In this context what will be the output of the following query?
Select sum(F1) from T1;
a) 8 b) '8'
c) 0 d) Error

77. A table T1 has a field F1 of char(10) type. The table contains only two records and the column
F1contains the values 'p' and '8'. In this context what will be the output of the following query?
Select avg(F1) from T1;
a) 8 b) '8'
c) 4 d) '4'

78. If a table Employee has a column Age, then what will be the output of the following query:
Select count(Age) from employee;
a) Number of records in the table. b) Number of records in which Age is not
NULL.
c) Number of records in which Age can be d) All the value of Age column.
counted.

www.yogeshsir.com Page: Q106/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

79. If a table Employee has a column Age, then what will be the output of the following query:
Select count(Age) from employee;
a) Number of records in the table. b) Number of records in which Age is not
NULL.
c) Number of records in which Age can be d) All the value of Age column.
counted.

80. If a table Employee has columns Dept and Age, then which of the queries will retrieve the data
sorted on Dept, and sorted on Age within each Dept:
a) Select * from employee order by Dept and Age;
b) Select * from employee order by Dept within Age;
c) Select * from employee order Dept, Age;
d)Select * from employee order by Dept+Age;

81. If a table Employee has columns Dept and Age, then which of the queries will retrieve the data in
the ascending order of Dept, and sorted in descending order of Age within each Dept:
a) Select * from employee order by Dept-Age;
b) Select * from employee order by Dept, Age desc;
c) Select * from employee order Dept, Desc Age;
d)Select * from employee order by Dept, reverse Age;

82. If a table Employee has columns Dept and Age, then which of the queries will retrieve the data
showing average Age in each Dept:
a) Select avg(age) from employee order by Dept;
b) Select dept, age from employee group by Dept;
c) Select avg(age), dept from dept wise;
d)Select dept, avg(age) from employee group by dept;

83. Which of the following queries will add a column BALANCE, of type int, to the table ITEM:
a) Alter table item set Balance (int);
b) Alter table ITEM add Balance (int);
c) Alter table item add column Balance int;
d)Alter table item set column Balance int;

84. Which of the following queries will add a columns BALANCE and GRP, of type int and CHAR(5)
respectively, to the table ITEM:
a) Alter table item add balance int, grp char(5);
b) A Alter table item add (balance int, grp char(5));
c) Alter table item add (balance, grp int,char(5));
d)Alter table item (balance int, grp char(5);

85. Which of the following queries will remove the column BALANCE from the table ITEM:
a) Alter table item delete column balance;
b) Alter table item drop column balance;
c) Alter item delete column balance;;
d)Alter item drop balance;

www.yogeshsir.com Page: Q107/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

86. Which of the following is not a valid difference between DELETE and DROP commands of SQL:
a) DELETE is a DML command and DROP is a DDL command;
b) DELETE can delete a table whereas DROP can DROP a table.
c) DELETE affects the data whereas DROP affects the structure of the database;
d) DELETE can reduce the cardinality of a table, whereas DROP can change the Degree of a
table

87. If a table Employee has columns Code, Dept and Age, then which of the following queries will
make Code the Primary Key of the table:
a) Alter table employee set Primary Key (Code);
b) Update employee set Code = Primary Key;
c) Alter table employee add Primary Key (Code);
d)Update table employee add Primary Key (Code);

88. If the column Code is the Primary Key of a table Employee, then which of the following queries will
remove the Primary Key of the table:
a) Alter table employee delete Code;
b) Update employee set Primary Key = None;
c) Alter table employee drop Primary Key;
d)Update table employee drop Primary Key (Code);

89. If a table Employee has columns Proj, Dept,DOS and DOE, then which of the following queries
will make Proj+Dept the Primary Key of the table:
a) Alter table employee set Primary Key (Proj), Primary Key(Dept);
b) Alter table employee set Primary Key (Proj+Dept);
c) Alter table employee set Primary Key (Proj,Dept);
d) Alter table employee set Primary Keys (Proj,Dept);

90. If a table Employee has a composite Primary Key consisting of columns Proj and Dept, then which
of the following statements is False:
a) Proj column cannot accept NULL
b) Dept column cannot accept NULL
c) One of the columns Proj or Dept can be NULL for a record
d) Neither of the columns Proj or Dept can be NULL for any record

91. If two table A and B, in a database, have a common field named Code, then which of the following
commands will display the cartesian product of these two tables:
a) Select * from A and B;
b) Select Code from A, B;
c) Select * from A,B;
d)Select * from A cartesian B;

92. If two table A and B, in a database, have a common field named Code, then which of the following
commands will display the natural join of these two tables:
a) Select * from A natural B;
b) Select * from A natural join B;
c) Select * from A,B;
d)Select * from A, B join on Code;

www.yogeshsir.com Page: Q108/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

93. If two table A and B, in a database, have a common field named Code, then which of the following
commands will show an error:
a) Select * from A, B;
b) Select Code from A, B;
c) Select Code from A natural join B
d)Select * from A natural join B;

94. If two table A and B, in a database, have a common field named Code, then which of the following
statements is True:
a) Code will not appear in the cartesian product of A and B
b) Code will appear once in the cartesian product of A and B
c) Code will appear twice in the cartesian product of A and B
d) None of the above

95. If two table A and B, in a database, have a common field named Code, then which of the following
statements is False:
a) Code will appear once in the natural join of A and B
b) Code will appear twice in the cartesian product of A and B.
c) Cardinality of the Cartesian product of A and B will be more than the cardinality of natural
join of A and B.
d) Cardinality of the Cartesian product of A and B will be less than or equal to the cardinality
of natural join of A and B.

96. In context of Python - Database connectivity, the function fetchone() is a method of which
object?
a) connection b) database
c) cursor d) query

97. In context of Python - Database connectivity, the function commit() is a method of which object?
a) connection b) database
c) cursor d) query

98. In context of Python - Database connectivity, the function execute() is a method of which object?
a) connection b) database
c) cursor d) query

99. In context of Python - Database connectivity, the function cursor() is a method of which object?
a) connection b) database
c) cursor d) query

100. In context of Python-Database connectivity, rowcount is a/an:


a) property/attribute b) method
c) object d) literal

www.yogeshsir.com Page: Q109/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

Database Management Assertion Reasoning based Questions


Following are Assertion(A) and Reasoning(R) based questions. Mark the correct choice as:
(A) Both A and R are true and R is the correct explanation for A
(B) Both A and R are true and R is not the correct explanation for A
(C) A is True but R is False
(D) A is False but R is True
1. Assertion (A): Tables in a database are usually interrelated.
Reasoning (R): A database contains multiple tables representing different entities of an organization.
2. Assertion (A): SQL is a standard language for accessing and manipulating databases.
Reasoning (R): SQL stands for Structured Query Language.
3. Assertion (A): The PRIMARY KEY constraint uniquely identifies each record in a database table.
Reasoning (R): A table can have multiple PRIMARY KEY constraints
4. Assertion (A): The degree of a table is the number of columns in it.
Reasoning (R): The cardinality of a table is the numbers of records in it.
5. Assertion (A): The number of Alternate Keys of a table can be more than the number of its Candidate
Keys.
Reasoning (R): Each Alternate Key is a Candidate Key.
6. Assertion (A): The number of Alternate Keys of a table cannot be more than the number of its
Candidate Keys.
Reasoning (R): Each Alternate Key is a Candidate Key.
7. Assertion (A): The number of Alternate Keys of a table cannot be more than the number of its
Candidate Keys.
Reasoning (R): Each Candidate Key is an Alternate Key.
8. Assertion (A): The domains of two columns of a table cannot be the same.
Reasoning (R): Domain of a column is the set of valid values for that column.
9. Assertion (A): The domains of two columns of a table can be the same.
Reasoning (R): Domain of a column is the set of valid values for that column.
10. Assertion (A): We can add more records in a table after deleting all its records.
Reasoning (R): Deleting records from a table does not destroy the table.
11. Assertion (A): We cannot add more records in a table after deleting all its records.
Reasoning (R): Deleting records from a table does not destroy the table.
12. Assertion (A): We can add more records in a table after dropping the table.
Reasoning (R): A Dropped table no more exists in the database.
13. Assertion (A): We cannot add more records in a table after dropping the table.
Reasoning (R): A Dropped table no more exists in the database.
14. Assertion(A): If the column C1 is the Primary Key of a table T1, then both of the following queries
will produce the same result.
select count(*) from T1;
select count(C1) from T1;
Reasoning (R): C1 cannot have any duplicate values.
15. Assertion(A): If the column C1 is the Primary Key of a table T1, then both of the following queries
will produce the same result.
select count(*) from T1;
select count(C1) from T1;
Reasoning (R): C1 cannot have any NULL values.

www.yogeshsir.com Page: Q110/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

16. Assertion(A): If the column C1 is the Primary Key of a table T1, then both of the following queries
will produce the same result.
select C1 from T1;
select distinct(C1) from T1;
Reasoning (R): C1 cannot have any NULL values.
17. Assertion(A): If the column C1 is the Primary Key of a table T1, then both of the following queries
will produce the same result.
select C1 from T1;
select distinct(C1) from T1;
Reasoning (R): C1 cannot have any duplicate values.
18. Assertion(A): If the column C1 is an Alternate Key of a table T1, then both of the following queries
will produce the same result.
select C1 from T1;
select distinct(C1) from T1;
Reasoning (R): C1 cannot have any NULL values.
19. Assertion(A): The following SQL statement will give the output 5
select 2+3;
Reasoning (R): Select command can be used to evaluate expressions.
20. Assertion(A): If T1 is a table with columns C1, C2, and C3, then the following statement will give
an error:
select 2+3 from T1;
Reasoning (R): 2+3 is not a column of T1.
21. Assertion(A): If T1 is a table with columns C1, C2, and C3, then the following statement will be
executed successfully:
select C1 C2 from T1;
Reasoning (R): In the above statement C2 will be considered an alias of C1.
22. Assertion (A): We can use WHERE clause instead of HAVING clause with GROUP BY clause.
Reasoning (R): WHERE and HAVING both are used to apply conditions.
23. Assertion (A): We cannot use WHERE clause instead of HAVING clause with GROUP BY clause.
Reasoning (R): WHERE and HAVING both are used to apply conditions.
24. Assertion (A): We cannot use WHERE clause instead of HAVING clause with GROUP BY clause.
Reasoning (R): WHERE clause is used to apply conditions on individual rows, whereas HAVING
clause is used to apply conditions on groups.
25. Assertion (A): A Foreign Key is an attribute whose values are derived from the Primary Key of
another table.
Reasoning (R): A Foreign Key is used to establish relationship between two tables.
26. Assertion (A): A Foreign Key column cannot accept NULL values.
Reasoning (R): A Foreign Key is an attribute whose values are derived from the primary Key of
another table.
27. Assertion (A): The domain of the Foreign Key column of a table is same as that of the Primary Key
to which it references.
Reasoning (R): A Foreign Key is an attribute whose values are derived from the Primary Key of
another table.
28. Assertion (A): The cardinality of the Natural join of two tables cannot be more than the cardinality of
their Cartesian Product
Reasoning (R): Natural join of two tables is obtained after filtering the records of their Cartesian
Product.

www.yogeshsir.com Page: Q111/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

29. Assertion (A): The cardinality of the Natural join of two tables can be more than the cardinality of
their Cartesian Product
Reasoning (R): Natural join of two tables is obtaining by applying a condition on their Cartesian
Product.
30. Assertion (A): The cardinality of the Natural join of two tables cannot be more than the cardinality of
their Cartesian Product
Reasoning (R): Natural join of two tables is same as their Cartesian Product.

www.yogeshsir.com Page: Q112/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

Database Management – Descriptive Questions

1. Write the SQL command to view all the databases.


2. Write the SQL command to select/activate the database, named Library.
3. Write the SQL command to view all the tables in the selected database.
4. Write the SQL command to view the structure of a table, named BOOKS.
5. Differentiate between CHAR and VARCHAR Data types.
6. Write two characteristics of Primary Key column of a table.
7. Define the term Domain with respect to RDBMS. Give one example to support your answer.
8. What is the difference between Primary Key constraint and Unique constraint?
9. What is the Cartesian product of two tables?
10. Differentiate between % (percentage) and _(underscore) characters used with the LIKE operator in SQL with
appropriate examples.
11. Differentiate between DROP and DELETE commands in SQL with appropriate examples.
12. Consider the following two commands with reference to a table, named Employee having a column named
Department:
(a) Select count(Department) from Employee;
(b) Select count(*) from Employee;
If these two commands are producing different results:
(i) What may be the possible reason?
(ii) Which command (a) or (b) might be giving a higher value?
13. Give a suitable example of a table with sample data and illustrate Primary and Candidate keys in it.
14. What constraint should be applied on a table column so that duplicate values are not allowed in that column, but
NULL is allowed.
15. What constraint should be applied on a table column so that NULL is not allowed in that column, but duplicate
values are allowed.
16. Write an SQL command to remove the Primary Key constraint from a table, named MOBILE. M_ID is the primary
key of the table.
17. Write an SQL command to make the column M_ID the Primary Key of an already existing table, named MOBILE.

18. Explain the usage of HAVING clause in GROUP BY command in RDBMS with the help of an example.
19. What is the difference between degree and cardinality of a table? What is the degree and cardinality of the following
table?
ENo Name Salary
101 John Fedrick 45000
103 Raya Mazumdar 50600

20. Give a suitable example of a table with sample data and illustrate Primary and Alternate keys in it.
21. Observe the following table carefully and write the names of the most appropriate columns, which can be
considered as (i) candidate keys and (ii) primary key.
Id Product Qty Price Transaction Date
101 Plastic Folder 12" 100 3400 2014-12-14
104 Pen Stand Standard 200 4500 2015-01-31
105 Stapler Medium 250 1200 2015-02-28
109 Punching Machine Big 200 1400 2015-03-12
103 Stapler Mini 100 1500 2015-02-02

22. Observe the following STUDENTS and EVENTS tables carefully and write the name of the RDBMS operation
which will be used to produce the output as shown in LIST. Also, find the Degree and Cardinality of the LIST.

www.yogeshsir.com Page: Q113/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

STUDENTS EVENTS
No Name EVENTCODE EVENTNAME
1 Tara mani 1001 Programming
2 Jaya Sarkar 1002 IT Quiz
3 Tarini Trikha

LIST
NO NAME EVENTCODE EVENTNAME
1 Tara mani 1001 Programming
1 Tara mani 1002 IT Quiz
2 Jaya Sarkar 1001 Programming
2 Jaya Sarkar 1002 IT Quiz
3 Tarini Trikha 1001 Programming
3 Tarini Trikha 1002 IT Quiz

23. Consider the following table – LOAN and BORROWER:


Table: LOAN Table: BORROWER
LOAN_NO B_NAME AMOUNT CUST_NAME LOAN_NO
L-170 DELHI 3000 JOHN L-171
L-230 KANPUR 4000 KRISH L-230
RAVYA L-170
How many rows and columns will be there in the natural join of these two tables?
24. Write an SQL command to create the following table STUDENT with composite primary key CLA+SEC+RNO:
+----------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------+-------------+------+-----+---------+-------+
| NAME | varchar(20) | YES | | NULL | |
| CLA | int | NO | PRI | NULL | |
| SEC | char(1) | NO | PRI | NULL | |
| RNO | int | NO | PRI | NULL | |
| ACTIVITY | varchar(20) | YES | | NULL | |
+----------+-------------+------+-----+---------+-------+
25. Consider the following table STUDENT which has been created without any Primary key. Write an SQL command
to make CLA+SEC+RNO the composite primary key of the table:
+----------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------+-------------+------+-----+---------+-------+
| NAME | varchar(20) | YES | | NULL | |
| CLA | int | YES | | NULL | |
| SEC | char(1) | YES | | NULL | |
| RNO | int | YES | | NULL | |
| ACTIVITY | varchar(20) | YES | | NULL | |
+----------+-------------+------+-----+---------+-------+

www.yogeshsir.com Page: Q114/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

Writing SQL Commands


Do the following tasks practically on the computer. Keep noticing the outputs and errors that appear. It will
help you understand and memorise the commands in a better way.

1. Create a database named 'pracSQL'


2. Select the database 'pracSQL'
3. Create a table StdMaster with the following structure:
SNo Field Type Constraint
1. AdmNo Char(10) Primary Key
2. AdmDate Date
3. Name varchar(20) Not Null
4. Email Varchar(30) Unique
5. Class Int(2)
6. Section Char(1)
7. RNo Int(2)
4. View the structure of the 'StdMaster' table.
5. Delete the table 'StdMaster'.
6. Create the table StdMaster'. This time without any constraint.
7. Add the primary key constraint to the AdmNo field.
8. Add "Unique" constraint to the field 'email'
9. Add the 'Not Null' constraint to the Name field.
10. Add the following data to the table:
+-----------+------------+----------+--------+-------+---------+------+
| AdmNo | admdate | name | email | class | section | rno |
+-----------+------------+----------+--------+-------+---------+------+
| 200700001 | 2007-04-01 | Abhay | [email protected] | 1 | A | 1 |
| 200700002 | 2007-04-01 | Azhar | [email protected] | 1 | A | 2 |
| 200800007 | 2008-04-11 | Sukhdeep | [email protected] | 3 | B | 11 |
| 200800009 | 2008-04-13 | Benita | [email protected] | 3 | C | 4 |
| 200800012 | 2008-06-13 | Bharat | [email protected] | 5 | B | 6 |
+-----------+------------+----------+--------+-------+---------+------+
11. Display all the data from the table.
12. Try adding a record with duplicate primary key value and check what error is shown by MySQL.
13. Try adding a record with Null for Name field and check what error is shown by MySQL.
14. Display the data from 'StdMaster' table in ascending order of class.
15. Display the data from 'StdMaster' table in descending order of class.
16. Display the data from 'StdMaster' table in ascending order of class, and within each class data should
be in ascending order of Name.
17. Display the data from 'StdMaster' table in descending order of class, , and within each class data should
be in ascending order of Name.
18. Display the data of all the students of class 1.
19. Display the data of all students in classes 2 and above.
20. Display the data of all students in classes 2 and above and section B.
21. Display the data of students of classes 1 and 5.
22. Display the data of all the students who are not in class 1 or class 5.
23. Display the data of all the students of classes other than 1 and 3.
24. Display all the classes, but each class should be Displayed once only.
25. Display the data of all the students whose email is null.
26. Display the data of all the students whose email is not null.
27. Display admno, admdate, and email of all the students whose names start with 'A'.
28. Display all the names which are not ending with 'a'.
29. Display the records where section is either B or C.
30. Add a column 'fee' of float type to the table.
31. Update the fee column. Fee for a student is class*100.
32. Display admno, fee, and scholarship for each student. Scholarship is 5% of the fee.
33. Display maximum fee, minimum fee, average fee, total fee, and number of entries in the fee column.

www.yogeshsir.com Page: Q115/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

34. Display maximum fee, minimum fee, average fee, total fee, and number of entries in the fee column for
class 5 students.
35. Display Lowest scholarship and Highest scholarship. Lowest Scholarship is calculated as 2 times the
lowest fee, and highest scholarship is calculated as 2 times the highest fee.
36. Display section wise number of students from the table stdmaster.
37. Display section wise number of students from the table stdmaster only for those sections where
number of students is more than 1.
38. Display section wise number of students whose names start with 'A' from the table stdmaster.
39. Display section wise number of students whose names start with 'A' from the table stdmaster, but only
for those sections where such number is more than 2.
40. Create a table HouseAct (To store House Activities records) with the following structure:
SNo Field Type Constraint
1. AdmNo Char(10) Foreign key references stdmaster(AdmNo)
2. House Varchar(10) Not null
3. Activity varchar(20)
41. Insert the following data into the table HouseAct:
+-----------+---------+-------------+
| admno | house | activity |
+-----------+---------+-------------+
| 200700001 | Peace | Dance |
| 200700002 | Harmony | Music |
| 200800009 | Hope | Quiz |
| 200700002 | Harmony | Dance |
| 200700001 | Peace | Drama |
| 200700002 | Harmony | Photography |
+-----------+---------+-------------+
42. Display all the data from the table HouseAct.
43. Display the cartesian product of stdmaster and HouseAct.
44. Display the natural join of stdmaster and HouseAct.
45. Display all the data from the equijoin of stdmaster and HouseAct.
46. Display admno, name, house, and activity of all the students who are participating in some activity.
47. Display admno, name, class, section, activity of all the students who are participating in some activity.
48. Display admno, name, class, section, activity of all the students who are participating in dance.
49. Using natural join, display admno, name, class, section, activity of all the students who are
participating in some activity.
50. Using natural join, display admno, name, class, section, activity of all the students who are
participating in dance.
51. Add a new column 'grade' of float type to the table HouseAct.
52. Add a new column 'level' of varchar(10) type to the table HouseAct.
53. Display the structure of table HouseAct.
54. Delete the column 'level' from the table HouseAct.
55. Delete all the data from the table stdmaster.
56. Delete all the data from HouseAct.
57. Display names of all the table in the database.
58. Delete the table HouseAct.
59. Delete the database pracSQL.
60. Display the names of all the databases.

www.yogeshsir.com Page: Q116/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

Writing Queries and Finding Outputs


1. Write SQL commands based on the relation Teacher given below:
No Name Age Department Date_of_join Salary Sex
1 Jugal 34 Computer 1997-01-10 12000 M
2 Sharmila 31 History 1998-03-24 20000 F
3 Sandeep 32 Maths 1996-12-12 30000 M
4 Sangeeta 35 History 1999-01-07 40000 F
5 Rakesh 42 Maths 1997-09-05 25000 M
6 Shyam 50 History 1998-06-27 30000 M
7 Shiv Om 44 Computer 1997-02-25 21000 M
8 Shalakha 33 Maths 1997-07-31 20000 F
a) To show all information about the teacher of History department.
b) To list the names of female teachers who are in Maths department.
c) To list the names of all teachers with their date of joining in ascending order.
d) To display teacher’s name, salary, age for male teachers only.
e) To count the number of teachers with Age>23.
2. Write SQL commands for the following queries on the basis of Club relation given below:
Coach-ID CoachName Age Sports date_of_app Pay Sex
1 Kukreja 35 Karate 1996-03-27 1000 M
2 Ravina 34 Karate 1998-01-20 1200 F
3 Karan 34 Squash 1998-02-19 2000 M
4 Tarun 33 Basketball 1998-01-01 1500 M
5 Zubin 36 Swimming 1998-01-12 750 M
6 Ketaki 36 Swimming 1998-02-24 800 F
7 Ankita 39 Squash 1998-02-20 2200 F
8 Zareen 37 Karate 1998-02-22 1100 F
9 Kush 41 Swimming 1998-01-13 900 M
10 Shailya 37 Basketball 1998-02-19 1700 M
a) To show all information about the swimming coaches in the club.
b) To list the names of all coaches with their date of appointment (date_of_app) in descending order.
c) To display a report showing coach name, pay, age, and bonus (15% of pay) for all coaches.
d) To insert a new row in the Club table with ANY relevant data:
e) Give the output of the following SQL statements:
i. Select COUNT(Distinct Sports) from Club;
ii. Select Min(Age) from Club where SEX ='F';
3. Write SQL commands for (a) to (f) and write the outputs for (g) on the basis of tables FURNITURE and
ARRIVALS
FURNITURE
NO ITEMNAME TYPE DATEOFSTOCK PRICE DISCOUNT
1 White lotus Double Bed 2002-02-23 30000 25
2 Pink feather Baby cot 2002-01-20 7000 20
3 Dolphin Baby cot 2002-02-19 9500 20
4 Decent Office Table 2002-01-01 25000 30
5 Comfort zone Double Bed 2002-01-12 25000 25
6 Donald Baby cot 2002-02-24 6500 15
7 Royal Finish Office Table 2002-02-20 18000 30
8 Royal tiger Sofa 2002-02-22 31000 30
9 Econo sitting Sofa 2001-12-13 9500 25
10 Eating Paradise Dining Table 2002-02-19 11500 25

www.yogeshsir.com Page: Q117/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

ARRIVALS
NO ITEMNAME TYPE DATEOFSTOCK PRICE DISCOUNT
1 Wood Comfort Double Bed 2003-03-23 25000 25
2 Old Fox Sofa 2003-02-20 17000 20
3 Micky Baby cot 2003-02-21 7500 15

a) To show all information about the Baby cots from the FURNITURE table.
b) To list the ITEMNAME which are priced at more than 15000 from the FURNITURE table.
c) To list ITEMNAME and TYPE of those items, in which date of stock is before 2002-01-22 from
the FURNITURE table in descending of ITEMNAME.
d) To display ITEMNAME and DATEOFSTOCK of those items, in which the discount percentage is
more than 25 from FURNITURE table.
e) To count the number of items, whose TYPE is "Sofa" from FURNITURE table.
f) To insert a new row in the ARRIVALS table with the following data:
14,"Valvet touch", "Double bed", '2003-03-25', 25000,30
g) Give the output of following SQL statements:
Note: Outputs of the above mentioned queries should be based on original data given in both the
tables i.e., without considering the insertion done in (f) part of this question.
(i) Select COUNT(distinct TYPE) from FURNITURE;
(ii) Select MAX(DISCOUNT) from FURNITURE,ARRIVALS;
(iii) Select AVG(DISCOUNT) from FURNITURE where TYPE = "Baby
cot";
(iv) Select SUM(Price) from FURNITURE where DATEOFSTOCK < '2002-
02-12'
4. Consider the following tables GAMES and PLAYER. Write SQL commands for the statements (a) to (d)
and give outputs for SQL queries (e1) to (e4)
GAMES
GCode GameName Number PrizeMoney ScheduleDate
101 Carom Board 2 5000 23-Jan-2004
102 Badminton 2 12000 12-Dec-2003
103 Table Tennis 4 8000 14-Feb-2004
105 Chess 2 9000 01-Jan-2004
108 Lawn Tennis 4 25000 19-Mar-2004
PLAYER
PCode Name Gcode
1 Nabi Ahmad 101
2 Ravi Sahai 108
3 Jatin 101
4 Nazneen 103
(a) To display the name of all Games with their Gcodes
(b) To display details of those games which are having PrizeMoney more than 7000.
(c) To display the content of the GAMES table in ascending order of ScheduleDate.
(d) To display sum of PrizeMoney for each of the Number of participation groupings (as shown in
column Number)
(e1) SELECT COUNT(DISTINCT Number) FROM GAMES;
(e2) SELECT MAX(ScheduleDate),MIN(ScheduleDate) FROM GAMES;
(e3) SELECT SUM(PrizeMoney) FROM GAMES;
(e4) SELECT DISTINCT Gcode FROM PLAYER;

www.yogeshsir.com Page: Q118/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

5. Consider the following tables WORKER and PAYLEVEL and answer (A) and (B) parts of this question:
WORKER
ECODE NAME DESIG PLEVEL DOJ DOB
11 Radhey Shyam Supervisor P001 13-Sep-2004 23-Aug-1981
12 Chander Nath Operator P003 22-Feb-2010 12-Jul-1987
13 Fizza Operator P003 14-June-2009 14-Oct-1983
15 Ameen Ahmed Mechanic P002 21-Aug-2006 13-Mar-1984
18 Sanya Clerk P002 19-Dec-2005 09-June-1983

PAYLEVEL
PAYLEVEL PAY ALLOWANCE
P001 26000 12000
P002 22000 10000
P003 12000 6000
(A) Write SQL commands for the following statements:
(i) To display the details of all WORKERs in descending order of DOB.
(ii) To display NAME and DESIG of those WORKERs whose PLEVEL is either P001 or P002.
(iii) To display the content of all the WORKERs table, whose DOB is in between ’19-JAN-1984’
and ’18-JAN-1987’.
(iv) To add a new row with the following:
19, ‘Daya kishore’, ‘Operator’, ‘P003’, ’19-Jun-2008’, ’11-Jul-1984’
(B) Give the output of the following SQL queries:
(i) SELECT COUNT(PLEVEL), PLEVEL FROM WORKER GROUP BY PLEVEL;
(ii) SELECT MAX(DOB), MIN(DOJ) FROM WORKER;
(iii) SELECT Name, Pay FROM WORKER W, PAYLEVEL P WHERE
W.PLEVEL=P.PLEVEL AND W.ECODE<13;
(iv) SELECT PLEVEL, PAY+ALLOWANCE FROM PAYLEVEL WHERE
PLEVEL=’P003’;
6. Consider the following tables CABHUB and CUSTOMER and answer parts (A) and (B):
CABHUB CUSTOMER
VCode VehicleName Make Color Capacity Charges CCode CName VCode
100 Innova Toyota WHITE 7 15 1 Hemant Sahu 101
102 SX4 Suzuki BLUE 4 14 2 Raj Lal 108
104 C Class Merc RED 4 35 3 Feroz Shah 105
105 A-Star Suzuki WHITE 3 14 4 Ketan Dhal 104
108 Indigo Tata SILVER 3 12

(A) Write SQL commands for the following statements:


1) To display the names of all white colored vehicles
2) To display name of vehicle, make and capacity of vehicles in ascending order of their sitting
capacity
3) To display the highest charges at which a vehicle can be hired from CABHUB.
4) To display the customer name and the corresponding name of the vehicle hired by them.
(B) Give the output of the following SQL queries:
1) SELECT COUNT(DISTINCT Make) FROM CABHUB;
2) SELECT MAX(Charges), MIN(Charges) FROM CABHUB;
3) SELECT COUNT(*), Make FROM CABHUB;
4) SELECT VehicleName FROM CABHUB WHERE Capacity = 4;

7. Write SQL queries for (a) to (f) and write the outputs for the SQL queries mentioned shown in (g1) to (g4)
parts on the basis of tables ITEMS and TRADERS:

www.yogeshsir.com Page: Q119/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

ITEMS
CODE INAME QTY PRICE COMPANY TCODE
1001 DIGITAL PAD 12i 120 11000 XENITA T01
1006 LED SCREEN 40 70 38000 SANTORA T02
1004 CAR GPS SYSTEM 50 21500 GEOKNOW T01
1003 DIGITAL CAMERA 12X 160 8000 DIGICLICK T02
1005 PEN DRIVE 32GB 600 1200 STOREHOME T03
TRADERS
TCode TName CITY
T01 ELECTRONIC SALES MUMBAI
T03 BUSY STORE CORP DELHI
T02 DISP HOUSE INC CHENNAI
a) To display the details of all the items in the ascending order of item names (i.e. INAME).
b) To display the number of items, which are traded by each trader, as follows:
T01 2
T02 2
T03 1
c) To display item name and price of all those items, whose price is in range of 10000 and 22000
(both values inclusive).
d) To display the price, item name and quantity (qty) of those items which have quantity more than
150.
e) To display the names of those traders, who are either from DELHI or from MUMBAI.
f) To display the names of the companies and the names of the items in descending order of company
names.
g1) SELECT MAX(PRICE), MIN(PRICE) FROM ITEMS;
g2) SELECT PRICE*QTY AMOUNT FROM ITEMS WHERE CODE-1004;
g3) SELECT DISTINCT TCODE FROM ITEMS;
g4) SELECT INAME, TNAME FROM ITEMS I, TRADERS T WHERE
I.TCODE=T.TCODE AND QTY<100;
8. Answer the (A) and (B) parts on the basis of the following tables STORE and ITEM:
STORE ITEM
SNo SNAME AREA INO INAME Price SNo
S01 ABC Computronics GK II T01 Mother Board 12000 S01
S02 All Infortech Media CP T02 Hard Disk 5000 S01
S03 Tech Shoppe Nehru Place T03 Keyboard 500 S02
S05 Hitech Tech Store SP T04 Mouse 300 S01
T05 Mother Board 13000 S02
T06 Key Board 400 S03
T07 LCD 6000 S04
T08 LCD 5500 S05
T09 Mouse 350 S05
T10 Hard Disk 4500 S03
(A) Write the SQL queries (1 to 4):
1) To display IName and Price of all the items in the ascending order of their Price.
2) To display the SNo and SName o all stores located in CP.
3) To display the minimum and maximum price of each IName from the table Item.
4) To display the IName, price of all items and their respective SName where they are available.
(B) Write the output of the following SQL commands (1 to 4):
1) SELECT DISTINCT INAME FROM ITEM WHERE PRICE >= 5000;
2) SELECT AREA, COUNT(*) FROM STORE GROUP BY AREA;
3) SELECT COUNT(DISTINCT AREA) FROM STORE;
4) SELECT INAME, PRICE*0.05 DISCOUNT FROM ITEM WHERE SNO IN ('S02',
'S03');
www.yogeshsir.com Page: Q120/150 www.youtube.com/LearnWithYK
QB/XII/CS-083/2025/YK/Questions

9. Consider the following DEPT and WORKER tables. Write SQL queries for (i) to (iv) and find outputs for
SQL queries (v) to (viii):
Table: DEPT
DCODE DEPARTMENT CITY
D01 MEDIA DELHI
D02 MARKETING DELHI
D03 INFRASTRUCTURE MUMBAI
D05 FINANCE KOLKATA
D04 HUMAN RESOURCE MUMBAI

Table: WORKER
WNO NAME DOJ DOB GENDER DCODE
1001 George K 2013-09-02 1991-09-01 MALE D01
1002 Ryma Sen 2012-12-11 1990-12-15 FEMALE D03
1003 Mohitesh 2013-02-03 1987-09-04 MALE D05
1007 Anil Jha 2014-01-17 1984-10-19 MALE D04
1004 Manila Sahai 2012-12-09 1986-11-14 FEMALE D01
1005 R SAHAY 2013-11-18 1987-03-31 MALE D02
1006 Jaya Priya 2014-06-09 1985-06-23 FEMALE D05
Note: DOJ refers to date of joining and DOB refers to date of Birth of workers.
(i) To display Wno, Name, Gender from the table WORKER in descending order of Wno.
(ii) To display the Name of all the FEMALE workers from the table WORKER.
(iii) To display the Wno and Name of those workers from the table WORKER who are born
between ‘1987-01-01’ and ‘1991-12-01’.
(iv) To count and display MALE workers who have joined after ‘1986-01-01’.
(v) SELECT COUNT(*), DCODE FROM WORKER GROUP BY DCODE HAVING
COUNT(*)>1;
(vi) SELECT DISTINCT DEPARTMENT FROM DEPT;
(vii) SELECT NAME, DEPARTMENT, CITY FROM WORKER W,DEPT D WHERE
W.DCODE=D.DCODE AND WNO<1003;
(viii) SELECT MAX(DOJ), MIN(DOB) FROM WORKER
10. Consider the following DEPT and EMPLOYEE tables. Write SQL queries for (i) to (iv) and find outputs
for SQL queries (v) to (viii).
Table: DEPT
DCODE DEPARTMENT LOCATION
D01 INFRASTRUCTURE DELHI
D02 MARKETING DELHI
D03 MEDIA MUMBAI
D05 FINANCE KOLKATA
D04 HUMAN RESOURCE MUMBAI

Table: EMPLOYEE
ENO NAME DOJ DOB GENDER DCODE
1001 George K 20130902 1991-09-01 MALE D01
1002 Ryma Sen 20121211 1990-12-15 FEMALE D03
1003 Mohitesh 20130203 1987-09-04 MALE D05
1007 Anil Jha 20140117 1984-10-19 MALE D04
1004 Manila Sahai 20121209 1986-11-14 FEMALE D01
1005 R SAHAY 20131118 1987-03-31 MALE D02
1006 Jaya Priya 20140609 1985-06-23 FEMALE D05
Note: DOJ refers to date of joining and DOB refers to date of Birth of employees.
(i) To display Eno, Name, Gender from the table EMPLOYEE in ascending order of Eno.
(ii) To display the Name of all the MALE employees from the table EMPLOYEE.
(iii) To display the Eno and Name of those employees from the table EMPLOYEE who are born
between '1987‐01‐01' and '1991‐12‐01'.
www.yogeshsir.com Page: Q121/150 www.youtube.com/LearnWithYK
QB/XII/CS-083/2025/YK/Questions

(iv) To count and display FEMALE employees who have joined after '1986‐01‐01'.
(v) SELECT COUNT(*),DCODE FROM EMPLOYEE
GROUP BY DCODE HAVING COUNT(*)>1;
(vi) SELECT DISTINCT DEPARTMENT FROM DEPT;
(vii) SELECT NAME, DEPARTMENT FROM EMPLOYEE E, DEPT
D WHERE E.DCODE=D.DCODE AND EN0<1003;
(viii) SELECT MAX(DOJ), MIN(DOB) FROM EMPLOYEE;

11. Write SQL queries for (i) to (iv) and find outputs for SQL queries (v) to (viii), which are based on the
tables.
Table: VEHICLE
Code VTYPE PERKM
101 VOLVO BUS 160
102 AC DELUXE BUS 150
103 ORDINARY BUS 90
105 SUV 40
104 CAR 20
Note:
• PERKM is Freight Charges per kilometer
• VTYPE is Vehicle Type
Table: TRAVEL
NO NAME TDATE KM CODE NOP
101 Janish Kin 2015-11-13 200 101 32
103 Vedika sahai 2016-04-21 100 103 45
105 Tarun Ram 2016-03-23 350 102 42
102 John Fen 2016-02-13 90 102 40
107 Ahmed Khan 2015-01-10 75 104 2
104 Raveena 2015-05-28 80 105 4
106 Kripal Anya 2016-02-06 200 101 25
Note :
• NO is Traveller Number
• KM is Kilometer travelled
• NOP is number of travellers travelled in vehicle
• TDATE is Travel Date
(i) To display NO, NAME, TDATE from the table TRAVEL in descending order of NO.
(ii) To display the NAME of all the travellers from the table TRAVEL who are travelling by
vehicle with code 101 or 102.
(iii) To display the NO and NAME of those travellers from the table TRAVEL who travelled
between ‘2015-12-31’ and ‘2015-04-01’.
(iv) To display all the details from table TRAVEL for the travellers, who have travelled
distance more than 100 KM in ascending order of NOP.
(v) SELECT COUNT (*), CODE FROM TRAVEL GROUP BY CODE HAVING
COUNT(*)>1;
(vi) SELECT DISTINCT CODE FROM TRAVEL;
(vii) SELECT A.CODE,NAME,VTYPE FROM TRAVEL A,VEHICLE B WHERE
A.CODE=B.CODE AND KM<90;
(viii) SELECT NAME,KM*PERKM FROM TRAVEL A, VEHICLE B WHERE
A.CODE=B.CODE AND A.CODE='105';

www.yogeshsir.com Page: Q122/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

12. Write SQL queries for (i) to (iv) and find outputs for SQL queries (v) to (viii), which are based on the
tables.
Table: VEHICLE
VCODE VEHICLETYPE PERKM
V01 VOLVO BUS 150
V02 AC DELUXE BUS 125
V03 ORDINARY BUS 80
V05 SUV 30
V04 CAR 18

Note: PERKM is Freight Charges per kilometer


Table: TRAVEL
CNO CNAME TRAVELDATE KM VCODE NOP
101 K.Niwal 2015-12-13 200 V01 32
103 Fredrick Sym 2016-03-21 120 V03 45
105 Hitesh Jain 2016-04-23 450 V02 42
102 Ravi Anish 2016-01-13 80 V02 40
107 John Malina 2015-02-10 65 V04 2
104 Sahanubhuti 2016-01-28 90 V05 4
106 Ramesh jaya 2016-04-06 100 V01 25
Note :
• KM is Kilometer travelled
• NOP is number of travellers travelled in vehicle
• TDATE is Travel Date
(i) To display CNO, CNAME, TRAVELDATE from the table TRAVEL in descending order
of CNO.
(ii) To display the CNAME of all the customers from the table TRAVEL who are travelling by
vehicle with code V01 or V02.
(iii) To display the CNO and CNAME of those customers from the table TRAVEL who
travelled between ‘2015-12-31’ and ‘2015-05-01’.
(iv) To display all the details from table TRAVEL for the customers, who have travelled
distance more than 120 KM in ascending order of NOP.
(v) SELECT COUNT (*), VCODE FROM TRAVEL GROUP BY VCODE HAVING
COUNT(*)>1;
(vi) SELECT DISTINCT VCODE FROM TRAVEL;
(vii) SELECT A.VCODE,CNAME,VEHICLETYPE FROM TRAVEL A,VEHICLE B
WHERE A.VCODE=B.VCODE AND KM<90;
(viii) SELECT CNAME,KM*PERKM FROM TRAVEL A, VEHICLE B WHERE
A.VCODE=B.VCODE AND A.VCODE='V05';
13. Write the output of the SQL queries (i) to (iv) based on the relations COMPUTER and SALES given below:
Table: COMPUTER
PROD_ID PROD_NAME PRICE COMPANY TYPE
P001 MOUSE 200 LOGITECH INPUT
P002 LASER PRINTER 4000 CANON OUTPUT
P003 KEYBOARD 500 LOGITECH INPUT
P004 JOYSTICK 1000 IBALL INPUT
P005 SPEAKER 1200 CREATIVE OUTPUT
P006 DESKJET PRINTER 4300 CANON OUTPUT
Table: SALES
PROD_ID QTY_SOLD QUARTER
P002 4 1
P003 2 2
pool 3 2
P004 2 1

www.yogeshsir.com Page: Q123/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

(i) SELECT MIN(PRICE), MAX(PRICE) FROM COMPUTER;


(ii) SELECT COMPANY, COUNT(*) FROM COMPUTER GROUP BY COMPANY
HAVING COUNT (COMPANY) > 1;
(iii) SELECT PROD NAME, QTY SOLD FROM COMPUTER C, SALES S WHERE C.
PROD ID=S.PROD ID AND TYPE = 'INPUT';
(iv) SELECT PROD NAME, COMPANY, QUARTER FROM COMPUTER C, SALES S
WHERE C.PROD ID=S.PROD_ID;
14. Consider the following table, named LAB, which stores the data of 5 labs in a school:
LABNO LAB NAME INCHARGE CAPACITY FLOOR
L001 CHEMISTRY Dais 20 I
L002 BIOLOGY Venky 20 II
L003 MATH Preeti 15 I
L004 LANGUAGE Dais 36 III
L005 COMPUTER Ma Kom 37 II
(A) Based on the data given above answer the following questions:
a) Identify the columns which can be considered as the Candidate Keys.
b) Write the degree and cardinality of the table.
(B) Write the statements to:
(a) Insert a new row with appropriate data.
(b) Increase the capacity of each lab by 10 students which are on floor I.
(c) Add the constraint PRIMARY KEY to the column LABNO of the table.
(d) Delete the table LAB.
15. Consider the tables, BOOK and MEMBER given below:
Table: BOOK Table: MEMBER
CODE BNAME TYPE MNO MNAME CODE ISSUEDATE
F101 The priest Fiction M101 SNEH SINHA L102 2022-10-13
L102 Easy Python Programming M103 SARTHAK F102 2021-02-23
C101 Juman Ji Thriller M102 SARA KHAN C101 2022-06-12
F102 Untold Story Fiction
C102 War Stories Comic
What will be the output of the statement:
SELECT * FROM BOOK NATURAL JOIN MEMBER;

16. Write the output of the queries (i) to (iv) based on the table EMPLOYEE
Table: Employee
EID Name DOB DOJ Salary Project
E01 Ranjan 1990-07-12 2015-01-21 150000 P01
E02 Akhtar 1992-06-21 2015-02-01 125000 P04
E03 Muneera 1996-11-15 2018-08-19 135000 P01
E04 Alex 1991-10-25 2018-10-19 75000 P02
E05 Satyansh 1993-12-16 2018-10-19 85000 P04
(i) SELECT NAME, PROJECT FROM EMPLOYEE ORDER BY NAME DESC;
(ii) SELECT NAME, SALARY FROM EMPLOYEE WHERE NAME LIKE 'A%';
(iii) SELECT NAME, DOJ FROM EMPLOYEE WHERE SALARY BETWEEN
100000 AND 200000;
(iv) SELECT * FROM EMPLOYEE WHERE PROJECT = 'P01';

www.yogeshsir.com Page: Q124/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

17. Consider the following tables – FACULTY and COURSES:


Table: FACULTY Table: COURSES
FID FNAME LNAME JOINDATE SALARY C_ID FID CNAME FEES
F01 Anishma Garg 2000-12-14 32000 C11 F01 Grid Computing 40000
F03 Bhumi Goel 2001-08-10 15000 C12 F04 Python 17000
F04 Neha Verma 2000-05-17 27000 C13 F03 C++ 8000
F05 Meenu Sharma 2006-07-11 30000 C14 F04 Computer Network 15000
C15 F01 HTML 12000
C16 F05 Data Science NULL

What will be the output of the following statements?


(i) SELECT FID, MIN(FEES), MAX(FEES) FROM COURSES GROUP BY FID;
(ii) SELECT AVG(SALARY) FROM FACULTY WHERE FNAME LIKE '%a';
(iii) SELECT FNAME, CNAME FROM FACULTY F, COURSES C WHERE
F.FID=C.FID AND COURSES.FID='F04';
(iv) SELECT FNAME, CNAME , FEES FROM FACULTY F , COURSES C WHERE
F.FID = C.FID AND FEE>15000;
18. Navdeep creates a table RESULT with a set of records to maintain the marks secured by students in Sem1,
Sem2, Sem3, and their divisions. After the creation of the table, he entered data of 7 students in the table.
ADNO ROLLNO SNAME SEM1 SEM2 DIVISION
123 101 KARAN 366 410 I
245 102 NAMAN 300 350 I
128 103 ISHA 400 410 I
129 104 RENU 350 357 I
234 105 ARPIT 100 75 IV
187 106 SABINA 100 205 II
181 107 NEELAM 470 450 I
Based on the data given above answer the following questions:
(i) Identify the columns which can be considered as candidate keys?
(ii) If 2 more columns are added and 3 rows are deleted from the table result, what will be the new
degree and cardinality of the above table?
(iii) Write a statement to increase the SEM2 marks by 3% for the students securing marks between
70 to 100.
19. Reva creates a table, named STUDIOS, with a set of records to store the basic data of Motion Picture and
Entertainment studios in India. After creation of the table, she has entered data of 5 studios in the table, as
shown below.
SNo Name Industry Founded HeadQuarter
1 2D Entertainment Motion Picture 2013 Chennai
2 Ashirwad Cinemas Motion Picture 2010 Kochi
3 Lyca Productions Entertainment 2014 Chennai
4 CineMan Productions Entertainment 2010 Ahmedabad
5 Eros International Media & Enter. 1977 Mumbai
6 R K Films Motion Picture 1948 Mumbai
Based on the data given above answer the following questions:
(i) Name the possible candidate key(s) of the table? Justify your answer.
(ii) If one column and three rows are added to the table, what will be the new degree and cardinality of
the above table?
(iii) Write the statements to:
a) Add a new column Founder of type varchar(20), to the table.
b) Delete the record of R K Films from the table (as the studio was closed in 2019).
c) Set SNo as the Primary Key of the table.
d) Change the value of column Founded to 2000 for Ashirwad Cinemas.
www.yogeshsir.com Page: Q125/150 www.youtube.com/LearnWithYK
QB/XII/CS-083/2025/YK/Questions

20. Write the output of SQL queries (a) to (d) based on the table VACCINATION_DATA given below :
TABLE: VACCINATION_DATA
VID Name Age Dose1 Dose2 City
101 Jenny 27 2021-12-25 2022-01-31 Delhi
102 Harjot 55 2021-07-14 2021-10-14 Mumbai
103 Srikanth 43 2021-04-18 2021-07–20 Delhi
104 Gazala 75 2021-07-31 NULL Kolkata
105 Shiksha 32 2022-01-01 NULL Mumbai
(a) SELECT Name, Age FROM VACCINATION DATA
WHERE Dose2 IS NOT NULL AND Age > 40;
(b) SELECT City, COUNT(*) FROM VACCINATION DATA GROUP BY City;
(c) SELECT DISTINCT City FROM VACCINATION DATA;
(d) SELECT MAX (Dose1), MIN(Dose2) FROM VACCINATION DATA;
21. Write the output of SQL queries (a) and (b) based on the following two tables DOCTOR and PATIENT
belonging to the same database :

Table: DOCTOR Table: PATIENT


DNO DNAME FEES PNO PNAME ADMDATE DNO
D1 AMITABH 1500 P1 NOOR 2021-12-25 D1
D2 ANIKET 1000 P2 ANNI 2021-11-20 D2
D3 NIKHIL 1500 P3 PRAKASH 2020-12-10 NULL
D4 ANJANA 1500 P4 HARMEET 2019-12-20 D1

(a) SELECT DNAME, PNAME FROM DOCTOR NATURAL JOIN PATIENT;


(b) SELECT PNAME, ADMDATE, FEES FROM PATIENT P, DOCTOR D WHERE D. DNO
P. DNO AND FEES > 1000;

22. Write the output of the queries (i) to (iv) based on the table WORKER given below:
Table: WORKER
W_ID F_NAME L_NAME CITY STATE
102 SAHIL KHAN KANPUR UTTAR PRADESH
104 SAMEER PARIKH ROOP NAGAR PUNJAB
105 MARY JONES DELHI DELHI
106 MAHIR SHARMA SONIPAT HARYANA
107 ATHARVA BHARDWAJ DELHI DELHI
108 VEDA SHARMA KANPUR UTTAR PRADESH
i. SELECT F_NAME, CITY FROM WORKER ORDER BY STATE DESC;
ii. SELECT DISTINCT(CITY) FROM WORKER;
iii. SELECT F_NAME, STATE FROM WORKER WHERE L_NAME LIKE '_HA%';
iv. SELECT CITY, COUNT(*) FROM WORKER GROUP BY CITY;
23. Write the output of the queries (i) to (iv) based on the relations COMPUTER and SALES given below:
Table: COMPUTER
PROD_ID PROD_NAME PRICE COMPANY TYPE
P001 MOUSE 200 LOGITECH INPUT
P002 LASER PRINTER 4000 CANON OUTPUT
P003 KEYBOARD 500 LOGITECH INPUT
P004 JOYSTICK 1000 IBALL INPUT
P005 SPEAKER 1200 CREATIVE OUTPUT
P006 DESKJET PRINTER 4300 CANON OUTPUT

www.yogeshsir.com Page: Q126/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

Table: SALES
PROD_ID QTY_SOLD QUARTER
P002 4 1
P003 2 2
P001 3 2
P004 2 1

24. Write the output of the queries (i) to (iv) based on the table GARMENT given below:
Table: GARMENT
GCODE TYPE PRICE FCODE ODR_DATE
G101 EVENINGGOWN 850 F03 2008-12-19
G102 SLACKS 750 F02 2020-10-20
G103 FROCK 1000 F01 2021-09-09
104 TULIPSKIRT 1550 F01 2021-08-10
G105 BABYTOP 1500 F02 2020-03-31
G106 FORMALPANT 1250 F01 2019-01-06

(i) SELECT DICTINCT(COUNT(FCODE)) FROM GARMENT;


(ii) SELECT FCODE, COUNT(*), MIN(PRICE) FROM GARMENT GROUP BY FCODE
HAVING COUNT(*)>1;
(iii) SELECT TYPE FROM GARMENT WHERE ORD_DATE>'2021-02-01' AND
PRICE<1500;
(iv) SELECT * FROM GARMENT WHERE TYPE LIKE 'F%';
25. Write the output of the queries (i) to (iv) based on the tableS COMPANY and CUSTOMER given below:
Table: COMPANY
CID C_NAME CITY PRODUCTNAME
111 SONY DELHI TV
222 NOKIA MUMBAI MOBILE
333 ONIDA DELHI TV
444 SONY MUMBAI MOBILE
555 BLACKBERRY CHENNAI MOBILE
666 DELL DELHI LAPTOP

Table: CUSTOMER
CUSTID CID NAME PRICE QTY
C01 222 ROHIT SHARMA 70000 20
C02 666 DEEPIKA KUMARI 50000 10
C03 111 MOHAN KUMAR 30000 5
C04 555 RADHA MOHAN 30000 11
(i) SELECT PRODUCTNAME, COUNT(*) FROM COMPANY GROUP BY PRODUCTNAME
HAVING COUNT(*)>2;
(ii) SELECT NAME, PRICE, PRODUCTNAME FROM COMPANY C, CUSTOMER CT WHERE
C.CID=CU.CID AND C_NAME='SONY';
(iii) SELECT DISTINCT CITY FROM COMPANY;
(iv) SELECT *FROM COMPANY WHERE C_NAME LIKE'%ON%';
www.yogeshsir.com Page: Q127/150 www.youtube.com/LearnWithYK
QB/XII/CS-083/2025/YK/Questions

26. The ABC Company is considering to maintain their salespersons records using SQL to store data. As a
database administrator, Alia created the table Salesperson and also entered the data of 5 Salespersons.
Table: SALESPERSON
S_ID S_NAME AGE S_AMOUNT REGION
S001 SHYAM 35 20000 NORTH
S002 RISHABH 30 25000 EAST
S003 SUNIL 29 21000 NORTH
S004 RAHIL 39 22000 WEST
S005 AMIT 40 23000 EAST
Based on the data given above, answer the following questions:
(i) Identify the attribute that is best suited to be the Primary Key and why?
(ii) The Company has asked Alia to add another attribute in the table. What will be the new degree and
cardinality of the above table?
(iii) Write the statements to:
a) Insert details of one salesman with appropriate data.
b) Change the region of the salesman 'SHYAM' to 'SOUTH' in the table Salesperson.
c) Delete the record of salesman RISHABH, as he has left the company.
d) Remove an attribute REGION from the table.

27. Consider the table CLUB given below and write the output of the SQL queries that follow:
Table: CLUB
CID CNAME AGE GEMDER SPORTS PAY DOAPP
5246 AMRITA 35 FEMALE CHESS 900 2006-03-27
4687 SHYAM 37 MALE CRICKET 1300 2004-04-15
1245 MEENA 23 FEMALE VOLLEYBALL 1000 2007-06-18
1622 AMRIT 28 MALE KARATE 1000 2007-09-05
1256 AMINA 36 FEMALE CHESS 1100 2003-08-15
1720 MANJU 33 FEMALE KARATE 1250 2004-04-10
321 VIRAT 35 MALE CRICKET 1050 2005-04-30

(i) SELECT COUNT(DISTINCT SPORTS) FROM CLUB;


(ii) SELECT CNAME, SPORTS FROM CLUB WHERE DOAPP<"2006-04-30" AND CNAME
LIKE "%NA";
(iii) SELECT CNAME, AGE, PAY FROM CLUB WHERE GENDER = "MALE" AND PAY
BETWEEN 1000 AND 1200;

28. Consider the table Personal given below:


Table: Personal
P_ID Name Desig Salary Allowance
P01 Rohit Manager 89000 4800
P02 Kashish Clerk NULL 1600
P03 Mahesh Superviser 48000 NULL
P04 Salil Clerk 31000 1900
P05 Ravina Superviser NULL 2100

Based on the given table, write SQL queries for the following:
(i) Increase the salary by 5% of personals whose allowance is known.
(ii) Display Name and Total Salary (sum of Salary and Allowance) of all personals. The column
heading ‘Total Salary’ should also be displayed.
(iii) Delete the record of personals who have salary greater than 25000

www.yogeshsir.com Page: Q128/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

29. Consider the tables PRODUCT and BRAND given below:


Table: PRODUCT Table: BRAND
PCode PName UPrice Rating BID BID BName
P01 Shampoo 120 6 M03 M02 Dant Kanti
P02 Toothpaste 54 8 M02 M03 Medimix
P03 Soap 25 7 M03 M04 Pepsodent
P04 Toothpaste 65 4 M04 M05 Dove
P05 Soap 38 5 M05
P06 Shampoo 245 6 M05

Write SQL queries for the following:


(i) Display product name and brand name from the tables PRODUCT and BRAND.
(ii) Display the structure of the table PRODUCT.
(iii) Display the average rating of Medimix and Dove brands
(iv) Display the name, price, and rating of products in descending order of rating.
30. Consider the table ORDERS given below and write the output of the SQL queries that follow:
Table: ORDERS
ORDNO ITEM QTY RATE ORDATE
1001 RICE 23 120 2023-09-10
1002 PULSES 13 120 2023-10-18
1003 RICE 25 110 2023-11-17
1004 WHEAT 28 65 2023-12-25
1005 PULSES 16 110 2024-01-15
1006 WHEAT 27 55 2024-04-15
1007 WHEAT 25 60 2024-04-30
(i) SELECT ITEM, SUM(QTY) FROM ORDERS GROUP BY ITEM;
(ii) SELECT ITEM, QTY FROM ORDERS WHERE ORDATE BETWEEN '2023-11-01' AND
'2023-12-31';
(iii) SELECT ORDNO, ORDATE FROM ORDERS WHERE ITEM='WHEAT' AND RATE>=60;
31. Consider the table PROJECTS given below:
Table: PROJECTS
P-id Pname Language Startdate Enddate
P001 School Management System Python 2023-01-12 2023-04-03
P002 Hotel Management System C++ 2022-12-01 2023-02-02
P003 Blood Bank Python 2023-02-11 2023-03-02
P004 Payroll Management System 65Python 2023-03-12 2023-06-02
Based on the given table write the SQL queries for the following:
(i) Add the constraint Primary Key to the column P_id in the existing table Projects.
(ii) To change the language to Python of the project whose id is P002.
(iii) To delete the table Projects from MySQL database along with its data.
32. Consider the tables Admin and Transport given below:
Table: Admin Table: Transport
S_id S_name Address S_type S_id Bus_no Stop_name
S001 Sandhya Rohini DayBoarder S002 TSS10 Sarai Kale Khan
S002 Vedanshi Rohtak DayScholar S004 TSS12 Sainik Vihar
S003 Vibhu RajNagar NULL S005 TSSl0 Kamla Nagar
S004 Atharva Rampur DayBoarder
Write the SQL queries for the following:
(i) Display the student name and their stop name from the tables Admin and Transport.
(ii) Display the number of students whose S_type is not known.
(iii) Display all details of the students whose name starts with 'V'.
(iv) Display student id and address in alphabetical order of student name, from the table Admin.

www.yogeshsir.com Page: Q129/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

33. Consider the table Stationery given below and write the output of the SQL queries that follow:
Table: Stationery
ITEMNO ITEM DISTRIBUTOR QTY PRICE
401 Ball Pen 0.5 Reliable Stationers 100 16
402 Gel Pen Premium Classic Plastics 150 20
403 Eraser Big Clear Deals 210 10
404 Eraser Small Clear Deals 200 5
405 Sharpener Classic Classic Plastics 150 8
406 Gel Pen Classic Classic Plastics 100 15
(i) SELECT DISTRIBUTOR, SUM(QTY) FROM STATIONERY GROUP BY
DISTRIBUTOR;
(ii) SELECT ITEMNO, ITEM FROM STATIONERY WHERE DISTRIBUTOR =
"Classic Plastics" AND PRICE > 10;
(iii) SELCET ITEM, QTY * PRICE AS "AMOUNT" FROM STATIONERY WHERE
ITEMNO = 402;
34. Consider the table Rent_cab, given below :
Table: Rent_Cab
Vcode VName Make Color Charges
101 Big car Carus White 15
102 Small car Polestar Silver 10
103 Family car Windspeed Black 20
104 Classic Studio White 30
105 Luxury Trona Red 9
Based on the given table, write SQL queries for the following :
(i) Add a primary key to a column name Vcode.
(ii) Increase the charges of all the cabs by 10%.
(iii) Delete all the cabs whose maker name is "Carus".
35. Consider the tables GAMES and PLAYERS given below:
Table: GAMES
GCode GameName Type Number PrizeMoney
101 Carrom Board Indoor 2 5000
102 Badminton Outdoor 2 12000
103 Table Tennis Indoor 4 NULL
104 Chess Indoor 2 9000
105 Lawn Tennis Outdoor 4 25000
Table: PLAYERS
PCode Name GCode
1 Nabi Ahmad 101
2 Ravi Sahai 108
3 Jatin 101
4 Nazneen 103
Write SQL queries for the following :
(i) Display the game type and average number of games played in each type.
(ii) Display prize money, name of the game, and name of the players from the tables Games and
Players.
(iii) Display the types of games without repetition.
(iv) Display the name of the game and prize money of those games whose prize money is known.
36. Consider the table ORDERS as given below, and answer the questions that follow:
Table: ORDERS
O_Id C_Name Product Quantity Price
1001 Jitendra Laptop 1 12000
1002 Mustafa Smartphone 2 10000
1003 Dhwani Headphone 1 1500
Note: The table contains many more records than shown here.

www.yogeshsir.com Page: Q130/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

1. Write SQL queries for the following:


(i) To display the total Quantity for each Product, excluding Products with total Quantity less
than 5.
(ii) To display the orders table sorted by total price in descending order.
(iii) To display the distinct customer names from the Orders table.
(iv) Display the sum of Price of all the orders for which the quantity is null.
2. Write the outputs of the following queries:
(i) Select c_name, sum(quantity) as total_quantity from orders
group by c_name;
(ii) Select * from orders where product like '%phone%';
(iii) Select o_id, c_name, product, quantity, price from orders where
price between 1500 and 12000;
(iv) Select max(price) from orders;
37. Saman has been entrusted with the management of Law University Database. He needs to access some
information from FACULTY and COURSES tables for a survey analysis. Help him extract the following
information by writing the desired SQL queries as mentioned below.
Table: FACULTY
F_ID FName LName Hire_Date Salary
102 Amit Mishra 12-10-1998 12000
103 Nitin Vyas 24-12-1994 8000
104 Rakshit Soni 18-5-2001 14000
105 Rashmi Malhotra 11-9-2004 11000
106 Sulekha Srivastava 5-6-2006 10000

Table: COURSES
C_ID F_ID CName Fees
C21 102 Grid Computing 40000
C22 106 System Design 16000
C23 104 Computer Security 8000
C24 106 Human Biology 15000
C25 102 Computer Network 20000
C26 105 Visual Basic 6000

(i) To display complete details (from both the tables) of those Faculties whose salary is less than
12000.
(ii) To display the details of courses whose fees is in the range of 20000 to 50000 (both values
included).
(iii) To increase the fees of all courses by 500 which have "Computer" in their Course names.
(iv) To display names (FName and LName) of faculty taking System Design.
(v) To display the Cartesian Product of these two tables.

www.yogeshsir.com Page: Q131/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

Database Management - Python – MySQL Connectivity


1. Consider the following SQL table MEMBER in a SQL Database CLUB:
Table: MEMBER
M_ID Name ACTIVITY
M1001 Amina GYM
M1002 Pratik GYM
M1003 Simon SWIMMING
M1004 Rakesh GYM
M1005 Avneet SWIMMING
Assume that the required library for establishing the connection between Python and MYSQL
is already imported in the given Python code. Also assume that DB is the name of the database
connection for table MEMBER stored in the database CLUB. Predict the output of the following
code:
MYCUR=DB.cursor()
MYCUR.execute("USE CLUB")
MYCUR.execute("SELECT * FROM MEMBER WHERE ACTIVITY= 'GYM'")
R=MYCUR.fetchone()
for i in range (2)
R=MYCUR.fetchone()
print (R[0], R[1], sep )
2. Consider a table Employee which contains the following record structure:
• E_code - String
• E_name - String
• Sal – Integer
• City - String
(a) The code given below deletes the records from the table. Write/complete the following
statements to complete the code:
• Statement 1 – to import the desired library.
• Statement 2 – to execute the command that deletes the record with E_code as
'E101'.
• Statement 3 – to delete the record permanently from the database.

import __________ as mysql # Statement 1


def delete() :
mydb=mysql.connect(host="localhost",user="root",
passwd="root",database="emp")
mycursor=mydb.cursor()
_________________ # Statement 2
_________________ # Statement 3
print ("Record deleted")
(b) The code given below reads and displays only those records who have employees coming
from city ‘Delhi’, and displays these records. Write/complete the following statements to
complete the code:
• Statement 1 – to import the desired library.
• Statement 2 – to execute the query that fetches records of the employees coming
from city ‘Delhi’.

www.yogeshsir.com Page: Q132/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

• Statement 3 – to read the complete data of the query (rows whose city is Delhi) into
the object named details, from the table employee in the database.

import _____________ as mysql #Statement 1


def display():
mydb=mysql.connect(host="localhost",user="root",
passwd="root",database="emp")
mycursor=mydb.cursor()
____________________________ #Statement 2
details = ___________________ #Statement 3
for i in details:
print (i)

3. The table Bookshop in MySQL contains the following attributes:


• B_code Integer
• B_name String
• Qty Integer
• Price Integer
Note the following to establish connectivity between Python and MySQL:
• Username is 'Shop'
• Password is 'Book'
• The table exists in a MySQL database named 'Bstore'.

(a) The code given below updates the records from the table Bookshop in MySQL.
• Statement 1 to form the cursor object.
• Statement 2 to execute the query that updates the Qty to 20 of the records whose
B_code is 105 in the table.
• Statement 3 to make the changes permanent in the database.

import mysql.connector as mysql


def update_book():
mydb=mysql.connect(host="localhost",
user="shop",passwd="Book",database="Bstore")
mycursor=__________ # Statement 1
qry= "update Bookshop set Qty=20 where B_code=105"
___________________ # Statement 2
___________________ # Statement 3
(b) The code given below reads the records from the table Bookshop and displays all the
records:
• Statement 1 to form the cursor object.
• Statement 2 to write the query to display all the records from the table.
• Statement 3 to read the complete result of the query into the object named B_Details,
from the table Bookshop in the database.

www.yogeshsir.com Page: Q133/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

import mysql.connector as mysql


def Display_book():
mydb=mysql.connect(host="localhost",
user="shop",passwd="Book",database="Bstore")
mycursor=___________ # Statement 1
mycursor.execute("_________") # Statement 2
B_Details=__________ # Statement 3
for i in B_Details:
print(i)

4. The code given below accepts the roll number of a student and increases the marks of that
student by 5 in the table Student. The structure of a record of table Student is:
RollNo – integer; Name – string; Clas – integer; Marks – integer
Note the following to establish connectivity between Python and MYSQL:
• Username is root
• Password is abc
• The table exists in a MYSQL database named school.
Write the following missing statements to complete the code:
Statement 1 – to open/activate the school database.
Statement 2 – to execute the command that updates the record in the table Student.
Statement 3- to make the updation in the database permanent

import mysql.connector as mysql


def sql_data():
con1=mysql.connect(host="localhost",user="root",
password="abc")
mycursor= con1.cursor()
__________________ #Statement 1
rno=int(input("Enter Roll Number :: "))
name=input("Enter name :: ")
querry="update student set marks=marks+5
where RollNo = {}".format(rno)
_______________________ #Statement 2
_______________________ # Statement 3
print("Data updated successfully")

5. Kapil has created a table named Student in MYSQL database SCHOOL:


• rno(Roll number )- integer
• name(Name) - string
• DOB (Date of birth) – Date
• Fee – float
Note the following to establish connectivity between Python and MySQL:
Username – root, Password – YK@RJ, Host - localhost

www.yogeshsir.com Page: Q134/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

Kapil wants to write a program to do the following:


(a) to insert a record in the table. The values of fields rno, name, DOB and fee have to be
accepted from the user.
(b) to display the records of students whose fee is more than 5000.
Help Kapil to write this program in Python.
6. Sonia wants to write a program in Python to reduce the quantity by 5 of the records whose item
code is 250 in the table named ITEMS in MySQL database named SHOP. The table shop in
MySQL contains the following attributes:
• Item_code: Item code (Integer)
• Item_name: Name of item (String)
• Qty: Quantity of item (Integer)
• Price: Price of item (Integer)
• Disc: Discount percentage (float)
Consider the following to establish connectivity between Python and MySQL:
Username: admin Password: Shopping Host: localhost
Help Sonia by writing the program.
7. Sumit wants to write a code in Python to display all the details of the passengers from the
table flight in MySQL database named Travel. The table contains the following attributes:
• F_code: Flight code(String)
• F_name: Name of flight(String)
• Source: Departure city of flight(String)
• Destination: Destination city of flight(String)
Consider the following to establish connectivity between Python and MySQL:
Username: admin Password: Fly-KM Host: localhost
Help Sumit by writing the program.
8. Salman wants to write a program in Python to delete the record of a candidate “Vaishali” from
the table named Candidate in MySQL database named Recruitment.
The table Candidate in MySQL contains the following attributes:
• CName – String
• Dept – String
• Place – String
• Salary – integer
Note the following to establish connectivity between Python and MySQL:
Username: admin Password: Talent Host: localhost
Help Salman to write the program in Python for the above mentioned task.
9. Rajni wants to write a program in Python to insert 3 records in the table named Accounts in
MySQL database, Bank. The table Accounts has the following structure:
• Accno – integer
• Cname – string
• Atype – string
• Amount – float
Note the following to establish connectivity between Python and MySQL:
Username: Emp11 Password: R-11@Bnk Host: localhost
The values of fields Accno, Cname, Atype and Amount have to be accepted from the user. Help
Rajni to write the program in Python.

www.yogeshsir.com Page: Q135/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

10. A table, named STATIONERY, in ITEMDB database, has the following structure:
Field Type
itemNo int(11)
itemName varchar(15)
price float
qty int(11)
Write the following Python function to perform the specified operation:
AddAndDisplay(): To input details of an item and store it in the table STATIONERY. The
function should then retrieve and display all records from the STATIONERY table where the
Price is greater than 120. Assume the following for Python-Database connectivity:
Username: root Password: Pencil Host: localhost

www.yogeshsir.com Page: Q136/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

(III) Computer Networks

www.yogeshsir.com Page: Q137/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

Computer Networks MCQs


1. The acronym ARPANet stands for:
a) Advanced Research for Protocols b) Agency for Research Projects and
Advanced Network Advanced Networks
c) Advanced Research Projects Agency d) Advancement in Research and Projects
Network Agency Network
2. The acronym NSFNet stands for:
a) National Self Financed Network b) National Science Foundation Network
c) National Science For Networks d) National Setup for Foundation Network

3. In context of computer networks, the meaning of Switching Technique is:


a) Technique of sending data from one node b) Technique of changing switches of network
to another. devices.
c) Techniques of shifting computers from one d) Technique of switching data from one
network to another. network to a computer.

4. In which of the following switching techniques a dedicated path is established between the sender and
receiver for the entire duration of the communication.?
a) Circuit switching b) Packet switching
c) Network switching d) Physical switching

5. In which of the following switching techniques the data is divided into packets and each packet follows
its own path?
a) Circuit switching b) Packet switching
c) Network switching d) Physical switching

6. __________ is reliable but can be inefficient because the dedicated path is reserved even if no data is
being transmitted.
a) Circuit switching b) Packet switching
c) Network switching d) Physical switching

7. It's more efficient and flexible, but packets can arrive out of order or get lost, requiring retransmission
a) Circuit switching b) Packet switching
c) Network switching d) Physical switching

8. ___________ refers to the maximum rate at which data can be transmitted over a network connection
in a given amount of time.
a) Channel b) Bandwidth
c) Frequency d) Capacity

9. Which of the following is not a unit of bandwidth?


a) abps b) kbps
c) gbps d) mbps

10. The term Guided media refers to:


a) Print Media b) Social Media
c) Wired Media d) Wireless Media

11. Which of the following is the fastest wired medium?


a) Coaxial Cable b) Twisted Pair Cable
c) Fiber-optic Cable d) USB Cable

12. Which of the following wired media is the easiest to install for a LAN?
a) Coaxial Cable b) Twisted Pair Cable
c) Fiber-optic Cable d) USB Cable

www.yogeshsir.com Page: Q138/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

13. Which of the following wired media is not recommended for economical setup of a LAN?
a) Coaxial Cable b) Twisted Pair Cable
c) Fiber-optic Cable d) USB Cable

14. The term Unguided media refers to?


a) Print Media b) Social Media
c) Wired Media d) Wireless Media

15. Which of the following is not a wireless medium?


a) Infrared rays b) Radio waves
c) Micro waves d) Satellite

16. Which of the following is a wireless medium?


a) Bluetooth b) Satellite
c) Wi Fi d) Infrared Rays

17. Which of the following wireless media is used for very long distance communication which may cover
multiple cities or more?
a) Infrared rays b) Radio waves
c) Micro waves d) All of the above

18. Which of the following is used for short distance communication and cannot cross obstacles?
a) Infrared rays b) Radio waves
c) Micro waves d) All of the above

19. On the side of the sender, Modem works as a


a) Modulator b) Demodulator
c) Router d) Repeater

20. On the side of the receiver, Modem works as a


a) Modulator b) Demodulator
c) Router d) Repeater

21. Conversion of Digital signals into Analogue signals is called


a) Modulation b) Demodulation
c) Modem d) Switching

22. Conversion of Analogue signals into Digital signals is called


a) Modulation b) Demodulation
c) Modem d) Switching

23. The term NIC stands for


a) Network Interface Card b) Net Integrated Card
c) Network Interfaced Computer d) Net Interfaced Computer

24. Which connector is used to connect Ethernet cable to NIC?


a) Repeater b) RJ45 connector
c) USB connector d) Advanced Connector

25. Which of the following devices can only broadcast, but cannot unicast or multicast?
a) Hub b) Switch
c) Router d) Gateway

26. A communicating device sends data to some of its connected devices. Such a communication is called
a) Broadcast b) Unicast
c) Multicast d) None of these

www.yogeshsir.com Page: Q139/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

27. A communicating device sends data to one of its connected devices. Such a communication is called
a) Broadcast b) Unicast
c) Multicast d) None of these

28. A communicating device sends data to all of its connected devices. Such a communication is called
a) Broadcast b) Unicast
c) Multicast d) None of these

29. Which of the following devices only amplifies/regenerates the incoming signal and sends it forward?
a) Modem b) Repeater
c) Router d) Gateway

30. Which of the following devices does not know any address of any connected device?
a) Hub b) Switch
c) Router d) Gateway

31. Which of the following devices knows the MAC addresses of all the connected devices?
a) Hub b) Switch
c) Router d) Gateway

32. Which of the following statements is correct?


a) A switch is more intelligent than a hub b) A hub is more intelligent than a switch
c) A hub is as intelligent as a switch d) Switch and Hub together make a router

33. Which of the following devices is used to connect multiple segments of a LAN?
a) Modem b) Repeater
c) Router d) Gateway

34. Which of the following devices is used to connect two networks?


a) Modem b) Repeater
c) Router d) Gateway

35. Which of the following can be a software or a hardware?


a) Modem b) Repeater
c) Router d) Gateway

36. Which of the following is not a valid difference between HTML and XML?
a) HTML has predefined tags, whereas XML has no predefined tags.
b) HTML is used to describe the layout of a webpage, whereas XML is used to describe the
structure of data.
c) An HTML file can be created using a text editor, whereas an XML file cannot be created
using a text editor.
d) An XML file can be interpreted by a spreadsheet package, whereas an HTML file cannot be
interpreted by a spreadsheet package.

37. __________________ is a set of rules that needs to be followed by the communicating devices in order
to have a successful and reliable data communication over a network.
a) Topology b) Media
c) Protocol d) Web Server

38. Which protocol is used to login to a remote computer?


a) FTP b) PPP
c) Telnet d) HTTP

www.yogeshsir.com Page: Q140/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

39. Which protocol is used to transfer files over a TCP/IP network?


a) FTP b) PPP
c) Telnet d) HTTP

40. Which protocol is used to send emails?


a) POP3 b) SMTP
c) FTP d) HTTP

41. Which protocol is used to receive emails?


a) POP3 b) SMTP
c) FTP d) HTTP

42. Which protocol is used to send web pages securely over a TCP/IP network?
a) PPP b) SMTP
c) FTP d) HTTPS

43. The term URL stands for:


a) Universal Resource Locator b) Uniform Resource Locator
c) Universal Resource Link d) Uniform Resource Link

44. www.yogeshsir.com/home is a
a) Protocol b) Website
c) Domain Name d) URL

45. In https://www.yogeshsir.com/home , https is a


a) Protocol b) Website
c) Domain Name d) URL

46. In https://www.yogeshsir.com/home , www.yogeshsir.com is a


a) Protocol b) Website
c) Domain Name d) URL

47. Which of the following is a web browser?


a) Chrome b) Windows
c) WWW d) Internet

48. A web server is a


a) person who manages websites b) computer that manages websites
c) person who hosts websites d) computer that hosts websites

49. Which of the following is not a web browser?


a) Edge b) Chrome
c) Safari d) Adobe

50. A __________is a small device that allows your computer to connect to wireless networks.
a) modem b) Wi-Fi
c) Wi-Fi card d) browser

www.yogeshsir.com Page: Q141/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

Computer Networks – Descriptive questions


1. What is a computer network?
2. Expand the terms: ARPANET, NSFNET, PAN, LAN, MAN, WAN, HTTP, FTP, PPP, SMTP, TCP/IP,
POP3, HTTPS, TELNET, VoIP, WWW, HTML, XML, URL
3. What is VoIP?
4. What, out of the following, will you use to have an audio-visual chat with an expert sitting in a faraway place
to fix-up a technical issue?
Email, VoIP, FTP
5. Give one suitable example of each – URL and Domain Name.
6. What is the difference between domain name and IP address?
7. Write two advantages of using an optical fiber cable over an Ethernet cable to connect two service stations,
which are 190m away from each other.
8. Which type of network (out of LAN, PAN, MAN) is formed when you connect two mobiles using Bluetooth
to transfer a picture file?
9. Differentiate between ftp and http.
10. Out of the following, which is the fastest (i) wired and (ii) wireless medium of communication?
Infrared, Coaxial Cable, Ethernet Cable, Microwave, Optical Fiber
11. Give two examples of PAN and LAN type of networks.
12. Which protocol helps us to browse through web pages using internet browsers? Name any one internet
browser.
13. Differentiate between PAN and LAN types of networks.
14. Which protocol helps us to transfer files to and from a remote computer?
15. Differentiate between physical address and logical address of a node in a computer network.
16. Differentiate between Guided media and Unguided media with an example of each.
17. Explain the terms: (i) remote login (ii) remote desktop
18. Write any two differences between HTML and XML.
19. Write any two differences between Bus topology and Star topology.
20. Write any two differences between Star Topology and Tree Topology.
21. Draw a network diagram of 5 computers connected using (i) Bus topology, and (ii) Star Topology.
22. Draw the diagram of a Tree topology.
23. Mention any two advantages and two disadvantages of Bus topology.
24. Mention any two advantages and two disadvantages of Star topology.
25. Mention any two advantages and two disadvantages of using twisted pair cable over other guided media.
26. Mention any two advantages and two disadvantages of using coaxial cable over other guided media.
27. Mention any two advantages and two disadvantages of using optical fibre over other guided media.
28. Mention any two advantages and two disadvantages of using Infrared rays over other unguided media.
29. Mention any two advantages and two disadvantages of using Radio waves over other unguided media.
30. Mention any two advantages and two disadvantages of using Micro waves over other unguided media.

www.yogeshsir.com Page: Q142/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

Computer Networks – Case Studies


1. Quick Learn University is setting up its academic blocks at Prayag Nagar and is planning to set up a
network. The University has 3 academic blocks and one Human Resource Center as shown in the
diagram below:

Center to Center distances between various blocks/center is as follows:


Law Block to business Block 40m
Law block to Technology Block 80m
Law Block to HR center 105m
Business Block to technology Block 30m
Business Block to HR Center 35m
Technology block to HR center 15m
Number of computers in each of the blocks/Center is as follows:
Law Block 15
Technology Block 40
HR center 115
Business Block 25
a) Suggest the most suitable place (i.e., Block/Center) to install the server of this University with a
suitable reason.
b) Suggest an ideal layout for connecting these blocks/centers for a wired connectivity.
c) Which device will you suggest to be placed/installed in each of these blocks/centers to
efficiently connect all the computers within these blocks/centers.
d) The university is planning to connect its admission office in the closest big city, which is more
than 250km from university. Which type of network out of LAN, MAN, or WAN will be formed?
Justify your answer.

2. Granuda Consultants are setting up a secured network for their office campus at Faridabad for their
day to day office and web based activities. They are planning to have connectivity between 3 buildings
and the head office situated in Kolkata. Answer the questions (a) to (d) after going through the building
positions in the campus and other details, which are given below:

Distances between, and Number of Computers in various buildings:


From - To Distance Building No. of Computers
“RAVI” to “JAMUNA” 120m “RAVI” 25
“RAVI” to “GANGA” 50m “JAMUNA” 150
“GANGA” to “JAMUNA” 65m “GANGA” 51
Faridabad Campus to Head Office 1460km Head Office 10

www.yogeshsir.com Page: Q143/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

a) Suggest the most suitable place (i.e. block) to house the server of this organization. Also give a
reason to justify your suggested location.
b) Suggest a cable layout of connections between the buildings inside the campus.
c) Suggest the placement of the following devices with justification:
(i) Switch (ii) Repeater
d) The organization is planning to provide a high speed link with its head office situated in KOLKATA
using a wired connection. Which of the following cable will be most suitable for this job?
(i) Optical Fiber (ii) Co-axial cable (iii) Ethernet cable

3. Expertia Professional Global (EPG) is an online corporate training provider company for IT related
courses. The company is setting up their new campus in Mumbai. You as a network expert have to
study the physical locations of various buildings and the number of computers to be installed. In the
planning phase, provide the best possible answers for the queries (a) to (d) raised by them.

Building to Building distances (in Mtrs.), and Number of computers in each building:
FROM - TO Distance Building No. of Computers
Administrative to Finance 60 Administrative 20
Administrative to Faculty Studio 120 Finance 40
Finance to Faculty Studio 70 Faculty Studio 120
a) Suggest the most appropriate building, where EPG should plan to install the server.
b) Suggest the most appropriate building to building cable layout to connect all three buildings
for efficient communication.
c) Which type of network out of the following is formed by connecting the computers of these
three buildings? (LAN, MAN, WAN)
d) Which wireless channel out of the following should be opted by EPG to connect to students
of all over the world? (Infrared, Microwave, Satellite)

4. Trine Tech Corporation (TTC) is a professional consultancy company. The company is planning to set
up their new offices in India with its hub at Hyderabad. As a network adviser, you have to understand
their requirement and suggest them the best available solutions. Their queries are mentioned (a) to
(d) below.

Block to Block distances (in Mtrs.), and Number of Computers in each block:
FROM - TO Distance Block No. of Computers
Human resource to Conference 110 Human resource 25
Human resource to Finance 40 Finance 120
Conference to Finance 80 Conference 90

a) What will be the most appropriate block, where TTC should plan to install the server?

www.yogeshsir.com Page: Q144/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

b) Draw a block to block cable layout to connect all the buildings in the most appropriate
manner for efficient communication.
c) What will be the best possible connectivity out of the following, you will suggest to connect
the new setup of offices in Bangalore with its London based office?
Satellite Link, Infrared, Ethernet cable
d) Which of the following devices will be suggested by you to connect each computer in each of
the buildings.
Switch, modem, Gateway

5. Perfect Edu Services Ltd. is an educational organization. It is planning to setup its India campus at
Chennai with its head office at Delhi. The Chennai campus has 4 main buildings – ADMIN,
ENGINEERING, BUSINESS and MEDIA

Shortest distances between various buildings:


ADMIN to ENGINEERING 55 m
ADMIN to BUSINESS 90 m
ADMIN to MEDIA 50 m
ENGINEERING to BUSINESS 55 m
ENGINEERING to MEDIA 50 m
BUSINESS to MEDIA 45 m
DELHI Head Office to CHENNAI Campus 2175 km

Number of Computers installed at various buildings are as follows:


ADMIN 110
ENGINEERING 75
BUSINESS 40
MEDIA 12
DELHI Head Office 20
a) Suggest the most appropriate location of the server inside the CHENNAI campus (out of
the 4 buildings), to get the best connectivity for maximum no. of computers. Justify your
answer.
b) Suggest and draw the cable layout to efficiently connect various buildings within the
CHENNAI campus for connecting the computers.
c) Which hardware device will you suggest to be procured by the company to be installed to
protect and control the internet uses within the campus?
d) Which of the following will you suggest to establish the online face-to-face communication
between the people in the Admin Office of CHENNAI campus and DELHI Head Office?
(i) Cable TV (ii) Email (iii) Video Conferencing (iv) Text Chat

www.yogeshsir.com Page: Q145/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

6. Uplifting Skills Hub India is a knowledge and skill community which has an aim to uplift the standard
of knowledge and skills in the society. It is planning to setup its training centers in multiple towns and
villages pan India with its head offices in the nearest cities. They have created a model of their network
with a city, a town and 3 villages as follows:

As a network consultant, you have to suggest the best network related solutions for their
issues/problems raised in (a) to (d) keeping in mind the distances between various locations and
other given parameters.
Shortest distances between, and Number of Computers at various locations:
From - To Distance Location No. of Computers
VILLAGE 1 to B_TOWN 2 KM B_TOWN 120
VILLAGE 2 to B_TOWN 1.0 KM VILLAGE 1 15
VILLAGE 3 to B_TOWN 1.5 KM VILLAGE 2 10
VILLAGE 1 to VILLAGE 2 3.5 KM VLLAGE 3 15
VILLAGE 1 to VILLAGE 3 4.5 KM A_CITY OFFICE 6
VILLAGE 2 to VILLAGE 3 2.5 KM
A_CITY Head Office to B_HUB 25 KM
Note :
• In Villages, there are community centers, in which one room has been given as
training center to this organization to install computers.
• The organization has got financial support from the government and top IT
companies.

a) Suggest the most appropriate location of the SERVER in the B_HUB (out of the 4
locations), to get the best and effective connectivity. Justify your answer.
b) Suggest the best wired medium and draw the cable layout (location to location) to
efficiently connect various locations within the B_HUB.
c) Which hardware device will you suggest to connect all the computers within each
location of B_HUB?
d) Which service/protocol will be most helpful to conduct live interactions of Experts
from Head Office and people at all locations of B_HUB?
7. Total-IT Corporation, a Karnataka based IT training company, is planning to set up training centres in
various cities in next 2 years. Their first campus is coming up in Kodagu district. At Kodagu
campus, they are planning to have 3 different blocks, one for AI, IoT and DS (Data Sciences
each). Each block has number of computers, which are required to be connected in a network
for communication, data and resource sharing. As a network consultant of this company, you have to
suggest the best network related solutions for them for issues/problems raised in question nos. (i) to
(v), keeping in mind the distances between various blocks/locations and other given parameters.

www.yogeshsir.com Page: Q146/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

Distance between, and Number of Computers in various blocks/locations:


Block Distance Block No. of Computers
IT to DS 28 m IT 75
IT to IoT 55 m DS 50
DS to IoT 32 m IoT 80
Kodagu Campus to Coimbatore Campus 304 km

(i) Suggest the most appropriate block/location to house the SERVER in the Kodagu campus
(out of the 3 blocks) to get the best and effective connectivity. Justify your answer.
(ii) Suggest a device/software to be installed in the Kodagu Campus to take care of data
security.
(iii) Suggest the best wired medium and draw the cable layout (Block to Block) to most
efficiently connect various blocks within the Kodagu Campus.
(iv) Suggest the placement of the following devices with appropriate reasons: a) Switch/Hub
b) Router
(v) Suggest a protocol that shall be needed to provide Video Conferencing solution between
Kodagu Campus and Coimbatore Campus.
8. TechnoCraft, a Chennai based IT company, is planning to set up its development center in Ariyalur
district of Tamil Nadu. At Ariyalur center, they are planning to have 3 different blocks, one each for
R&D (Research and Development), DA (Data Analytics), and AD (Application Development). Each
block will have its own computer network, and all the blocks are also needed to be inter-connected.
As a network consultant of this company, you have to suggest the best network related solutions for
them for issues/problems raised in question nos. (i) to (v), keeping in mind the distances between
various blocks/locations and other given parameters.

(i) Suggest the block to place the sever in Ariyalur center. Justify your answer.
(ii) Should the cabling be done using Twisted Pair Cable or Fiber optics cable? Give one reason
to support your answer.
(iii) Which type of network out of LAN, MAN, or WAN is formed by interconnecting all the blocks
of Ariyalur center? Justify your answer.
(iv) Do you suggest the placement of repeater anywhere in the Ariyalur center? Justify your
answer.
(v) Suggest a device/software to be installed in the Ariyalur Campus to take care of data
security.

www.yogeshsir.com Page: Q147/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

9. FutureTech Corporation, a Bihar based IT training and development company, is planning to set up
training centers in various cities in the coming year. Their first center is coming up in Surajpur
district. At Surajpur center, they are planning to have 3 different blocks - one for Admin, one for
Training and one for Development. Each block has number of computers, which are required to
be connected in a network for communication, data and resource sharing. As a network consultant
of this company, you have to suggest the best network related solutions for them for issues/problems
raised in question nos. (i) to (v), keeping in mind the distances between various blocks/locations and
other given parameters.

Distance between various blocks/locations:

Distance between various blocks:


Block Distance
Development to Admin 28 m
Development to Training 105 m
Admin to Training 32 m
Surajpur Campus to Coimbatore Campus 340 km

Number of computers:
Block Number of Computers
Development 90
Admin 40
Training 50

(i) Suggest the most appropriate block/location to house the SERVER in the Surajpur center
(out of the 3 blocks) to get the best and effective connectivity. Justify your answer.
(ii) Suggest why should a firewall be installed at the Surajpur Center?
(iii) Suggest the best wired medium and draw the cable layout (Block to Block) to most
efficiently connect various blocks within the Surajpur Center.
(iv) Suggest the placement of the following devices with appropriate reasons: a) Switch/Hub
b) Router
(v) Suggest the best possible way to provide wireless connectivity between Surajpur Center
and Raipur Center.

www.yogeshsir.com Page: Q148/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

10. Core Study University is setting up its campus in Dubai and planning to set up a network. The
campus has 3 academic centres and one administration centre as shown in the diagram given
below:

Distance between various centres: No. of computers in various blocks:


AI Centre Robotics Centre 60 m AI Centre 25
Robotics Centre DL Centre 90 m DL Centre 55
Robotics Centre Admin Centre 115 m Admin Centre 130
AI Centre DL Centre 40 m Robotics Centre 35
AI Centre Admin Centre 45 m
DL Centre Admin Centre 25 m
(i) Suggest and draw a cable layout to efficiently connect various centres within the
university.
(ii) Which device will you suggest to be placed/ installed in each of these centres to
efficiently connect all the computers within the university?
(iii) Name the centre where the server is to be installed. Justify your answer.
(iv) The university is planning to connect its Dubai campus to its Delhi campus. The
approximate distance between these campuses is 2200 KM. Which type of network out
of LAN, MAN or WAN will be formed? Justify your answer.

www.yogeshsir.com Page: Q149/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Questions

www.yogeshsir.com Page: Q150/150 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Answers

Answers

www.yogeshsir.com Page: A1/52 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Answers

Answers - Python MCQs


Data Types, Operators, and Expressions
1. a 2. c 3. a 4. a 5. b 6. d 7. d 8. a 9. b 10. a
11. b 12. c 13. a 14. d 15. d 16. a 17. a 18. c 19. d 20. b
21. c 22. d 23. d 24. c 25. b 26. c 27. a 28. c 29. c 30. b
31. d 32. c 33. b 34. b 35. c 36. b 37. d 38. d 39. d 40. d

Variable Names and Compound Assignment Operators


1. a 2. c 3. c 4. d 5. b 6. d 7. b 8. d 9. c 10. d
11. b 12. b 13. a 14. d 15. a 16. d 17. b 18. d 19. a 20. a
21. d 22. c 23. c 24. b 25. c 26. d 27. c 28. b 29. d 30. d

Boolean Expressions
1. b 2. d 3. b 4. a 5. b 6. b 7. b 8. b 9. a 10. a
11. a 12. a 13. c 14. c 15. a 16. b 17. a 18. b 19. a 20. b
21. b 22. d 23. b 24. c 25. a 26. b 27. d 28. a 29. d 30. a
31. a 32. c 33. b 34. d 35. c 36. c 37. c 38. c 39. c 40. b
41. b 42. d 43. a 44. d 45. d 46. c 47. a 48. c 49. b 50. c

range() and random


1. c 2. d 3. b 4. a 5. a 6. c 7. a, c 8. a 9. b,c 10. d
11. a 12. a 13. d 14. c 15. b 16. a 17. a,d 18. a 19. c 20. a
21. d 22. b 23. d 24. b 25. c

Lists
1. d 2. a 3. c 4. b 5. d 6. a 7. b 8. b 9. a 10. d
11. c 12. a 13. b 14. a 15. b 16. c 17. d 18. d 19. d 20. b
21. d 22. a 23. d 24. d 25. d 26. d 27. a 28. b 29. c 30. b
31. b 32. b 33. a 34. c 35. a 36. a 37. b,d 38. c,d 39. a,b 40. a,c
41. d 42. c 43. c 44. d 45. b

Tuples
1. b 2. b 3. c 4. b 5. a,d 6. b 7. d 8. a,d 9. b,d 10. c
11. b 12. a 13. a 14. c 15. c 16. a 17. c 18. a 19. d 20. b

Strings
1. b 2. b 3. c 4. c,d 5. a 6. b,d 7. b 8. d 9. a 10. b
11. a 12. d 13. d 14. a 15. b 16. c 17. d 18. c 19. d 20. b
21. c 22. d 23. c 24. b 25. a

Dictionaries
1. d 2. c 3. d 4. b 5. b,d 6. a 7. d 8. d 9. d 10. b
11. a,b,c 12. a,b 13. b 14. b 15. c 16. d 17. d 18. a 19. d 20. c

www.yogeshsir.com Page: A2/52 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Answers

Functions
1. a 2. b 3. a,c 4. d 5. d 6. a 7. b 8. a 9. a,d 10. d
11. d 12. d 13. a 14. b,c 15. c 16. b 17. b 18. a 19. c 20. d

Text Files
1. a 2. d 3. d 4. d 5. d 6. d 7. c 8. a,b 9. a,b 10. c
11. c 12. c 13. a 14. c 15. a 16. c 17. b 18. c 19. b 20. c
21. d 22. b 23. d 24. b 25. c 26. c 27. d 28. d 29. a 30. d
31. d 32. b 33. d 34. b 35. d 36. a 37. b 38. a 39. c 40. b

CSV Files
1. b 2. a 3. d 4. d 5. d 6. d 7. a 8. c 9. b 10. a
11. a 12. a 13. b 14. b 15. b

Binary Files
1. d 2. d 3. b 4. a 5. b,c 6. a 7. a 8. b 9. b 10. a
11. d 12. c 13. a 14. a 15. a 16. b 17. c 18. a 19. c 20. c
21. b 22. d 23. c 24. a,b 25. b

Exception Handling
1. b 2. a 3. a 4. c 5. b 6. a 7. b 8. c 9. a 10. b
11. b 12. b 13. d 14. b 15. d

Answers - Assertion Reasoning based Questions


1. D 2. A 3. D 4. D 5. A 6. D 7. A 8. C 9. D 10. B
11. A 12. A 13. D 14. D 15. D 16. A 17. A 18. C 19. A 20. B
21. A 22. A 23. B 24. D 25. A 26. D 27. C 28. A 29. A 30. A
31. B 32. B 33. A 34. C 35. D 36. C 37. B 38. A 39. B 40. A
41. C 42. C 43. A 44. B 45. A 46. B 47. C 48. A 49. B 50. B
51. B 52. D 53. A 54. D 55. A 56. D 57. B 58. C 59. D 60. C

Answers - Finding Output


Compound Assignment Operators
1. 3 8 2. 12 60 3. 5 1 4. 10 16 1 5. 5 2 3
6. 11#0#8 7. 13, 11, 2. 8. 0 3 2# 9. 35 70 135 10. 125 40 75
11. 65 130 45 12. 3 10 39 13. 60 6 10 14. 1 7 25 15. 2 1 0

if..elif..else
1. Non Integer 2. No 3. B 4. 30 15 25 5. True
6. True 7. True 8. b 9. b 10. b
11. 12 12. False 13. 12 14. 6 2 20 15. 20 6 2
16. 2 22 8 17. 1 18. 12 19. -24 20. 684
21. 671 22. 000 23. Lp 24. Not Lp 25. Lp
26. Not Lp 27. Two Digit Number 28. Single Digit Number
29. Two Digit Number 30. Two Digit Number
www.yogeshsir.com Page: A3/52 www.youtube.com/LearnWithYK
QB/XII/CS-083/2025/YK/Answers

Loops
1. 1-3-5-7-9-9 2. 13 9 5 6 3. 0:1:2:7
4. 0:1:2:3:4:11 5. 46567 and 4656 and 6. 1 2 3 -
11 5 6 7 i.9
7. 10 1;16 7;25 7;34 7; 8. 2.0 9. 3.5
10 5 72
10. 469 2 11. 7 $ 12. 1 3
6$ 24
# 35
465 46
57
6 --
13. 0:3&3-3 14. 4--8--11 15. -4--0--3
1:5&5-5
2:7&7-7
7

Lists
1. 73291 2. 4 3. cat
[1, 2, 3] ['ant', 'bat']
[4, 5, 6] ['cat', 'dog', 'eel']
[1, 4] ['eel', 'bat']
4. [8, 6] 5. 2 3 2 3 2 6. 10 11 20
[6, 33, 12, 8, 6]
[8, 23]
[]
7. 526 8. 3 16 64 9. 5#-8#4
10. 6 None 4 11. [1, 2, 'a', 'b'] 12. 1, 2, ['a', 'b']]
13. [1, 2, 3, 4, ['a', 'b']] 14. [1, 2, 3, 4, 'a', 'b'] 15. [1, 2, 'a'] [1, 2, 'a'] [1, 2]
16. 6 17. [1, 2, 3, 3, 4] None 18. [5, 3, 4]
19. 3 20. 31 21. [15, 29, 56, 109, 214]
22. [0, 0, 0, 8, 2, 0, 2, 6, 4] 23. [67, 67, 67, 67, 67, 67] 24. 88
25. 89 59

Tuples
1. 732 2. 4 3. 765
(1, 2, 3)
(4, 5, 6)
(1, 4)
4. 3#[1]#5 5. 1 6. (1, 2, 'a', 'b')
[2, 3, 4, 5, 6]
[2, 3, 4, 5, 6]
7. (1, 2, 3) (1, 2) 8. (1, 2, 3) 9. 3
((1, 2),)

www.yogeshsir.com Page: A4/52 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Answers

10. (3, 2, 4, 1) 11. 3 1 12. [1, 2]


[1, 2, 3, 4] ([1,2], 'a', 'A')
13. [1, 2] 14. (('r', 'e', 'd'), 'yellow') 15. ('r', 'e', 'd')
([1], 'a', 'A') 2 yellow 3e

Strings
1. 7:S:t 2. The Quiz 3. P:s:o:i
(Strings)
18:
:z
4. Na 5. 3333 6. 3444
io
al
9
7. -*-*-*-*-*-*-*-* 8. tional*Na*Ntoa 9. al#Nation#lnia
10. onal:a:Nt 11. 2-4-0-10 12. 1-3-3
13. ['a', 'and', 'b', 'and', 'c'] 14. ['a ', ' b\n', ' c'] 15. ['', ' ', 'nd b']
16. ['', ''] 17. ['a and b'] 18. Vision
19. V,i,s,i,o,n 20. 1 and 2 and 3 21. a*b*c
11 13 5
22. ('Inte', 'r', 'national') 23. ('In', 't', 'ernational') 24. ('I', 'n', 'ternational')
25. ('Inter', 'na', 'tional') 26. ('', 'I', 'nternational') 27. ('Internation', 'al', '')
28. ('International', '', '') 29. ('', 'Pen', ' and Pencil') 30. Writer writes
31. Writer writes 32. their weird foreign 33. their weird foriegn
Writer reads freinds friends
34. 1, 10 35. 8, 8 36. 9, 17
37. -1, -1 38. Live and let live 39. q fOR qUIZ
40. A-n-t

Dictionaries
1. [1, 3] 2. [1, 3]
3. [2, 4] 4. [(1, 2), (3, 4)]
5. {1: None, 2: None, 3: None} 6. {1: 'a', 2: 'a', 3: 'a'}
7. {'a': [1, 2, 3]} 8. {'a': 'app', 'p': 'app'}
9. {1: None, 2: None} 10. {1: None, 2: None}
11. {'One': None, 'Two': None} 12. {(1, 'One'): None, (2, 'Two'): None}
13. {} 14. Two
Two
15. None 16. Two
Three Two
None
None
{1: 'One', 2: 'Two', 3: None}
17. Three 18. Two
Three -
{1: 'One', 2: 'Two', 3: 'Three'}
www.yogeshsir.com Page: A5/52 www.youtube.com/LearnWithYK
QB/XII/CS-083/2025/YK/Answers

19. (2, 'Two') 20. {1: 'One', 2: 'Two', 3: 'Three'}


(1, 'One') {2: 'Two', 3: 'Three'}
21. 1-2- 22. (1, 'One')-(2, 'Two')-
1-2- 1-One
One-Two- 2-Two
23. {1: 'One', 2: 'Four', 3: 'Nine'} 24. (3, 3, 1)
[1, 2, 3]
25. {1: 1, 2: 8} 26. {}
{1: 1, 2: 3, 3: 5}
{1: 1, 2: 3, 3: 5}
27. {1: 'One', 2: 'Two'} 28. {'m': 1, 'i': 4, 's': 4, 'p': 2}
29. {'a': (0, 3), 'b': (1, 2)} 30. {'a': [0, 1, 2, 3], 'm': [0, 1, 2, 3]}

Functions
1. 10 20 2. 10 20 3. 12 10
4. 12 10 5. 10 12 6. 4 5 6
7. 6 12 5 8. 5 1 6 9. Hello
None
10. Hello 11. Hi 12. Done
Hi None
13. HiBye 14. 10 15. 18
11
7
(8, 7)
16. [1, 2, 'H', 'i'] 17. 10 18. [1, 3, 5]
19. [6, 31, 0, 3, 0] 20. (4, 10, 14, 16, 4)

Answers – Correcting the Code


1.
(i) print("three") # OR print('three')
(ii) print(3)
(iii) print(44,'+',56)
(iv) print(3,2, sep=': ')
(v) print("wisdom")
(vi) print('33+44')
(vii) print("15 August 1947")

2.
(i) input("Enter a number:")
(ii) input("Enter your age: ") #No Error
(iii) int(56) #No error
(iv) int("56.6") -> int(56.6) #Remove quotation marks
(v) int("fifty6") -> int('56')
(vi) int('56')
(vii) int(56)

www.yogeshsir.com Page: A6/52 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Answers

(viii) float(12.3) #No Error


(ix) float("-12.45") #No Error
(x) float(5) #No Error
(xi) int(5/4) #No Error
(xii) float("5/4") -> float(5/4) #Remove quotation marks
(xiii) eval('10+2') #No Error
(xiv) eval('10') #No Error
(xv) eval('10') #Eval takes only a string as parameter
(xvi) eval('10*2')
(xvii) int(eval("10/3")) #No Error
(xviii) eval('int(10/3)')
(xix) eval(int("10/3")) -> eval("int(10/3)")
(xx) eval(float("10/3")) -> eval("float(10/3)")

3.
(i) n1,n2=5,4
if n1==n2:
print("Equal")

(ii) n1=n2=12/5
if n1!=n2:
print("Not equal") #indent
else: print("Equal")

(iii) age=12
if age<=10:
print("Primary")
elif age<=13:
print("Middle")
elif age<=15:
print("Secondary")
elif age<=17:
print("Sr Secondary")

(iv) num=int(input("Enter an integer: "))


if num<0:
num=-num;
if num>=0 and num<=9:
print("Single digit number")
elif num>=10 or num<=99: #colon removed after elif
print("Two digit number")
elif num<=999:
print("Three digit number")
else: print("Number contains more than 3 digits")

(v) a=b=c=12,13,14
if (a>=b or a<=c and a+c<=b):
print("A") #Indentation
else: print(a+b+c)

www.yogeshsir.com Page: A7/52 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Answers

4.
(i) a=int(input("Enter a number: "))
c=1
for b in range (a,a*10,a):
c*=b
print(a,b,c)

(ii) a=int(input("Enter a number: "))


b=int(input("Enter another number: "))
start,end=a,b
if a>b:
start,end=b,a
i=start
while i<=end:
if (i%start==0):
print(i,start,end='--')
i+=1
print(i)
(iii) a=int(input("Enter a number: "))
b=int(input("Enter another number: "))
if a>b: step=-1
else: step=1
while a!=b:
if (a+b%2>0):
print(a+b,sep="—")
a=+step
(iv) a=int(input("Enter a number: "))
while a%5!=0:
if (a%2>0):
print(a,sep="—")
a+=1
else: print(a)
(v) x=123045
while x%10:
x//=10
print(x,sep="--")
else: print(x) #deindent

(vi) x=123045
while x%10:
d=x%10
for i in range(d):
print(i)
else: print (d) #deindent
print(x,sep='--')
x//=10
else: print(x)

(vii) n=100; s=0 #OR Write the two statements in separate lines.
for i in range(1,n+1):
if n%i==0:
s+=i
else: n+=1
print(n,s)#
www.yogeshsir.com Page: A8/52 www.youtube.com/LearnWithYK
QB/XII/CS-083/2025/YK/Answers

(viii) a=10
while a>=0:
if a%2==0:
print(a)
else:
print(a//2) #Indentation
a-=1

(ix) d1=dict.fromkeys('banana')
d2=dict.fromkeys('pineapple','apple')
d1.update(d2)
for k in d1.keys():
if k in d2:
print(d2[k], end=' ')
else: print(d1[k])
(x) voter = {'name': "Alok", 'age': 30, 'city': "Agra"}
print(voter["name"])
voter["country"] = "India"
del voter["age"]
(xi) To=30
for K in range(0,To):
if K%4==0:
print (K*4)
else:
print (K+3)

(xii) Number = 250


while Number<=1000:
if Number<=750:
print(Number)
Number=Number+100
else:
print(Number*2)
Number=Number+50

5.
(i) a=[1,2,3,2,1]
for x in range(a):
print(x)

(ii) a=["Umang","Usman","Utkarsh","Umedh"]
for x in range(len(a)):
print(a[x])

(iii) A=[0]*5 #[any value]*5


for i in range(5):
A[i]=i+2
print(A[])
print([A])
A[2:]=A
A[2:5]=8,9,10

www.yogeshsir.com Page: A9/52 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Answers

6. n=int(input("Enter a positive integer: "))


for i in range(n,1,-1):
if i%2==0:
if n%i==0: #indent
print(i,end=' ') #indent
7. n=int(input("Enter an integer: "))
for i in range(1,11):
m=n*i
print(m,end=' ')
8. n=int(input("Enter a positive integer: "))
f=1 #
for i in range(1,n+1): #OR (2,n+1)
f*=i
print(f) #De-indentation
9. from random import randint
nums=list()
for i in range (10):
nums.append(randint(10,99))
print(nums)
10. import random
nums=[random.randint(10,99) for i in range(20)]
i=0
while i<len(nums):
if nums[i]%3==0 and nums[i]%2!=0:
del nums[i]
else: i+=1
11. from random import randint
nums=[randint(10,99) for i in range(10)]
t=tuple()
for num in nums:
if num%5==0:
t+=(num,)
12. t=()
for i in range(10):
num=int(input("Enter an integer: "))
t+=(num,) #
s=0
for i in range(10):
if t[i]%5==0:
s+=t[i]
13. def prime():
n=int(input("Enter number to check: "))
for i in range (2, n//2+1):
if n%i==0:
print("Number is not prime \n")
break
else:
print("Number is prime \n")

www.yogeshsir.com Page: A10/52 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Answers

14. for val in range(1,51):


if val%4==0:
print (val,end=' ')
else:
if val%5==0:
print (val,end=' ')
else:
continue
15. def reverse(n):
rev=0
while n>0:
d=n%10
rev=rev*10+d
n//=10
return rev #De-indentation
print(reverse(1024))

Answers - Writing single statement code


1. L3=[] #OR L3=list()
2. L4=list('Campground')
3. L5=L1[:5]+L2[-5:]
4. print(len(L1))
5. print(len(L1)+len(L2)) #OR print(len(L1+L2))
6. L1.append(L2)
7. L1.extend(L2)
8. L2.insert(3,L1)
9. L2[-1:-1]=L1
10. L1.sort()
11. L2.sort(reverse=True)
12. L1.count(3)
13. L2.append(L1[3])
14. L2.insert(0,L1.pop())
15. L1.remove(3)
16. L1.remove(L1[-1])
17. L2.remove(L1[3])
18. print(L1.index(5))
19. print(L1.index(5,L1.index(5)+1))
20. L1.append(L1.pop(0))
21. L2.insert(0,L2.pop())
22. L2.insert(0,L1.pop())
23. L1.reverse()
24. L6=sorted(L1)
25. L2.insert(4,min(L1))
26. print(sum(L1))
27. print(sum(L2[::2]))
28. print(sum(L1[1::2]))
www.yogeshsir.com Page: A11/52 www.youtube.com/LearnWithYK
QB/XII/CS-083/2025/YK/Answers

29. T1=tuple(L1)
30. T2=T1+tuple(L2)

31. print(len(S1))
32. print(len(S2.split()))
33. print(S1.upper())
34. print(S1.lower())
35. print(S1.capitalize())
36. print(S1.title())
37. print(S1.index(ch))
38. print(S1.find(ch))
39. print(S3.lstrip())
40. print(S3.rstrip())
41. print(S3.strip())
42. print(S4.split())
43. sorted(S1)
44. sorted(S2,reverse=True)
45. high,low=max(S1),min(S2)
46. T3=() #or t3=TUPLE()
47. T4=tuple('Campground')
48. T5=T1[:3]+T2[-3:]
49. print(len(T2))
50. print(len(T1+T2)) #OR print(len(T1+T2))
51. T1=T1+(T2,)
52. T1=T1+T2 #OR T1+=T2
53. T1=T1[:3]+(T2,)+T1[3:]
54. T1.count('e')
55. T2.count(T1[3])
56. print(T2.index('s'))
57. print(T2.index('s',T2.index('s')+1))
58. L1=sorted(T1)
59. print(min(T1),max(T1))
60. print(sum(T1))

61. D3={} #OR D3=dict()


62. dict.fromkeys(D1)
63. print(len(D1))
64. print(list(D1.keys()))
65. print(tuple(D2.values()))
66. print(list(D1.items()))
67. D1.update({4:'d',5:'e'})
68. print(D2['b'])
69. D2.clear()
70. D3=D2.copy()
71. print(D1.pop(2))
72. print(D1.popitem()[0])

www.yogeshsir.com Page: A12/52 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Answers

73. print(D2.popitem()[1])
74. print(D2.get(k))
75. print(D2.setdefault(k,'Kite'))
76. print(sorted(D1.keys()))
77. print(sorted(D2.values()))
78. print(D1[max(D1)])
79. print(D2[min(D2)])
80. D2.update(D1)

Answers - Writing Functions


1. def even(n1,n2):
s=0
for i in range(n1+1,n2):
if i%2==0:
s+=i
return s
2. def proDigits(n):
p=1
while n>0:
d=n%10
n//=10
p*=d
return p
3. def countOddDigits(n):
c=0
while n>0:
d=n%10
n//=10
if d%2==1:
c+=1
print("Number of odd digits =",c)
4. def delete(A, B):
i=0
while i<len(A):
if A[i] in B:
del A[i]
else: i+=1
5. def swap(A):
n=len(A)
A=A[n//2:]+A[:n//2]
print(A)
6. def REVERSE(N):
left,right=0,len(N)-1
while left<right:
N[left],N[right]=N[right],N[left]
left+=1
right-=1

www.yogeshsir.com Page: A13/52 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Answers

7. def Alternate(nums):
n=len(nums)
if n%2==1:
n-=1
for i in range(0,n,2):
nums[i],nums[i+1]=nums[i+1],nums[i]
print(nums)
8. def combine(A,B,C):
n=len(A)
for i in range(n):
x=2*A[i]+3*B[i]
C.append(x)
9. def calculate(A):
n=len(A)
for i in range(n):
if A[i]%5==0:
A[i]//=5
else: A[i]*=2
10. def combine(A,B,C):
n=len(A)
for i in range(n):
C.append(A[i])
C.append(B[i])
11. def replace(A):
n=len(A)
for i in range(n):
if A[i]%2==0:
A[i]//=2
else: A[i]*=2
12. def shortName(ft,md,last):
nm=ft[0]+'. '+md[0]+'. '+last
return nm
13. def palin(S):
if S.upper()==S[::-1].upper():
print('Palindrome')
else: print('Not Palindrome')
14. def countPalin(n):
c=0
for i in range(n):
S=input("Enter a string: ")
if S==S[::-1]:
c+=1
return c

www.yogeshsir.com Page: A14/52 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Answers

15. def counters():


S=input("Enter a string: ")
d=l=u=s=0
for ch in S:
if ch.isdigit():
d+=1
elif ch.islower():
l+=1
elif ch.isupper():
u+=1
elif ch.isspace():
s+=1
print("Digits:",d)
print("Lowercase alphabets:",l)
print("Uppercase alphabets:",u)
print("Whitespace characters:",s)
16. def replace():
S=input("Enter a string: ")
while ' ' in S:
S=S.replace(' ',' ')
return S
17. def countVowelWords():
S=input("Enter a string: ")
words=S.split()
c=0
for word in words:
if word[0] not in 'AEIOU':
c+=1
return c
18. S='Apple in Pineapple'
def characters(S):
chars=[]
for ch in S:
if ch not in chars:
chars.append(ch)
return chars
19. def frequency(S):
freq={}
S=S.upper()
for ch in S:
if ch.isalpha():
if ch in freq:
freq[ch]+=1
else: freq[ch]=1
for k,v in freq.items():
print(k,v,sep=' - ')
20. def sortWords(S):
words=S.split()
words.sort()
print(words)

www.yogeshsir.com Page: A15/52 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Answers

21. def vowelStar(S,ch):


ns=''
for ele in S:
if ele in 'aeiou':
ns+=ch
else: ns+=ele
return ns

Answers - Text File Operations


1. def countSpaces():
with open("PARA.TXT") as f:
data = f.read()
sp=data.count(' ')
print(sp,"spaces in the file")
2. def copyFile():
with open("TEXT1.TXT") as f1:
with open("TEXT2.TXT","w") as f2:
data = f1.read()
words=data.split()
for w in words:
if w[0] not in "AEIOU":
f2.write(w+" ")
3. def story():
with open("STORY.TXT") as f:
c=0
data=f.read()
lines=data.split('\n')
for line in lines:
if line!='' and line[-1] in 'aeiouAEIOU':
c+=1
print(c,"lines ending in a vowel")
4. def Lines():
with open("LINES.TXT") as f:
c=0
data=f.read()
words=data.split()
for w in words:
if w[0] in 'aA':
c+=1
print(c)
5. def copy():
with open("FAIPS.TXT") as f1:
with open("DPS.TXT","w") as f2:
data = f1.read()
words=data.split()
for w in words:
if w[0].isupper():
f2.write(w+" ")

www.yogeshsir.com Page: A16/52 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Answers

6. def show(n):
with open("MIRA.TXT") as f:
data = f.read()
data=data.replace('\n','')
if n<=len(data):
print(data[n-1])
else: print('Invalid n')
7. def memy():
with open("DIARY.TXT") as f:
data = f.read()
data=data.upper()
words=data.split()
c=words.count('ME')+words.count('MY')
print("Count of Me/My in file:",c)
8. def Places():
with open("Places.TXT") as f:
for line in f:
if line[0] in 'PS':
print(line.rstrip())
9. def CountHisHer():
with open("Gender.TXT") as f:
data=f.read()
data=data.upper()
words=data.split()
his=words.count('HIS')
her=words.count('HER')
print('Count of His:',his)
print('Count of Her:',her)
10. def EUCount():
with open("IMP.TXT") as f:
data=f.read()
data=data.upper()
e=data.count('E')
u=data.count('U')
print('E:',e)
print('U:',u)
11. def SUCCESS():
with open("STORY.TXT") as f:
data=f.read()
data=data.upper()
words=data.split()
s=words.count('SUCCESS')
s+=words.count('SUCCESS,')
s+=words.count('SUCCESS.')
print(s)

www.yogeshsir.com Page: A17/52 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Answers

12. def TOWER():


with open("WRITEUP.TXT") as f:
data=f.read()
data=data.upper()
words=data.split()
s=words.count('TOWER')
s+=words.count('TOWER,')
s+=words.count('TOWER.')
print(s)
13. def WORD4CHAR():
with open("FUN.TXT") as f:
data=f.read()
words=data.split()
c=0
for w in words:
if w[-1] in '.,':
w=w[:-1]
if len(w)==4:
print(w,end=' ')
14. def DISP3CHAR():
with open("KIDINME.TXT") as f:
data=f.read()
words=data.split()
c=0
for w in words:
if w[-1] in '.,':
w=w[:-1]
if len(w)==3:
print(w,end=' ')
15. def copyFile():
sf=input("Enter the source file name: ")
tf=input("Enter the target file name: ")
with open(sf) as f1:
with open (tf,'w') as f2:
data=f1.read()
f2.write(data)
16. def copyFile():
sf=input("Enter the source file name: ")
tf=input("Enter the target file name: ")
with open(sf) as f1:
with open (tf,'w') as f2:
data=f1.read()
while ' ' in data:
data=data.replace(' ',' ')
f2.write(data)
17. def lastLine(fn):
with open(fn) as f:
data=f.readlines()
print(data[-1].rstrip())

www.yogeshsir.com Page: A18/52 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Answers

18. def counting():


with open('Books.txt') as f:
data=f.read()
l=u=d=w=0
for ch in data:
if ch.islower():
l+=1
elif ch.isupper():
u+=1
if ch.isdigit():
d+=1
if ch.isspace():
w+=1
print('Lowercase characters:',l)
print('Uppercase characters:',u)
print('Digits:',d)
print('Whitespace characters:',w)
19. def fileSize():
fn=input("Enter the file name: ")
with open(fn) as f:
data=f.read()
data=data.replace(' ','')
data=data.replace('\t','')
data=data.replace('\n','')
print('File size:',len(data))
20. print(open('abc.txt').read())
21. def last3Chars():
with open('story.txt') as f:
data=f.read()
if data[-1]=='\n':
print(data[-4:-1])
else: print(data[-3:])

www.yogeshsir.com Page: A19/52 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Answers

Answers - CSV File Operations

1. import csv
def Append():
F_id=input("Enter furniture ID: ")
desc=input("Enter Description: ")
pr=int(input("Enter Price: "))
disc=float(input("Enter discount: "))
rec=[F_id, desc, pr, disc]
with open("Furniture.csv",'a',newline='') as f:
w=csv.writer(f)
w.writerow(rec)
def countRec():
with open('furniture.csv') as f:
r=csv.reader(f)
c=0
for rec in r:
if int(rec[2])<5000:
c+=1
print(c,'records')
Append()
countRec()
2. import csv
def ADD():
E_id=input("Enter Emplyee ID: ")
name=input("Enter Name: ")
mob=int(input("Enter Mobile Number: "))
rec=[E_id, name, mob]
with open("record.csv",'a',newline='') as f:
w=csv.writer(f)
w.writerow(rec)
def COUNTREC():
with open('record.csv') as f:
r=csv.reader(f)
data=list(r)
print(len(data),'records')
ADD()
COUNTREC()
3. import csv
def addCust():
with open("cust.csv",'a',newline='') as f:
w=csv.writer(f,delimiter='*')
recs=[['001','Nihir',8000],
['104','Akshay',5000]]
w.writerows(recs)
def readCust():
with open('cust.csv') as f:
r=csv.reader(f, delimiter='*')
for rec in r:
print(rec)
addCust()
readCust()

www.yogeshsir.com Page: A20/52 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Answers

4. import csv
def getInventory():
with open("Inventory.csv",'a',newline='') as f:
w=csv.writer(f)
cd=input("Enter inventory code: ")
nm=input("Enter inventory name: ")
pr=input("Enter inventory price: ")
reorder=input("Enter reorder: ")
rec=[cd,nm,pr,reorder]
w.writerow(rec)
def Search(code):
with open('Inventory.csv') as f:
r=csv.reader(f)
found=0
for rec in r:
if rec[0]==code:
print(rec)
found=True
break
if found==False:
print('Record not found')
getInventory()
Search('5')
5. import csv
def add():
with open("furdata.csv",'a',newline='') as f:
w=csv.writer(f)
fid=input("Enter furniture code: ")
fname=input("Enter furniture name: ")
fprice=input("Enter furniture price: ")
rec=[fid,fname,fprice]
w.writerow(rec)
def search():
with open('furdata.csv') as f:
r=csv.reader(f)
found=0
for rec in r:
if int(rec[-1])>10000:
print(rec)
found=1
if found==0:
print("No item with price more than 10000")
add()
search()
6. Statement 1: a
Statement 2: csv.writer(csvf)
Statement 3: csv.writerow(['Title','Author','Price'])
Statement 4: csv.reader(csvf)
Statement 5: r[0][0]=='K'

www.yogeshsir.com Page: A21/52 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Answers

7. Statement-1: csv
Statement-2: 'student.csv','w'
Statement-3: writer(fh)
Statement-4: roll_no, name, Class, section
Statement-5: writerows()
8. Statement 1: import csv
Statement 2: csvwriter.writerows(data)
Statement 3: next(csvreader)
Statement 4: csvreader
9. Line 1: csv
Line 2: 'a'
Line 3: reader
Line 4: ['Arjun', '123@456']
['Arunima', 'aru@nima']
['Frieda', 'myname@FRD']

Answers - Binary File Operations


1. import pickle
def above75():
with open('STUDENT.DAT','rb') as f:
try:
while True:
rec=pickle.load(f)
if rec[-1]>75:
print(rec)
except EOFError:
pass
2. import pickle
def showfile():
with open('SPEED.DAT','rb') as f:
c=0
try:
while True:
rec=pickle.load(f)
print(rec)
c+=1
except EOFError:
print("Total records:",c)

www.yogeshsir.com Page: A22/52 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Answers

3. import pickle
def search(b):
with open('BOOK.DAT','rb') as f:
found=0
try:
while True:
rec=pickle.load(f)
if rec["BookNo"]==b:
print(rec)
found=1
except EOFError:
if found==0:
print("Book not found")
4. import pickle
def search():
with open('VINTAGE.DAT','rb') as f:
found=0
try:
while True:
rec=pickle.load(f)
if 200000<rec[-1]<250000:
print(rec)
found=1
except EOFError:
if found==0:
print("No such vehicle found")
5. import pickle
def AddRec():
with open("LAPTOP.DAT",'ab') as f:
mdl=int(input("Enter Model Number: "))
ram=int(input("Enter RAM: "))
hdd=int(input("Enter HDD: "))
det=input("Enter details: ")
rec=[mdl,ram,hdd,det]
pickle.dump(rec,f)
def Search():
with open('LAPTOP.DAT','rb') as f:
mdl=int(input("Enter model number to search for: "))
found=0
try:
while True:
rec=pickle.load(f)
if rec[0]==mdl:
print(rec)
found=1
except EOFError:
if found==0:
print("No such Laptop found")

www.yogeshsir.com Page: A23/52 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Answers

6. import pickle
def AddRec():
with open("MIC.DAT",'ab') as f:
code=input("Enter Code: ")
br=input("Enter Brand: ")
tp=input("Enter Type: ")
pr=int(input("Enter Price: "))
rec={code:[br,tp,pr]}
pickle.dump(rec,f)
def ShowBT():
with open('MIC.DAT','rb') as f:
c=0
try:
while True:
rec=pickle.load(f)
for k,v in rec.items():
if v[1]=='BT':
print(rec)
c+=1
except EOFError:
print(c,"Records")
7. import pickle
def ShowDetails():
with open('GAMES.DAT','rb') as f:
c=0
try:
while True:
rec=pickle.load(f)
if rec[-1]=="8 to 13":
print(rec)
except EOFError:
pass
8. import pickle
def SALE():
with open('GIFT.DAT','rb') as f:
data=[]
try:
while True:
rec=pickle.load(f)
for k,v in rec.items():
v[1]='ON SALE'
v[2]=v[2]*50/100
rec[k]=v
data.append(rec)
except EOFError:
pass
with open('GIFTS.DAT','wb') as f:
for rec in data:
pickle.dump(rec,f)

www.yogeshsir.com Page: A24/52 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Answers

9. import pickle
def BUMPER():
with open('GIFT.DAT','rb') as f:
try:
while True:
rec=pickle.load(f)
if rec[2]=='ON SALE':
print(rec)
except:
pass
10. import pickle
def Update():
with open('LAPTOP.DAT','rb') as f:
data=[]
try:
while True:
rec=pickle.load(f)
if rec[2]>=1024:
rec[1]=16
data.append(rec)
except EOFError:
pass
with open('LAPTOP.DAT','wb') as f:
for rec in data:
pickle.dump(rec,f)
11. import pickle
def Update():
import pickle
from os import remove, rename
with open('BOOK.DAT','rb') as f1:
with open('TEMP.DAT','wb') as f2:
try:
while True:
rec=pickle.load(f1)
print(rec)
edition=int(input("Enter Edition: "))
rec['Edition']=edition
pickle.dump(rec,f2)
except EOFError:
f1.close()
f2.close()
remove('BOOK.DAT')
rename('TEMP.DAT','BOOK.DAT')

www.yogeshsir.com Page: A25/52 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Answers

12. import pickle


def Delete():
import pickle
from os import remove, rename
with open('PRODUCT.DAT','rb') as f1:
with open('TEMP.DAT','wb') as f2:
try:
while True:
rec=pickle.load(f1)
if rec['p_desc']!='':
pickle.dump(rec,f2)
except EOFError:
f1.close()
f2.close()
remove('PRODUCT.DAT')
rename('TEMP.DAT','PRODUCT.DAT')
13. import pickle
def Delete():
import pickle
data=[]
with open('MIC.DAT','rb') as f1:
try:
while True:
rec=pickle.load(f1)
for k,v in rec.items():
pass
if v[1]=='BT':
pass
else: data.append(rec)
except EOFError:
f1.close()
with open('MIC.DAT','wb') as f1:
for rec in data:
pickle.dump(rec,f1)
14. import pickle
def copy4W():
with open('SPEED.DAT','rb') as f1:
with open('Four_Wheels.DAT','wb') as f2:
try:
while True:
rec=pickle.load(f1)
if rec[1]==4:
pickle.dump(rec,f2)
except EOFError:
pass

www.yogeshsir.com Page: A26/52 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Answers

15. import pickle


def CutPaste():
import pickle
data=[]
with open('MIC.DAT','rb') as f1:
try:
while True:
rec=pickle.load(f1)
data.append(rec)
except EOFError:
f1.close()
with open('MIC.DAT','wb') as f1, open('BT.DAT','wb') as f2:
for rec in data:
for k,v in rec.items():
pass
if v[1]=='BT':
pickle.dump(rec,f2)
else: pickle.dump(rec,f1)
16. def createIndex(tf,bf):
import pickle
with open(tf) as f:
data=f.read()
data=data.upper()
words=data.split()
n=len(words)
for i in range(n): #to remove trailing . or , from words
if words[i][-1] in '.,':
words[i]=words[i][:-1]
words.sort() #Not necessary
index=dict.fromkeys(words)
for k in index:
index[k]=[]
lines=data.split('\n')
n=len(lines)
for i in range(n):
line=lines[i]
words=line.split()
for w in words:
if w[-1] in ',.':
w=w[:-1]
if (i+1) not in index[w]:
index[w].append(i+1)
with open(bf,'wb') as f:
for word_lines in index.items():
pickle.dump(word_lines,f)

www.yogeshsir.com Page: A27/52 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Answers

Answers - Stacks
1. A stack is a linear data structure which facilitates LIFO type of data processing.
A stack should be implemented using a list to allow for insertion and deletion, and it is allowed in a list and not
in a tuple.
2. PUSH inserts an element at the top of a stack.
POP deletes the topmost element of the stack.
3. Characteristics of Stacks:
(i) It is a LIFO data structure
(ii) The insertion and deletion happens at one end i.e. from the top of the stack
4. LIFO – Last In First Out
Stack facilitates LIFO operations.

5. s=[] #stack
def PushKeys(R):
for k, v in R.items():
if v>75:
s.append(k)
def PopKeys():
while s:
print(s.pop(),end=" ")
R={"OM":76, "JAI":45, "BOB":89,"ALI":65, "ANU":90, "TOM":82}
PushKeys(R)
PopKeys()

6. s=[] #stack
def PUSH(N):
for num in N:
if num%2==0:
s.append(num)
def POP():
while s!=[]:
print(s.pop(),end=" ")
N=[12,13,34,56,21,79,98,22,35,38]
PUSH(N)
POP()

7. s=[] #stack
def PUSH(Herbs):
for k,v in Herbs.items():
if v[0]=='G':
s.append((k,v))
def POP():
while s:
print(s.pop(),end=" ")
Herbs={'Adrak':'Ginger', 'Amla': 'Gooseberry', 'Babool': 'Indian Gum',
'Dhania': 'Coriander', 'Lahsun':'Garlic', 'Tulsi': 'Basil'}
PUSH(Herbs)
POP()

8. s=[] #stack
def PUSH(s, ele):
s.append(ele)
def POP(s):
if s==[]: print('Underflow. Stack is empty')

www.yogeshsir.com Page: A28/52 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Answers

else: return s.pop()


n=int(input("Enter an integer: "))
f=2
while n>1:
if n%f==0:
PUSH(s,f)
n//=f
else: f+=1
while s:
print(POP(s),end=' ')

9. s=[] #stack
from random import randint
nums=[randint(10,99) for I in range(20)]
def PUSH(N):
for n in N:
if n%2==0: s.append(n)
for n in N:
if n%2!=0: s.append(n)
def POP():
while s:
print(s.pop(),end=' ')
PUSH(nums)
POP()

10.
After POP(S) After POP(S) After PUSH(S,8)

5 TOP 8 TOP
9 9 TOP 9
2 2 2

After PUSH(S,3) After POP(S) After PUSH(S,9)

3 TOP 9 TOP
8 8 TOP 8
9 9 9
2 2 2

11.
None
10
b
5 6
2

www.yogeshsir.com Page: A29/52 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Answers

12.
After PUSH(S,8) After POP(S) After PUSH(S,3)

8 TOP 3 TOP
9 9 TOP 9
5 5 5
9 9 9
2 2 2

After POP(S) After POP(S) After PUSH(S,3)

9 TOP 9 TOP
5 5 TOP 5
9 9 9
2 2 2

13.
status=[] #stack
def Push_element(cust):
if cust[2]=="Goa":
L1=[cust[0],cust[1]]
status.append(L1)
def Pop_element ():
while status:
dele=status.pop()
print(status.pop(), end=' ')
print("Stack Empty")

14.
stackItem=[] #stack
def Push(SItem):
for k,v in SItem.items():
if (v>75):
stackItem.append(k)
print("The count of elements in the stack is : ", len(stackItem))

www.yogeshsir.com Page: A30/52 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Answers

Answers – Database Management MCQs


1. a 2. c 3. c 4. c 5. b 6. a 7. a 8. d 9. b 10. a
11. b 12. d 13. c 14. d 15. c 16. d 17. a 18. b 19. b 20. a
21. d 22. d 23. d 24. a 25. a 26. d 27. b 28. d 29. a 30. b
31. d 32. b 33. d 34. a 35. b 36. c 37. b 38. c 39. c 40. b
41. d 42. a 43. b 44. d 45. b 46. c 47. b 48. b 49. b 50. b
51. d 52. c 53. c 54. a 55. d 56. d 57. c 58. d 59. a 60. c
61. b 62. d 63. a 64. d 65. a 66. d 67. c 68. a 69. a 70. b
71. d 72. c 73. c 74. b 75. a 76. a 77. c 78. b 79. a 80. c
81. b 82. d 83. c 84. b 85. b 86. b 87. c 88. c 89. c 90. c
91. c 92. b 93. b 94. c 95. c 96. c 97. a 98. c 99. a 100. a

Answers – Database Management - Assertion Reasoning based Questions


1. A 2. B 3. C 4. B 5. C 6. A 7. D 8. D 9. A 10. A
11. D 12. D 13. A 14. B 15. A 16. B 17. A 18. A 19. A 20. D
21. A 22. D 23. B 24. A 25. A 26. D 27. A 28. A 29. D 30. C

Answers – Database Management – Descriptive Questions


1. Show Databases;
2. Use Library;
3. Show tables;
4. Desc BOOKS;
5.
CHAR VARCHAR

Used for fixed length strings Used for variable length strings

Max limit of char is less than that of varchar Max limit of varchar is more than that of char

6. Two characteristics of Primary key column:


a. It cannot have duplicate values
b. It cannot be NULL
7. Domain: A set of legal (valid) values for a column is called the domain of that column. For example, If a table
stores school students' data, then domain for the column Age may be {3, 4, 5, …, 20}.
8. Primary key constraint does not allow NULL whereas Unique constraint allows NULL.
9. Cartesian product of two tables is a table obtained by pairing each tuple of one table with each tuple of the other
table.
10. The percentage character (%) represents a string of zero or more characters, whereas the underscore character
(_) represents a string of exactly one character. For example, 'A%' represents all the strings starting with 'A',
whereas 'A_' represents all the two character strings starting with 'A'.
11. DROP is a DDL command which is used to delete a table or a database, whereas DELETE is a DML command
which is used to delete data from a table. For example:
The command DELETE FROM EMP; will delete all the data from the table EMP. After execution of this
command, the table EMP will be empty.
The command DROP TABLE EMP; will delete the table EMP from the database. After execution of this
command, the table EMP will no more exist.

12. (i) Some entries in the Department column are NULL.


(ii) Command (b) might be giving a higher value.

www.yogeshsir.com Page: A31/52 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Answers

13. A table may have one or more than one such attribute/group of attributes that identify a row/tuple uniquely. All
such attribute(s)/group(s) are known as Candidate keys. Out of the candidate keys, one is selected as primary
key.
Example:
Relation: EMP
ENO Name Sal Dept Email
1 Rajat 50000 SALES [email protected]
2 Sumit 60000 ADMIN [email protected]
3 Aleena 55000 SALES [email protected]
In this relation ENO and Email are Candidate keys. Any one of these can be designated as the Primary key.

14. UNIQUE
15. NOT NULL
16. ALTER TABLE MOBILE DROP PRIMARY KEY;
17. ALTER TABLE MOBILE ADD PRIMARY KEY (M_ID);
18. HAVING is used for including conditions based on aggregate functions on groups.
SELECT DEPT, COUNT(*) FROM EMPLOYEE GROUP BY DEPT HAVING COUNT(*)>1;

Above command will return the number of employees in each department for the departments having more than
1 employee.
19. Degree of a table is the number of columns (attributes) in It, whereas Cardinality is the number of rows (tuples)
in it.
Degree of the given table is 3 and its Cardinality is 2.

20. A table may have one or more than one such attribute/group of attributes that identify a row/tuple uniquely. All
such attribute(s)/group(s) are known as Candidate keys. Out of the candidate keys, one is selected as primary
key and the other candidate keys are known an alternate keys.
Example:
Relation: EMP
ENO Name Sal Dept Email
1 Rajat 50000 SALES [email protected]
2 Sumit 60000 ADMIN [email protected]
3 Aleena 55000 SALES [email protected]

In this relation ENO and Email are Candidate keys. If ENO is selected as the primary key, then Email will be
the alternate key, and vice-versa.

21. Candidate keys: Id, Product Primary key : Id


22. Cartesian Product
Degree = 4
Cardinality = 6
23. Rows: 2, Columns: 4
24. CREATE TABLE STUDENT (NAME VARCHAR(20), CLA INT, SEC CHAR(1), RNO INT,
ACTIVITY VARCHAR(20), PRIMARY KEY(CLA, SEC, RNO));
25. ALTER TABLE ST1 ADD PRIMARY KEY (CLA, SEC, RNO);

Answers – Database Management – Writing Queries


1. create database pracSQL;
2. use pracSQL;
3. create table stdmaster
( AdmNo char(10) primary key,
admdate date,
name varchar(20) not null,
email varchar(30) unique,
class int(2), section char(1), rno int(2) );
www.yogeshsir.com Page: A32/52 www.youtube.com/LearnWithYK
QB/XII/CS-083/2025/YK/Answers

4. desc stdmaster;
5. drop table stdmaster
6. create table stdmaster
(AdmNo char(10), admdate date, name varchar(20),
email varchar(30), class int(2), section char(1), rno int(2));
7. alter table stdmaster add primary key (admno);
8. alter table stdmaster add unique(email);
9. alter table stdmaster change name name varchar(20) not null;
10. (i) insert into stdmaster values('200700001','2007-04-01',
'Abhay','[email protected]',1,'A',1);
(ii) insert into stdmaster values('200700002','2007-04-01',
'Azhar','[email protected]',1,'A',2);
(iii) insert into stdmaster values('200800012','2008-06-13',
'Bharat','[email protected]',5,'B',6);
(iv) insert into stdmaster values('200800007','2008-04-11',
'Sukhdeep','[email protected]',3,'B',11);
(v) insert into stdmaster values('200800009','2008-04-13',
'Benita','[email protected]',3,'C',4);
11. select * from stdmaster;
12. insert into stdmaster values('200800009','2008-04-13',
'Benita','[email protected]',3,'C',4);
13. insert into stdmaster (admno) values('200900012');
14. select * from stdmaster order by class;
15. select * from stdmaster order by class desc;
16. select * from stdmaster order by class, name;
17. select * from stdmaster order by class desc, name;
18. select * from stdmaster where class=1;
19. select * from stdmaster where class>1;
20. select * from stdmaster where class >1 and section='B';
21. select * from stdmaster where class in (1,5);
22. select * from stdmaster where class not in (1,5);
23. select * from stdmaster where not class in (1,3);
24. select distinct class from stdmaster;
25. select * from stdmaster where email is null;
26. select * from stdmaster where email is not null;
27. select admno, admdate, email from stdmaster where name like 'A%';
28. select name from stdmaster where name not like '%a';

29. select * from stdmaster where section between 'B' and 'C';
30. alter table stdmaster add fee float;
31. update stdmaster set fee=class*100;
32. select admno, fee, fee*0.05 as scholarship from stdmaster;
33. select max(fee),min(fee),avg(fee),count(fee),sum(fee) from stdmaster;
34. select max(fee),min(fee),avg(fee),count(fee),sum(fee) from stdmaster where
class=5;
35. select min(fee)*2 as "Lowest Sch", max(fee)*2 as "Highest Sch" from
stdmaster;
36. select section, count(section) from stdmaster group by section;
37. select section, count(section) from stdmaster group by section having
count(section)>1;
38. select section, count(section) from stdmaster where name like 'A%' group
by section;
39. select section, count(section) from stdmaster where name like 'A%' group
by section having count(section)>2;
40. create table HouseAct
(admno char(10), house varchar(10) not null, activity varchar(20),
foreign key (admno) references stdmaster(admno));
www.yogeshsir.com Page: A33/52 www.youtube.com/LearnWithYK
QB/XII/CS-083/2025/YK/Answers

41. (i) insert into HouseAct values('200700001','Peace','Dance');


(ii) insert into HouseAct values('200700002','Harmony','Music');
(iii)insert into HouseAct values('200800009','Hope','Quiz');
(iv)insert into HouseAct values('200700002','Harmony','Dance');
(v) insert into HouseAct values('200700001','Peace','Drama');
(vi)insert into HouseAct values('200700002','Harmony','Photography');
42. select * from HouseAct;
43. select * from stdmaster, HouseAct;
44. select * from stdmaster natural join HouseAct;
45. select h.admno,house,activity,email from stdmaster s, HouseAct h
where s.admno=h.admno;
46. select sm.admno, name, house, activity from stdmaster sm, HouseAct ha
where sm.admno=ha.admno;
47. select stdmaster.admno, name, class, section, activity from stdmaster,
HouseAct where stdmaster.admno=HouseAct.admno;
48. select stdmaster.admno, name, class, section, activity from stdmaster,
HouseAct where stdmaster.admno=HouseAct.admno and activity='dance';
49. select admno, name, class, section, activity from stdmaster natural join
HouseAct;
50. select admno, name, class, section, activity from stdmaster natural join
HouseAct where activity='dance';
51. alter table HouseAct add grade float;
52. alter table HouseAct add column level varchar(10);
53. desc HouseAct;
54. alter table HouseAct drop column level;
55. delete from stdmaster;
56. delete from HouseAct;
57. show tables;
58. drop table HouseAct;
59. drop database pracSQL;
60. show databases;

Answers – Database Management - Writing Queries and Finding Output


1.
a) SELECT * FROM TEACHER WHERE DEPARTMENT = "History";
b) SELECT NAME FROM TEACHER WHERE DEPARTMENT = "Maths" AND SEX = "F";
c) SELECT NAME FROM TEACHER ORDER BY DATE_OF_JOIN;
d) SELECT NAME, SALARY, AGE FROM TEACHER WHERE SEX = "M";
e) SELECT COUNT(*) FROM TEACHER WHERE AGE>23;
2.
a) SELECT * FROM CLUB WHERE SPORTS = "Swimming";
b) SELECT Name FROM CLUB ORDER BY date_of_app desc;
c) SELECT COACHNAME, PAY, AGE, PAY*15/100 AS BONUS FROM CLUB;
d) INSERT INTO CLUB VALUES (11, "Neelam", 35, "Basketyball",
"2000/04/01", 2200, "F");
e)
i. 4
ii. 34
3.
a) SELECT * FROM FURNITURE WHERE TYPE = 'Baby cot';
b) SELECT ITEMNAME FROM FURNITURE WHERE PRICE > 15000;
c) SELECT ITEMNAME, TYPE FROM FURNITURE WHERE DATEOFSTOCK<"2002/01/22"
ORDER BY ITEMNAME DESC;
d) SELECT ITEMNAME, DATEOFSTOCK FROM FURNITURE WHERE DISCOUNT>25;

www.yogeshsir.com Page: A34/52 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Answers

e) SELECT COUNT(*) FROM FURNITURE WHERE TYPE='Sofa';


f) INSERT INTO ARRIVAL VALUES (14, 'Valvet touch', "Double bed",
"2003/03/03");
g)
(i) 5
(ii) 30
(iii) 18.33
(iv) 65500
4.
a) SELECT GAMENAME, GCODE FROM GAMES;
b) SELECT * FROM GAMES WHERE PRZEMONEY > 7000;
c) SELECT * FROM GAMES ORDER BY SCHEDULEDATE;
d) SELECT NUMBER, SUM(PRIZEMONEY) FROM GAMES GROUP BY NUMBER;
(e1) 2
4
(e2) MAX(ScheduleDate) MIN(ScheduleDate)
----------------- -----------------
19-Mar-2004 12-Dec-2003
(e3) 59000
(e4) 101
108
103
5.
(A)
(i) SELECT * FROM WORKER ORDER BY DOB DESC;
(ii) SELECT NAME, DESIG FROM WORKER WHERE PLEVEL IN ("P001", "P002");
(iii) SELECT * FROM WORKER WHERE DOB BETWEEN "19-JAN-1984" AND "18-JAN-
1987";
(iv) INSERT INTO WORKER VALUES (19, 'Daya kishore', 'Operator', 'P003',
'19-Jun-2008', '11-Jul-1984');
(B)
(i) (ii)
COUNT(PLEVEL) PLEVEL MAX(DOB) MIN(DOJ)
1 P001 12-Jul-1987 13-Sep-2004
2 P002
2 P003

(iii) (iv)
Name Pay PLEVEL PAY+ALLOWANCE
Radhey Shyam 26000 P003 18000
Chander Nath 12000
6.
(A)
1) SELECT VehicleName FROM CARHUB WHERE Color = 'WHITE';
2) SELECT VehicleName, Make, Capacity FROM CARHUB ORDER BY CAPACITY;
3) SELECT MAX(Charges) FROM CARHUB;
4) SELECT CName, VehicleName, FROM CUSTOMER, CARHUB
WHERE CUSTOMER.Vcode = CARHUB.Vcode;

(B)
1) 2)
COUNT(DISTINCT Make) MAX(Charges) MIN(Charges)
4 35 12

3) 4)
COUNT(*) VehicleName
5 SX4
C Class
www.yogeshsir.com Page: A35/52 www.youtube.com/LearnWithYK
QB/XII/CS-083/2025/YK/Answers

7.
a) SELECT * FROM ITEMS ORDER BY INAME;
b) SELECT INAME, PRICE FROM ITEMS WHERE PRICE BETWEEN 10000 AND 22000;
c) SELECT TCODE, COUNT(*) FROM ITEMS GROUP BY TCODE;
d) SELECT PRICE, INAME, QTY FROM ITEMS WHERE QTY > 150;
e) SELECT INAME FROM TRADERS WHERE CITY IN ('DELHI', 'MUMBAI');
f) SELECT COMPANY, INAME FROM ITEMS ORDER BY COMPANY DESC;
g1) g2)
MAX(PRICE) MIN(PRICE) AMOUNT
38000 1200 1075000

g3) g4)
DISTINCT TCODE INAME TNAME
T01 LED SCREEN 40 DISP HOUSE INC
T02 CAR GPS SYSTEM ELECTRONIC SALES
T03

8.
(A)
1) SELECT IName, price from Item ORDER BY Price;
2) SELECT SNo, SName FROM Store WHERE Area='CP';
3) SELECT IName, MIN(Price), MAX(Price) FROM Item GROUP BY IName;
4) SELECT IName, Price, SName FROM Item, Store Where Item.SNo =
Store.SNo;
(B)
1) 2)
DISTINCT INAME Area Count(*)
Hard disk CP 2
LCD GK II 1
Mother Board Nehru Place 2

3) 4)
COUNT(DISTINCT AREA) INAME DISCOUNT
3 Keyboard 25
Mother Board 650
Hard Disk 225
9.
(i) SELECT Wno, Name, Gender FROM Worker ORDER BY Wno DESC;
(ii) SELECT Name FROM Worker WHERE Gender='FEMALE';
(iii) SELECT Wno, Name FROM Worker
WHERE DOB BETWEEN '19870101' AND '1991-12-01';
OR
SELECT Wno, Name FROM Worker
WHERE DOB >='1987-01-01' AND DOB <='1991-12-01'
(iv) SELECT COUNT(*) FROM Worker
WHERE GENDER='MALE' AND DOJ > '1986-01-01';

(v) (vi)
COUNT(*) DCODE Department
2 D01 MEDIA
2 D05 MARKETING
INFRASTRUCTURE
FINANCE
HUMAN RESOURCE

www.yogeshsir.com Page: A36/52 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Answers

(vii) (viii)
NAME DEPARTMENT CITY MAX(DOJ) MIN(DOB)
George K MEDIA DELHI 2014-06-09 1984-10-19
Ryma Sen INFRASTRUCTURE MUMBAI
10.
(i) SELECT Eno,Name,Gender FROM Employee ORDER BY Eno;
(ii) SELECT Name FROM Employee WHERE Gender='MALE';
(iii) SELECT Eno,Name FROM Employee
WHERE DOB BETWEEN '19870101' AND '1991-12-01';
OR
SELECT Eno,Name FROM Employee
WHERE DOB >='1987-01-01' AND DOB <='1991-12-01';
OR
SELECT Eno,Name FROM Employee
WHERE DOB >'19870101' AND DOB <'1991-12-01';

(iv) SELECT count(*) FROM Employee


WHERE GENDER='FEMALE' AND DOJ > '1986-01-01';
OR
SELECT * FROM Employee
WHERE GENDER='FEMALE' AND DOJ > '1986-01-01';
(v) (vi)
COUNT(*) DCODE Department
2 D01 INFRASTRUCTURE
2 D05 MARKETING
MEDIA
FINANCE
HUMAN RESOURCE

(vii) (viii)
NAME DEPARTMENT MAX(DOJ) MIN(DOB)
George K INFRASTRUCTURE 2014-06-09 1984-10-19
Ryma Sen MEDIA
11.
(i) SELECT NO, NAME, TDATE FROM TRAVEL ORDER BY NO DESC;
(ii) SELECT NAME FROM TRAVEL
WHERE CODE=101 OR CODE=102;
(iii) SELECT NO, NAME from TRAVEL
WHERE TDATE BETWEEN '2015-04-01' AND '2015-12-31';
(iv) SELECT * FROM TRAVEL WHERE KM > 100 ORDER BY NOP;

(v) (vi)
COUNT(*) CODE DISTINCT CODE
2 101 101
2 102 102
103
104
105

(vii) (viii)
CODE NAME VTYPE NAME KM*PERKM
104 Ahmed Khan CAR Raveena 3200
Ryma Sen Raveena SUV
12.
(i) SELECT CNO, CNAME, TRAVELDATE FROM TRAVEL ORDER BY CNO DESC;

www.yogeshsir.com Page: A37/52 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Answers

(ii) SELECT CNAME FROM TRAVEL WHERE VODE in ('V01', 'V02');


(iii) SELECT CNO, CNAME from TRAVEL WHERE TRAVELDATE LIKE '2015%';
(iv) SELECT * FROM TRAVEL WHERE KM > 120 ORDER BY NOP;

(v) (vi)
COUNT(*) VCODE DISTINCT(VCODE)
2 V01 V01
2 V02 V02
V03
V04
V05

(vii) (viii)
VCODE CNAME VEHICLETYPE CNAME KM*PERKM
V02 Ravi Anish AC DELUXE BUS Sahanubhuti 2700
V04 John Malina CAR

13.
(i) (ii)
MIN(PRICE) MAX(PRICE) COMPANY COUNT(*)
200 4300 LOGITECH 2
CANON 2

(iii) (iv)
PROD_NAME QTY_SOLD PROD_NAME COMPANY QUARTER
MOUSE 3 MOUSE LOGITECH 2
KEYBOARD 2 LASER PRINTER CANON 1
JOYSTICK 2 KEYBOARD LOGITECH 2
JOYSTICK IBALL 1
14.
(A)
a) LABNO, LAB_NAME
b) Degree: 5, Cardinality: 5
(B)
a) INSERT INTO LAB VALUES('L006','PHYSICS','RAVI',25,'II');
b) UPDATE LAB SET CAPACITY=CAPACITY+10 WHERE FLOOR='I';
c) ALTER TABLE LAB ADD PRIMARY KEY (LABNO);
d) DROP TABLE LAB;
15.
CODE BNAME TYPE MNO MNAME ISSUEDATE
L102 Easy Python Programming M101 SNEH SINHA 2022-10-13
C101 Juman Ji Thriller M102 SARA KHAN 2022-06-12
F102 Untold Story Fiction M103 SARTHAK 2021-02-23
16.
(i) (ii) (iii)
Name Project Name Salary Name DOJ
Satyansh P04 Akhtar 125000 Ranjan 2015-01-21
Ranjan P01 Alex 75000 Akhtar 2015-02-01
Muneera P01 Muneera 2018-08-19
Alex P02
Akhtar P04

www.yogeshsir.com Page: A38/52 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Answers

(iv)
EID Name DOB DOJ Salary Project
E01 Ranjan 1990-07-12 2015-01-21 150000 P01
E03 Muneera 1996-11-15 2018-08-19 135000 P01

17.
(i) (ii)
FID MIN(FEES) MAX(FEES) AVG(SALARY)
F01 12000 40000 29500
F03 8000 8000
F04 15000 17000
F05 NULL NULL

(iii) (iv)
FNAME CNAME FNAME CNAME FEES
Neha Python Anishma Grid Computing 40000
Neha Computer Network Neha Python 17000

18.
(i) ADNO, ROLLNO
(ii) Degree: 8, Cardinality: 4
(iii) UPDATE RESULT SET SEM2=SEM2+3/100*SEM2 WHERE SEM2 BETWEEN 70 AND 100;
19.
(i) SNo, as it cannot have same value for multiple records.
(ii) Degree: 8, Cardinality: 7
(iii)
a) alter table Studios add column Founder varchar(20);
b) delete from studios where name='R K Films';
c) ALTER TABLE STUDIOS ADD PRIMARY KEY (SNO);
d) UPDATE STUDIOS SET FOUNDED=2000 WHERE NAME='ASHIRWAD CINEMAS';
20.
(a) (b) (c) (d)
Name Age City Count(*) City Max(Dose1) Min(Dose2)
Harjot 55 Delhi 2 Delhi 2022-01-01 2021-07-20
Srikanth 43 Mumbai 2 Mumbai
Kolkata 1 Kolkata
21.
(a) (b)
DNAME PNAME PNAME ADMDATE FEES
AMITABH NOOR NOOR 2021-12-25 1500
ANIKET ANNI HARMEET 2019-12-20 1500
AMITABH HARMEET
22.
(a) (b)
F_NAME CITY CITY
SAHIL KANPUR KANPUR
VEDA KANPUR ROOP NAGAR
SAMEER ROOP NAGAR DELHI
MAHIR SONIPAT SONIPAT
MARY DELHI
ATHARVA DELHI

www.yogeshsir.com Page: A39/52 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Answers

(c) (d)
F_NAME STATE CITY COUNT(*)
SAHIL UTTAR PRADESH KANPUR 2
MAHIR HARYANA ROOP NAGAR 1
ATHARVA DELHI DELHI 2
VEDA UTTAR PRADESH SONIPAT 1

23.
(i) (ii)
MIN(PRICE) MAX(PRICE) COMPANY COUNT(*)
200 4300 LOGITECH 2
CANON 2

(iii) (iv)
PROD_NAME QTY_SOLD PROD_NAME COMPANY QUARTER
MOUSE 3 MOUSE LOGITECH 2
KEYBOARD 2 LASER PRINTER CANON 1
JOYSTICK 2 KEYBOARD LOGITECH 2
JOYSTICK IBALL 1
24.
(i) (ii)
DISTINCT(COUNT(FCODE)) FCODE COUNT(*) MIN(PRICE)
3 F02 2 750
F01 3 1000

(iii) (iv)
TYPE GCODE TYPE PRICE FCODE ODR_DATE
FROCK G103 FROCK 1000 F01 2021-09-09
G106 FORMAL PANT 1250 F01 2019-01-06
25.
(i) (ii)
PRODUCTNAME COUNT(*) NAME PRICE PRODUCTNAME
MOBILE 3 MOHAN KUMAR 30000 TV

(iii) (iv)
DISTINCT(CITY) CID C_NAME CITY PRODUCTNAME
DELHI 111 SONY DELHI TV
MUMBAI 333 ONIDA DELHI TV
CHENNAI 444 SONY MUMBAI MOBILE
26.
(i) Primary key: S_ID
As it is non-repeating value and not expected to repeat for new rows too.
(ii) Degree = 6 and Cardinality = 5
(iii)
(a) INSERT INTO SALESPERSON VALUES ("S006","JAYA",23,34000,'SOUTH');
(b) UPDATE SALESPERSON SET REGION='SOUTH' WHERE S_NAME="SHYAM";
(a) DELETE FROM SALESPERSON WHERE S_NAME="RISHABH";
(b) ALTER TABLE SALESPERSON DROP COLUMN REGION;

27.
(i) (ii) (iii)
COUNT(DISTINCT(SPORTS)) CNAME SPORTS CNAME AGE PAY
4 AMINA CHESS AMRIT 28 1000
VIRAT 35 1050
www.yogeshsir.com Page: A40/52 www.youtube.com/LearnWithYK
QB/XII/CS-083/2025/YK/Answers

28.
(i) UPDATE Personal SET Salary=Salary + Salary*0.5
WHERE Allowance IS NOT NULL;
(ii) SELECT Name, Salary + Allowance AS "Total Salary" FROM Personal;
(iii) DELETE FROM Personal WHERE Salary>25000

29.
(i) SELECT PName, BName FROM PRODUCT P, BRAND B WHERE P.BID=B.BID;
(ii) DESC PRODUCT;
(iii) SELECT BName, AVG(Rating) FROM PRODUCT P, BRAND B WHERE P.BID=B.BID
GROUP BY BName HAVING BName='Medimix' OR BName='Dove';
(iv) SELECT PName, UPrice, Rating FROM PRODUCT ORDER BY Rating DESC;

30.
(i) (ii) (iii)
ITEM SUM(QTY) ITEM QTY ORDNO ORDATE
RICE 48 RICE 25 1004 2023-12-25
PULSES 29 WHEAT 28 1007 2024-04-30
WHEAT 80
31.
(i) ALTER TABLE Projects ADD PRIMARY KEY (P_id);
(ii) UPDATE Projects SET LANGUAGE= "Python" WHERE P_id = "P002";
(iii) DROP TABLE Projects;

32.
(i) SELECT S_name, Stop_name FROM Admin, Transport
WHERE Admin.S_id = Transport.S_id;
(ii) SELECT COUNT(*) FROM Admin WHERE S_type IS NULL;
(iii) SELECT * FROM Admin WHERE S_name LIKE 'V%';
(iv) SELECT S_id, Address FROM Admin ORDER BY S_name;

33.
(i) (ii)
DISTRIBUTOR SUM(QTY) ITEMNO ITEM
Reliable Stationers 100 402 Gel Pen Premium
Classic Plastics 400 406 Gel Pen Classic
Clear Deals 410

(iii)
ITEM AMOUNT
Gel Pen Premium 3000

34.
(i) ALTER TABLE Rent_cab ADD CONSTRAINT PRIMARY KEY (Vcode);
(ii) UPDATE Rent_cab SET Charges=Charges+Charges*10/100
(iii) DELETE FROM Rent_cab WHERE Make="Carus";

35.
(i) SELECT Type, AVG(Number) FROM GAMES GROUP BY Type;
(ii) SELECT PrizeMoney, GameName, Name FROM GAMES, PLAYERS
WHERE GAMES.GCode=PLAYERS.GCode;
(iii) SELECT DISTINCT TYPE FROM GAMES;
(iv) SELECT GameName, PrizeMoney FROM GAMES
WHERE PrizeMoney IS NOT NULL;

www.yogeshsir.com Page: A41/52 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Answers

36.
(A)
(i) select Product, sum(Quantity) from orders group by product having
sum(Quantity)>=5;
(ii) select * from orders order by Price desc;
(iii) select distinct C_Name from orders;
(iv) select sum(price) as total_price from orders where Quantity IS NULL;

(B)
(i)
C_Name Total_Quantity
Jitendra 1
Mustafa 2
Dhwani 1

(ii)
O_Id C_Name Product Quantity Price
1002 Mustafa Smartphone 2 10000
1003 Dhwani Headphone 1 1500

(iii)
O_Id C_Name Product Quantity Price
1001 Jitendra Laptop 1 12000
1002 Mustafa Smartphone 2 10000
1003 Dhwani Headphone 1 1500

(iv)
MAX(Price)
12000

37.
(i) Select * from FACULTY natural join COURSES where Salary<12000;
OR
Select * from FACULTY, COURSES where Salary<12000 and
facuty.f_id=courses.f_id;
(ii) Select * from courses where fees between 20000 and 50000;
(iii) Update courses set fees=fees+500 where CName like '%Computer%';
(iv) Select FName, LName from faculty natural join courses where
CName="System Design";
(v) Select * from FACULTY, COURSES;

Answers – Database Management - Python – Database Connectivity


1. M1002#Pratik
M1004#Rakesh
2. (a)
Statement 1: mysql.connector
Statement 2: mycursor.execute("delete from Employee
where E_code='E101'")
Statement 3: mydb.commit()

(b)
Statement 1: mysql.connector

www.yogeshsir.com Page: A42/52 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Answers

Statement 2: mycursor.execute("select * from Employee


where city ='Delhi'")
Statement 3: mycursor.fetchall()
3. (a)
Statement 1: mydb.cursor()
Statement 2: mycursor.execute(qry)
Statement 3: mydb.commit()
(b)
Statement 1: mysql.connector
Statement 2: mycursor.execute("select * from Employee
where city ='Delhi'")
Statement 3: mycursor.fetchall()
4. Statement 1: mycursor.execute("use school")
Statement 1: mycursor.execute(querry)
Statement 3: con1.commit()
5. import mysql.connector as mysql
conn=mysql.connect(host="localhost",user="root", password="YK@RJ",
database="SCHOOL")
crsr= conn.cursor()
def insert_rec():
rno=int(input("Enter Roll Number: "))
name=input("Enter name: ")
dob=input("Enter DOB as YYYY-MM-DD: ")
fee=float(input("Enter fee: "))
qry="insert into student values
({},'{}','{}',{})".format(rno,name,dob,fee)
crsr.execute(qry)
conn.commit()
def show():
qry="select * from student where fee>5000"
crsr.execute(qry)
data=qry.fetchall()
for rec in data:
print(rec)
insert_rec()
show()
6. import mysql.connector as mysql
conn=mysql.connect(host="localhost",user="admin", password="Shopping ",
database="SHOP")
crsr= conn.cursor()
qry="update ITEMS set qty=qty-5 where Item_code=111"
crsr.execute(qry)
conn.commit()
7. import mysql.connector as mysql
conn=mysql.connect(host="localhost",user="admin", password="Fly-KM",
database="Travel")
qry="select * from flight"
crsr.execute(qry)
data=qry.fetchall()
for rec in data:
print(rec)

www.yogeshsir.com Page: A43/52 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Answers

8. import mysql.connector as mysql


conn=mysql.connect(host="localhost",user="admin", password="Talent",
database="Recruitment")
qry="delete from Placement where Cname='Vaishali'"
crsr.execute(qry)
conn.commit()
9. import mysql.connector as mysql
conn=mysql.connect(host="localhost",user="Emp11", password="R-11@Bnk",
database="BANK")
crsr= conn.cursor()
Acc=int(input("Enter Account Number: "))
Cname=input("Enter name: ")
Atype=input("Enter Account type: ")
Amt=float(input("Enter amount: "))
qry="insert into student values
({},'{}','{}',{})".format(Acc,Cname,Atype,Amt)
crsr.execute(qry)
conn.commit()
10. def AddAndDisplay():
import mysql.connector as mysql
conn=mysql.connect(host="localhost",user="root", password="Pencil",
database="ITEMDB")
crsr= conn.cursor()
ItNo=int(input("Enter Item Number: "))
Iname=input("Enter Item name: ")
pr=float(input("Enter Price: "))
qty=int(input("Enter quantity: "))
qry="insert into Stationery values
({},'{}',{},{})".format(ItNo,Iname,pr,qty)
crsr.execute(qry)
conn.commit()

www.yogeshsir.com Page: A44/52 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Answers

Answers - Computer Networks MCQs


1. c 2. b 3. a 4. a 5. b 6. a 7. b 8. b 9. a 10. c
11. c 12. b 13. c 14. d 15. d 16. d 17. c 18. a 19. a 20. b
21. a 22. b 23. a 24. b 25. a 26. c 27. b 28. a 29. b 30. a
31. b 32. a 33. c 34. d 35. d 36. c 37. c 38. c 39. a 40. b
41. a 42. d 43. a 44. d 45. a 46. c 47. a 48. d 49. d 50. c

Answers - Computer Networks – Descriptive questions


1. A computer network is a collection of interconnected computers and other communication devices
which are able to communicate with each other and share resources.
2. ARPANET – Advanced Research Projects Agency Network
NSFNET – National Science Foundation Network
PAN – Personal Area Network
LAN – Local Area Network
MAN – Metropolitan Area Network
WAN – Wide Area Network
HTTP – Hypertext Transfer Protocol
FTP – File Transfer Protocol
PPP – Point-to-Point Protocol
SMTP – Simple Mail Transfer Protocol
TCP/IP – Transmission Control Protocol / Internet Protocol
POP3 – Post Office Protocol version 3
HTTPS – Hypertext Transfer Protocol Secure
TELNET – Telecommunication Network
VoIP – Voice over Internet Protocol
WWW – World Wide Web
HTML – Hypertext Markup Language
XML – Extensible Markup Language
URL – Uniform Resource Locator
3. VoIP (Voice over Internet Protocol) is a technology that allows voice communication and multimedia
sessions to be transmitted over the internet or other IP-based networks.
4. VoIP
5. URL - parikshasangam.cbse.gov.in/ps/Home.html
Domain Name - parikshasangam.cbse.gov.in
6. A domain name is a human-readable address used to access websites on the internet. It typically
consists of a name (e.g., cbse) and a domain suffix (e.g., .com, .org).
An IP (Internet Protocol) address is a unique numerical label assigned to each device (such as a server
or computer) connected to the internet.
7. (i) Optical Fiber Cable provides higher bandwidth
(ii) Optical Fiber cable is immune to electromagnetic interference
8. PAN
9. FTP (File Transfer Protocol) works on client-server architecture and is used to transmit files among different
hosts.
HTTP (Hypertext Transfer Protocol) works on client-server architecture and is used to transfer web pages
between a client and a server.
10. Optical Fiber is the fastest wired medium
Microwave is the fastest wireless medium
11. PAN – Connecting a phone and a laptop using Bluetooth
LAN – Computer network in a school
12. Protocol - HTTP. Browser - Chrome
www.yogeshsir.com Page: A45/52 www.youtube.com/LearnWithYK
QB/XII/CS-083/2025/YK/Answers

13. (i) A PAN connects devices within the short range of a person, whereas a LAN connects devices at a single
site, typically an office building.
(ii) PAN often uses Bluetooth and USB ports, whereas LAN commonly uses Ethernet or Wi-Fi.
14. FTP
15. (i) The physical address of a device is its permanent address, whereas its IP address is temporary.
(ii) Physical address is allocated at the time of device manufacturing/assembling, whereas logical address is
allocated when the device is connected to a network.
16. (i) Guided media is wired media, whereas unguided media is wireless media. Examples: Coaxial Cable,
Twisted Pair Cable, Fiber Optics Cable.
(ii) Guided media offers better data security than unguided media. Examples: Infrared Rays, Radio waves,
Micro waves
17. (i) Remote login is a process in which user can login into remote site i.e. computer and use services that are
available on the remote computer.
(ii) A Remote desktop is a program or an operating system feature that allows a user to connect to a computer
in another location, see that computer's desktop and interact with it as if it were local.
18. (i) HTML is mainly used to create the layout and structure of web pages, whereas XML is used for defining
custom data structures and allowing data to be shared across different systems.
(ii) HTML has predefined tags that are used to describe the content, whereas there are no predefined tags in
XML. In XML we can design our own to suit the needs.
19. (i) In bus topology, all devices (computers, printers, etc.) are connected to a single central cable (the bus). This
central cable acts as a shared communication medium.
In star topology, each device is connected to a central hub or switch. The hub manages data traffic between
devices.
(ii) Bus topology is not very scalable; adding new devices can cause signal degradation and network
congestion.
Star topology is easier to scale compared to bus topology. New devices can be added without significant impact
on performance.
20. (i) In Star topology all devices are connected to a central hub or switch, whereas Tree topology is a combination
of star topologies connected in a hierarchical manner.
(ii) In Star topology data passes through the central hub before reaching its destination, whereas in Tree
topology data may have to pass through multiple hubs and switches as it travels up and down the hierarchy.
21. (i) Bus topology

(ii) Star topology

www.yogeshsir.com Page: A46/52 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Answers

22.

23.
Advantages:
1. Simplicity: Bus topology is easy to set up and requires less cable compared to other topologies, making it
cost-effective.
2. Scalability: Adding new devices to the network is straightforward without disrupting the existing
network.
Disadvantages:
1. Limited Length: The length of the bus cable is limited, which can restrict the size of the network.
2. Troubleshooting: If there is a problem with the main cable (bus), the entire network can go down,
making it difficult to troubleshoot.
24.
Advantages:
1. Easy to Manage: Since all devices are connected to a central hub, it's simple to manage and troubleshoot.
If one device fails, it doesn't affect the rest of the network.
2. Scalability: Adding new devices is straightforward. You just connect them to the central hub without
disrupting the existing network.
Disadvantages:
1. Single Point of Failure: If the central hub fails, the entire network goes down, which can be a significant
drawback.
2. Cost: It can be more expensive to set up compared to other topologies because it requires more cable and
a central hub.
25.
Advantages:
1. Cost-Effective: Twisted pair cables are generally cheaper compared to other guided media like coaxial
cables and fiber optics, making them a budget-friendly option for many networks.
2. Flexibility: They are easy to install and can be used in a variety of network setups, from small home
networks to larger business networks.
Disadvantages:
1. Limited Bandwidth: Twisted pair cables have lower bandwidth compared to coaxial cables and fiber
optics, which can limit the speed and capacity of the network.
2. Susceptibility to Interference: They are more prone to electromagnetic interference and crosstalk, which
can affect the quality of the signal.
26.
Advantages:
1. Higher Bandwidth: Coaxial cables offer higher bandwidth compared to twisted pair cables,
allowing for faster data transmission.

www.yogeshsir.com Page: A47/52 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Answers

2. Less Interference: They are less susceptible to electromagnetic interference, providing a more
stable and reliable connection.
Disadvantages:
1. Cost: Coaxial cables are generally more expensive than twisted pair cables, which can increase
the overall cost of the network setup.
2. Flexibility: They are less flexible and harder to install, especially in tight or complex spaces,
compared to twisted pair cables.
27.
Advantages:
1. High Bandwidth: Optical fiber cables offer significantly higher bandwidth compared to other
guided media, allowing for faster data transmission over long distances.
2. Immunity to Interference: They are immune to electromagnetic interference, providing a more
stable and reliable connection, especially in environments with high electrical noise.
Disadvantages:
1. Cost: Optical fiber cables are generally more expensive to install and maintain compared to
twisted pair and coaxial cables, which can increase the overall cost of the network setup.
2. Fragility: They are more fragile and can be easily damaged if not handled properly, requiring
careful installation and maintenance.
28.
Advantages:
1. Security: Infrared rays are confined to a specific area and do not penetrate walls, making them
more secure compared to other unguided media.
2. Interference-Free: They are less prone to electromagnetic interference, providing a stable and
reliable connection in environments with high electrical noise.
Disadvantages:
1. Line of Sight: Infrared communication requires a clear line of sight between the transmitter and
receiver, which can be obstructed by physical objects.
2. Limited Range: The range of infrared communication is relatively short, making it less suitable for
long-distance communication compared to other unguided media.
29.
Advantages:
1. Long Range: Radio waves can travel long distances, making them suitable for wide-area
communication, such as broadcasting and mobile networks.
2. Penetration: They can penetrate through walls and obstacles, providing better coverage in
buildings and urban areas.
Disadvantages:
1. Interference: Radio waves are susceptible to electromagnetic interference from other electronic
devices, which can affect the quality of the signal.
2. Security: Since radio waves can travel long distances and penetrate walls, they are more
vulnerable to unauthorized access compared to other unguided media.
30.
Advantages:
1. High Bandwidth: Microwaves offer higher bandwidth compared to other unguided media, allowing
for faster data transmission.
2. Long Distance Communication: They can cover long distances and are often used for satellite
and long-distance telephone communications.
Disadvantages:
1. Line of Sight: Microwaves require a clear line of sight between the transmitter and receiver, which
can be obstructed by physical objects.
2. Weather Sensitivity: They are susceptible to weather conditions like rain and fog, which can
affect the quality of the signal.

www.yogeshsir.com Page: A48/52 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Answers

Answers - Computer Networks – Case Studies


1. a) HR Center as it has the maximum number of computers.
b)

c) Switch
d) WAN, as the geographical area beyond the limits of MAN.

2. a) Building "JAMUNA" as it has the maximum number of computers.


b)

c) (i) Switch should be placed in each building to interconnect the computers in that
building.
(ii) Repeater should be placed between JAMUNA and RAVI as the distance between
these buildings is more than 90 meters.
d) Optical Fiber

3. a) Faculty Studio building as it has the maximum number of computers.


OR
Administrative building as it is generally the most secure building.

b)

c) LAN
d) Satellite

4. a) Finance. Reason: It has the maximum number of computers.

www.yogeshsir.com Page: A49/52 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Answers

b)

c) Satellite Link
d) Switch

5. a) ADMIN. Reason – It has the maximum number of computers.


b)

c) Firewall
d) Video Conferencing

6. a) B_TOWN as it has the maximum number of computers.


b) Best wired medium: Optical Fiber

c) Switch
d) VoIP

7. (i) IoT block, as it has the maximum number of computers.


(ii) Firewall
(iii) Optical fiber

(iv) a) Switch/Hub: In each block to interconnect the computers in that block.


b) Router: In IoT block (with the server) to interconnect all the three blocks.
(v) VoIP

8. (i) DA Block as it has the maximum number of computers.


(ii) Twisted Pair Cable. It is the most economic cable.

www.yogeshsir.com Page: A50/52 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Answers

OR
Optical Fibre cable. It offers extremely efficient data transfer.
(Both the options are correct with valid reason)
(iii) LAN, as the total area covered has the radius of just a few meters.
(iv) No. Distance between any two buildings is much less than 90 meters.
(v) Firewall

9. (i) Development block as it has the maximum number of computers.


(ii) To ensure the data security and to prevent unauthorized access through network.
(iii) Optical Fiber Cable

(iv) Switch/Hub – In each block to interconnect the computers within that block.
Router – Development block to interconnect the networks of the three blocks.
(v) Using Satellite connection.

10. (i)

(ii) Switch
(iii) Admin Centre because Admin Centre has the maximum number of computers.
(iv) WAN will be formed because the geographical distance between the campuses is more
than the limit of MAN.

www.yogeshsir.com Page: A51/52 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK/Answers

www.yogeshsir.com Page: A52/52 www.youtube.com/LearnWithYK


SQPs
SQP-1/XII/CS-083/2025/YK

Sample Question Paper-1 (Theory)


Class: XII
Session: 2024-25
Computer Science (083)

Time allowed: 3 Hours Maximum Marks: 70

General Instructions:
• Please check this question paper contains 37 questions.
• The paper is divided into 5 Sections- A, B, C, D and E.
• Section A consists of 21 questions (1 to 21). Each question carries 1 Mark.
• Section B consists of 7 questions (22 to 28). Each question carries 2 Marks.
• Section C consists of 3 questions (29 to 31). Each question carries 3 Marks.
• Section D consists of 4 questions (32 to 35). Each question carries 4 Marks.
• Section E consists of 2 questions (36 to 37). Each question carries 5 Marks.
• All programming questions are to be answered using Python Language only.

Section-A (21 x 1 = 21 Marks)

1. State True or False: (1)


Each literal is a token in Python.

2. Identify the output of the following code snippet: (1)


text="Instant*tea".replace('t','aa')
print(text)
(A) Insaaanaa*aaea
(B) Insaaant*tea
(C) Insaanaa*aaea
(D) Insaaanaa*tea

3. Which of the following expressions evaluates to False? (1)


(A) 2 and 3 or not 2>3
(B) True and not True > 5
(C) 2>4 and 4>2
(D) 2>4 or 4>2

4. What will be the output of the following statement? (1)


print('Mississippi'.split("si"))
(A) ['Mis', 's', 'ppi']
(B) ('Mis', 's', 'ppi')
(C) ['Mis', 'si', 's', 'si', 'ppi']
(D) ('Mis', 'si', 's', 'si', 'ppi')

5. What will be the output of the following code snippet? (1)


t1 = tuple('alpha')
t1 += 'beta',
print(len(t1))
(A) 2
(B) 5
(C) 6
(D) 9

6. What will be the output of the following code snippet? (1)


str= "Mississippi";
print(str[2:-2:2])

www.yogeshsir.com SQP1-1/8 www.youtube.com/LearnWithYK


SQP-1/XII/CS-083/2025/YK

7. If gold is a dictionary as defined below, then which of the following statements will create (1)
a dictionary with maximum length?
gold = {'Number': 79, 'mass': 196.97, 'valency': 1}
(A) gold.fromkeys('gold',gold)
(B) gold.fromkeys(gold)
(C) gold.fromkeys(gold,'gold')
(D) gold.fromkeys(gold,gold)

8. What does the list.clear() method do in Python? (1)


(A) Removes all the elements from the list
(B) Sets each element of the list to 0
(C) Sets each element of the list to None
(D) Removes duplicate values from the list

9. State whether the following statement is True or False: (1)


The finally block appears before except block.

10. What will be the output of the following code segment? (1)
a = 20
def add():
global a
a+=5
print(a,end='#')
add()
a=15
print(a,end='%')
(A) 25%15#
(B) 15#25%
(C) 25#15%
(D) 25%15#

11. Write the missing statement to complete the following code: (1)
file = open("myfile.csv", "r")
data = file.read(100)
____________________ #Set the value of file pointer to 20
next_data = file.read(50)
file.close()

12. What happens to the degree/cardinality of a table when we add 5 records to it? (1)

13. Which SQL command is used to delete a column from a table? (1)

14. What will be the output of the query? (1)


SELECT distinct(House) FROM students;
(A) All values from the House column of table Students.
(B) Unrepeated values from the House column of table Students.
(C) Total number of values from the House column of table Students.
(D) Total number of distinct values from the House column of table Students.

15. Which of the following is not a valid datatype in MySQL? (1)


(A) DATA
(B) VARCHAR
(C) FLOAT
(D) CHAR

www.yogeshsir.com SQP1-2/8 www.youtube.com/LearnWithYK


SQP-1/XII/CS-083/2025/YK

16. Which aggregate function ignores NULL values? (1)


(A) sum()
(B) count()
(C) avg()
(D) All of these

17. Which protocol is used to establish a direct connection between two networking devices? (1)
(A) HTTP
(B) FTP
(C) PPP
(D) HTTPS

18. Which network device is used to receive an incoming signal, amplify/regenerate it, and (1)
send it forward?
(A) Modem
(B) Gateway
(C) Switch
(D) Repeater

19. In which network topology all the computers are connected to a central networking device? (1)

Questions 20 and 21 are Assertion (A) and Reasoning (R) based questions. Mark the correct choice as:
(A) Both A and R are true and R is the correct explanation for A
(B) Both A and R are true and R is not the correct explanation for A
(C) A is True but R is False
(D) A is False but R is True

20. Assertion (A): We can define multiple functions with the same name in a Python script. (1)
Reasoning (R): Multiple functions with the same name are called simultaneously.

21. Assertion (A): UPDATE command of SQL is a DML command. (1)


Reasoning (R): Using UPDATE command we change the data and not the structure of a
table/database.

Section-B ( 7 x 2=14 Marks)

22. What is the use of in operator in Python? Give an example to explain. (2)

23. Identify two Arithmetic operators and two Logical operators in the following expression: (2)
5+2>3 and 3-5<5 or 5/2!=5*2 or not 5==10

24. If L1=[1,2,3,2,1,2,4,2, . . . ], and L2=[10,20,30, . . .], then do the (2)


following using built-in functions/methods only:
(I)
A) Write a statement to insert L2 at the end of L1.
OR
B) Write a statement to insert list L2 at L1[2].

(II)
A) Write a statement to create a copy (not an alias) of L1 and name it as L3.
OR
B) Write a statement to delete the last element of L2.

25. Identify the correct possible output(s) of the following code. Also write the minimum and (2)
the maximum possible values of the variable Pass.

www.yogeshsir.com SQP1-3/8 www.youtube.com/LearnWithYK


SQP-1/XII/CS-083/2025/YK

from random import randint


s="Simple"
Pass=randint(1,len(s))
for i in range(Pass,0,-1):
print(s[-i],end='-')
(A) S- (B) i-
(C) l-e- (D) i-m-p-l-e-

26. The function provided below is intended to find and return the sum of all the factors of (2)
a given number (n). For example, if the value of n is 6, the function should return 12
(1+2+3+4+6). However, there are syntax and logical errors in the code. Rewrite it after
removing all errors. Underline all the corrections made.
def sumFact(n)
s=0
for i in range(n):
if n%i=0:
s+=i
return s

27. (I) (2)


A) Give an example of an attribute of a table where UNIQUE constraint must be
applied.
OR
B) Give an example of an attribute of a table where NOT NULL constraint must
be applied.
(II)
A) Write an SQL command to remove the Primary Key constraint from a table,
named DemesticHelp. H_ID is the primary key of the table.
OR
B) Write an SQL command to make the column H_ID the Primary Key of an
already existing table, named DomesticHelp.

28. A) List one advantage and one disadvantage of radio waves as medium of communication. (2)
OR
B) Expand the term XML. What is the use of XML?

Section-C ( 3 x 3 = 9 Marks)

29. A) Write a Python function that displays all the words starting with a lowercase vowel (3)
from a text file "DomHelp.txt". In the output consecutive words should be separated
by a space. For example, if the file contains
The lives of domestic helpers are full of hardships.
They do a lot of work in the employer's house.
Then the output should be:
of are of a of in employer's
OR
B) Write a Python function that counts and displays the number of lowercase vowels in a
text file "DomHelp.txt". For example, if the file contains
The lives of domestic helpers are full of hardships.
They do a lot of work in the employer's house.
Then the output should be:
29 lowercase vowels in the file

30. (A) You have a stack named HelpStack that contains records of Domestic Helpers. Each (3)
record in the stack is represented as a list containing H_Code, H_Name, H_Mobile,
H_Address.

www.yogeshsir.com SQP1-4/8 www.youtube.com/LearnWithYK


SQP-1/XII/CS-083/2025/YK

Write the following user-defined functions in Python to perform the specified


operations on HelpStack:
(I) push_help(HelpStack, new_Help): This function takes the stack HelpStack
and a new help record new_Help as arguments and pushes the new help record
onto the stack.
(II) pop_Help(HelpStack): This function pops the topmost help record from the
stack and returns it. If the stack is already empty, the function should display
"Underflow".
(III) peep(Helptack): This function displays the topmost element of the stack
without deleting it. If the stack is empty, the function should display 'None'.
OR
(B) Write a Python program to input a positive integer and push all its digits in a stack.
Then pop all the digits from the stack and display them. Display the message 'Empty
Stack' after all the digits have been popped from the stack. For example, if the
integer is 5296, then the digits 6,9,2,5 should be pushed in the stack, and after pop
operation the output should be:
5 2 9 6 Empty Stack

31. A) Predict the output of the following code: (3)


d1={'One':0,'Two':0,'Four':0,'Five':0}
for k in d1:
d1[k]=len(k)
d2={}
for k,v in d1.items():
d2[v]=k
print(d1)
print(d2)
OR
B) Predict the output of the following code:
a=list('2and23')
b=sorted(a)
for ele in a:
print(a.index(ele)+b.index(ele),end="-")

SECTION D (4 X 4 = 16 Marks)

32. Based on the table Dhelp, as given below, answer part A to write the queries OR part B (4)
to write the output of the given queries.
Table: DHelp
+------+--------+--------+------+------------+
| Code | Name | Gender | Age | Mobile |
+------+--------+--------+------+------------+
| 1 | Anubha | F | 34 | 1122334455 |
| 2 | Basil | M | 28 | 2233445511 |
| 8 | Chris | M | 32 | 1100334455 |
| 4 | Sania | F | 27 | 1100334465 |
| 6 | Ashish | M | 32 | 1100334565 |
| 5 | Xavier | M | 28 | 1201334565 |
| 7 | Arifa | F | NULL | NULL |
+------+--------+--------+------+------------+
A)
I. To display all the records in the ascending order of Code.
II. To display the mobile numbers of all the records where Gender is M and Age is
less than 30.
III. To display the maximum age and minimum age from the table.

www.yogeshsir.com SQP1-5/8 www.youtube.com/LearnWithYK


SQP-1/XII/CS-083/2025/YK

IV. To display all those names for which the Mobile is not available.
OR
B)
I. select gender, avg(age) from dhelp group by gender;
II. select Code, Name from dhelp where mobile like '%0%';
III. select Code, Name, Age from dhelp where age between 28 and
32;
IV. select count(age) from dhelp;

33. A csv file "DomHelp.csv" contains the data of Domestic Helpers in India. Each record of (4)
the file contains the following data:
• ID (integer)
• Helper’s Name
• Helper’s Gender
• Weekly Work Hours
• Weekly Salary
For example, a sample record of the file may be:
3129, 'Bhanumati', 'F', 20, 2000
Write the following Python functions to perform the specified operations on this file:
(I) Read all the data from the file and display all those records for which the
hourly salary is less than 100 .
(hourly salary = weekly salary / weekly work hours)
(II) Count and display the number of records in the file.

34. Kynara runs a Domestic Help service. She has a database which contains two tables Dhelp (4)
and Contract. Dhelp stores the personal details of helpers, and Contract stores the
employment details of helpers. Sample data from both these tables is given below:
Table: DHelp
+------+--------+--------+------+------------+
| Code | Name | Gender | Age | Mobile |
+------+--------+--------+------+------------+
| 1 | Anubha | F | 34 | 1122334455 |
| 2 | Basil | M | 28 | 2233445511 |
| 8 | Chris | M | 32 | 1100334455 |
| 4 | Sania | F | 27 | 1100334465 |
| 6 | Ashish | M | 32 | 1100334565 |
| 5 | Xavier | M | 28 | 1201334565 |
| 7 | Arifa | F | NULL | NULL |
+------+--------+--------+------+------------+

Table: Contract
+-------+------------+----------+--------+
| HCode | StartDate | Duration | Salary |
+-------+------------+----------+--------+
| 1 | 2024-10-21 | 12 | 12000 |
| 2 | 2024-12-11 | 10 | 11000 |
| 6 | 2024-12-15 | 11 | 13000 |
| 7 | 2025-01-12 | 15 | 11000 |
+-------+------------+----------+--------+
From these two tables we can infer that Anubha got into an employment contract for 12
months on 21st December 2024 at a salary of 12000 per month.

As an assistant to Kynara, help her to extract the following information by writing the
desired SQL queries as mentioned below.
(I) To display the Name and Mobile of all the helpers who are hired for a Salary more
than 11000.

www.yogeshsir.com SQP1-6/8 www.youtube.com/LearnWithYK


SQP-1/XII/CS-083/2025/YK

(II) To display the details of contract whose duration is in the range of 10 to 12 (both
values included), along with the name of the corresponding Helper from the
Dhelp table.
(III) To increase the Salary of all the contracts by 10%.
(IV) (A) To display Name and Gender of all helpers who were hired in the month of
December.
OR
(B) To make Code the primary key of the table Dhelp.

35. A table, named DHelp, in DomServices database, has the following structure: (4)
+--------+-------------+
| Field | Type |
+--------+-------------+
| Code | int(5) |
| Name | varchar(20) |
| Gender | char(1) |
| Age | int(2) |
| Mobile | char(10) |
+--------+-------------+
Write the following Python function to perform the specified operation:
UpdateAndDisplay(): To increase the Age of each record by 1. The function
should then retrieve and display all records from the
DHelp table where the Gender is M.

Assume the following for Python-Database connectivity:


Host: 'localhost', User: 'root', Password: 'Help@DS'

SECTION E (2 X 5 = 10 Marks)

36. Zian is a manager of a Sales agency. He needs to manage the records of various Sales (5)
persons. For this he wants the following information of each Sales person to be stored:
S_ID – integer
S_Name – string
Experience – float
S_Rating - integer
You, as a programmer of the agency, have been assigned to do this job for Zian:
(I) Write a function to input the data of a Sales person and append it in a binary
file 'Sales.dat'.
(II) Write a function to input an S_ID and display the corresponding record from
the file 'Sales.Dat'. If the record is not found, then the function should display
the message "Record Not Found".
(III) Write a function to read the data from the file and display the number of
records where S_Rating is more than 4.

37. XLTech is a software development company with its Head Office in Chennai (in India). It (5)
is planning to set up a new campus in Aurangabad (in India). The Aurangabad campus will
have four blocks/buildings - Admin, Development, Back End, and Research.

www.yogeshsir.com SQP1-7/8 www.youtube.com/LearnWithYK


SQP-1/XII/CS-083/2025/YK

Distance between various blocks, and Number of Computers in each block is given below:
From To Distance Block Computers
ADMIN Development 24 m Admin 10
ADMIN Back End 24 m Development 30
ADMIN Research 24 m Back End 50
Development Back End 50 m Research 20
Development Research 50 m
Back End Research 60 m

Distance of Chennai Head Office from Aurangabad Campus = 1200 km

You, as a network expert, need to suggest the best network-related solutions for them to
resolve the issues/problems mentioned in points (I) to (V), keeping in mind the distances
between various blocks/buildings and other given parameters.
(I) Suggest the most appropriate location of the server inside the Aurangabad
campus. Justify your choice.
(II) Which hardware device will you suggest to connect all the computers within
each building?
(III) Draw the cable layout to efficiently connect various buildings within the
Aurangabad campus. Which cable would you suggest for the most efficient data
transfer over the network?
(IV) Is there a requirement of a repeater in the given cable layout? Why/ Why not?
(V) (A) What would be your recommendation to wirelessly connect Aurangabad
campus to Chennai Head Office in an economical way? Select an option from
the following:
a) Satellite Link
b) Microwave connection
c) Radio wave connection
OR
(B) What type of network (PAN, LAN, MAN, or WAN) will be set up among the
computers connected within the Aurangabad campus?

www.yogeshsir.com SQP1-8/8 www.youtube.com/LearnWithYK


SQP-2/XII/CS-083/2025/YK

Sample Question Paper-2 (Theory)


Class: XII
Session: 2024-25
Computer Science (083)

Time allowed: 3 Hours Maximum Marks: 70

General Instructions:
• Please check this question paper contains 37 questions.
• The paper is divided into 5 Sections- A, B, C, D and E.
• Section A consists of 21 questions (1 to 21). Each question carries 1 Mark.
• Section B consists of 7 questions (22 to 28). Each question carries 2 Marks.
• Section C consists of 3 questions (29 to 31). Each question carries 3 Marks.
• Section D consists of 4 questions (32 to 35). Each question carries 4 Marks.
• Section E consists of 2 questions (36 to 37). Each question carries 5 Marks.
• All programming questions are to be answered using Python Language only.

Section-A (21 x 1 = 21 Marks)

1. State True or False: (1)


Each built-in function name is a keyword in Python.

2. Identify the output of the following code snippet: (1)


a="A1b2".isupper()
print(a)
(A) A1b2
(B) A1B2
(C) True
(D) False

3. Which of the following expressions evaluates to True? (1)


(A) True and False or not True and not False
(B) True and False or not True and True
(C) 2 and 3<1 or 3 and not 2<1
(D) 2 and 3 or 3 and not 2

4. What will be the output of the following statement? (1)


print('Entertainment'.partition("n"))
(A) ['E', 'tertai', 'me', 't']
(B) ('E', 'tertai', 'me', 't')
(C) ['E', 'n', 'tertainment']
(D) ('E', 'n', 'tertainment')

5. What will be the output of the following code snippet? (1)


t1 = tuple('egg'),
t2 = tuple('egg')
print(len(t1), len(t2))
(A) 3 3
(B) 3 1
(C) 1 3
(D) 1 1

6. What will be the output of the following code snippet? (1)


a= list(range(10))
print(a[2::2])

www.yogeshsir.com SQP2-1/9 www.youtube.com/LearnWithYK


SQP-2/XII/CS-083/2025/YK

7. If book is a dictionary as defined below, then which of the following statements will (1)
change the length of the dictionary?
book = {'Code': '004', 'Edition': 2024, 'Price': 100}
(A) book.get(1)
(B) book.setdefault(1)
(C) book.update({'Code':'005'})
(D) book['Edition']=2025

8. What type of parameter, out of the following, is valid for the list.extend() method? (1)
(A) int
(B) float
(C) str
(D) None of these

9. State whether the following statement is True or False: (1)


try..except..finally statement works only for binary files.

10. What will be the output of the following code? (1)


a=[1,2,3]
def f1(b):
b.append('abc')
print(len(b),end='—')
f1(a)
print(len(a),end='+')
(A) 4-4+
(B) 3-3+
(C) 3-4+
(D) 4-3+

11. Write the missing statement to complete the following code: (1)
file = open("myfile.csv", "r")
data = __________ #read first 50 characters from the file
file.close()

12. What happens to the degree/cardinality of an existing table when we remove Primary key (1)
constraint from it?

13. Which SQL command is used to add a column to an existing table? (1)

14. What will be the output of the query? (1)


SELECT count(House) FROM students;
(A) Number of non null values in the House column.
(B) Number of values in the House column.
(C) Total number of records in the table.
(D) Total number of non null records in the table.

15. Which of the following is a valid entry in the date type column of a table in MySQL? (1)
(A) '12-21-2024'
(B) '21-12-2024'
(C) '2024-12-21'
(D) '2024-21-12'

16. Which aggregate function never gives a negative result? (1)


(A) sum()
(B) count()
(C) avg()
(D) All of these
www.yogeshsir.com SQP2-2/9 www.youtube.com/LearnWithYK
SQP-2/XII/CS-083/2025/YK

17. Which protocol is used to transfer files over a TCP/IP network? (1)
(A) HTTP
(B) FTP
(C) PPP
(D) HTTPS

18. Which network device is used to connect two segments of a LAN? (1)
(A) Modem
(B) Gateway
(C) Switch
(D) Router

19. In which network topology all the computers are connected to a common cable? (1)

Questions 20 and 21 are Assertion(A) and Reasoning(R) based questions. Mark the correct choice as:
(A) Both A and R are true and R is the correct explanation for A
(B) Both A and R are true and R is not the correct explanation for A
(C) A is True but R is False
(D) A is False but R is True

20. Assertion (A): We cannot define multiple functions with the same name in a Python script. (1)
Reasoning (R): A function is executed only when it is called.

21. Assertion (A): ALTER command of SQL is a DML command. (1)


Reasoning (R): Using ALTER command we change the structure and not the data of a
table/database.

Section-B ( 7 x 2=14 Marks)

22. Give an example of a Boolean expression in Python. What are the possible values of a (2)
Boolean expression?

23. Evaluate the following expressions: (2)


(i) 15//2/2*3+4**2*2 (ii) 2 or 3 and not 5

24. If S1="Web", and S2="Programming", then do the following using built-in (2)
functions/methods only:
(I)
A) Write a statement to display S2 in upper case.
OR
B) Write a statement to create a list containing characters of S1 as its elements.

(II)
A) Write a statement to display the number of times 'm' appears in S1.
OR
B) Write a statement to display W-e-b by applying a string method on S1.

25. Identify the correct possible output(s) of the following code. Also write the minimum and (2)
the maximum possible values of the variable Pos.
from random import randrange
for i in range(4):
Pos=randrange(i+4)
print(Pos,end='-')

(A) 1-2-1-0- (B) 3-3-2-6-


(C) 4-3-4-2- (D) 1-5-2-1-

www.yogeshsir.com SQP2-3/9 www.youtube.com/LearnWithYK


SQP-2/XII/CS-083/2025/YK

26. The function provided below is intended to find and return the sum of the digits of a (2)
given positive integer (n). For example, if the value of n is 621, the function should return
9 (6+2+1). However, there are syntax and logical errors in the code. Rewrite it after
removing all errors. Underline all the corrections made.
def sumDigits(n):
s==0
while n=0:
d=n//10
s+=d
n//=10
Return s

27. (I) (2)


A) Write any two restrictions applicable on the Primary key attribute of a table?
OR
B) What is a composite Primary key?
(II)
A) Write an SQL command to remove the column Sugar from a table Juice.
OR
B) Write an SQL command to add a column Sugar of type char(1) to a table
Juice.

28. A) List one advantage and one disadvantage of Micro waves as medium of communication. (2)
OR
B) Expand the term HTML. What is the use of HTML?

Section-C ( 3 x 3 = 9 Marks)

29. A) Write a Python function that displays all the lines ending with a lowercase vowel from (3)
a text file "Juice.txt". For example, if the file contains
Juices like beetroot juice, pomegranate
and citrus are heart-healthy due to their
antioxidant content and ability to
improve circulation, reduce blood pressure,
and lower cholesterol levels.
Then the output should be:
Juices like beetroot juice, pomegranate
antioxidant content and ability to
OR
B) Write a Python function that counts and displays the number of 5 letter words in a text
file "Juices.txt". In the output consecutive words should be separated by a space.
For example, if the file contains
Juices like beetroot juice, pomegranate
and citrus are heart-healthy due to their
antioxidant content and ability to
improve circulation, reduce blood pressure,
and lower cholesterol levels.
Then the output should be:
their blood lower

30. (A) A stack named Juices contains records of some juices. Each record in the stack is (3)
represented as a list containing Name, Size, Price.
Write the following user-defined functions in Python to perform the specified
operations on the stack Juices:

www.yogeshsir.com SQP2-4/9 www.youtube.com/LearnWithYK


SQP-2/XII/CS-083/2025/YK

(I) push_Juice(Juices, new_Juice): This function takes the stack Juices


and a new Juice record new_Juice as arguments and pushes the new Juice record
onto the stack.
(II) pop_Juice(Juices): This function pops the topmost Juice record from the
stack and returns it. If the stack is already empty, the function should display
"Underflow".
(III) peep(Juices): This function displays the topmost element of the stack
without deleting it. If the stack is empty, the function should display 'None'.
OR
(B) Write a Python program to generate a list of 20 2-digit random integers and push all
elements of the list which are divisible by 5 onto a stack. Then pop all the numbers
from the stack and display them.

31. A) Predict the output of the following code: (3)


s='Tic-Tac-Toe'
d1=dict.fromkeys(s,0)
for k in s:
d1[k]+=1
print(d1)
OR
B) Predict the output of the following code:
a=[0]*12
a[1::2]='banana'
a[::2]='grapes'
for ch in a[::-2]:
print(a.index(ch),end='-')

SECTION D (4 X 4 = 16 Marks)

32. Based on the table Drinks, as given below, answer part A to write the queries OR part B (4)
to write the output of the given queries.
Table: Drinks
+-------+------+-------+------------+
| Name | Size | Price | Remarks |
+-------+------+-------+------------+
| Apple | S | 0.75 | Apple Only |
| Apple | M | 1 | Apple Only |
| Apple | L | 1.5 | Apple Only |
| Mango | L | 2 | Shake |
| Mango | M | 1.5 | Shake |
| Mango | S | 0.75 | Mango Only |
+-------+------+-------+------------+
A)
I. To display the average price of each kind of drink based on its Name.
II. To display the details of all drinks where Remarks is Shake.
III. To display the number of records where Remarks contains 'Only'.
IV. To display all those records where price is less than 1.
OR
B)
I. select name, price from drinks where size in ('S','M');
II. select min(price), max(price) from drinks group by size;
III. select distinct(size) from drinks;
IV. select Name, Size, Price from Drinks
where price between 1 and 2 order by price;

www.yogeshsir.com SQP2-5/9 www.youtube.com/LearnWithYK


SQP-2/XII/CS-083/2025/YK

33. A csv file "Juices.csv" contains the records of Juices made by a Juice manufacturer. Each (4)
record of the file contains the following data:
• ID (5 character string)
• Content (Main Fruit's Name – a string)
• Sugar (A single character string - Y for Yes and N for No)
• Qty (integer)
• Price (integer)
For example, a sample record of the file may be:
'MSF12', 'Mango', 'N', 150, 20
Write the following Python functions to perform the specified operations on this file:
(I) Append a record to the file. Data should be input from the user.
(II) Display all those records from the file for which Sugar is 'N'.

34. Abhishek manages a Fruit Juice Sales agency. He has a database which contains two tables (4)
- Juices and Orders. Juices stores the details of juices and Orders stores the details of
the orders received. Sample data from both these tables is given below:
Table: Juices
+-------+---------+-------+------+-------+
| J_ID | Content | Sugar | Qty | Price |
+-------+---------+-------+------+-------+
| MSF12 | Mango | N | 150 | 20 |
| ASF12 | Apple | N | 150 | 20 |
| MXS25 | Mix | Y | 250 | 50 |
| GrS35 | Grapes | Y | 1000 | 250 |
+-------+---------+-------+------+-------+
Table: Orders
+------+------------+-------+-------+----------+
| O_No | O_Date | J_ID | O_Qty | Discount |
+------+------------+-------+-------+----------+
| 201 | 2024-12-15 | ASF12 | 50 | 0.5 |
| 108 | 2024-12-21 | MXS25 | 100 | 0.75 |
| 12 | 2025-01-03 | MSF12 | 100 | NULL |
+------+------------+-------+-------+----------+
As a database expert, help Abhishek to extract the following information by writing the
desired SQL queries as mentioned below.
(I) To display the details of all the juices for which some order has been placed.
(II) To display the details of all the orders placed in the year 2024 along with the
corresponding Content from the table Juices.
(III) To display the value of each order after considering the discount.
(value = O_Qty*Price*(100-Discount))
(IV) (A) For some records the value of discount is NULL, and for some other records it
is 0. Display the corresponding J_ID and Price for all such orders.
OR
(B) To add a column BalQty of type int(4) to the table Juices.

35. A table, named Juices, in AbhiSales database, has the following structure: (4)
+---------+-------------+
| Field | Type |
+---------+-------------+
| J_ID | char(5) |
| Content | varchar(10) |
| Sugar | char(1) |
| Qty | int(4) |
| Price | int(4) |
+---------+-------------+
Write the following Python function to perform the specified operation:

www.yogeshsir.com SQP2-6/9 www.youtube.com/LearnWithYK


SQP-2/XII/CS-083/2025/YK

DeleteAndDisplay(): To input a J_ID from the user and delete the corresponding
record from the table. The function should then retrieve
and display all records from the Juices table.

Assume the following for Python-Database connectivity:


Host: 'localhost', User: 'Guest', Password: 'Abhi-J'

SECTION E (2 X 5 = 10 Marks)

36. Rajesh is a production manager working in an Export firm. He needs to manage the records (5)
of employees working for him. For this he wants the following information of each
employee to be stored:
E_ID – integer
E_Name – string
E_Age – integer
E_Salary - integer
Experience – float
You, as a programmer of the company, have been assigned to do this job for Rajesh:
(I) Write a function to input the data of an employee and append it in a binary
file 'Emp.dat'.
(II) Write a function to input an E_ID and display the corresponding record from
the file 'Emp.Dat'. If the record is not found, then the function should display
the message "Record Not Found".
(III) Write a function to read the data from the file and display the number of
records where E_Age is less than 30.

37. Total Health is a chain of Hospitals with its Head Office in Panipat. It has a big hospital in (5)
Rourkela which is 1500km away from Panipat. Rourkela hospital has four major blocks –
Admin, Inpatient, Outpatient, and Emergency.

Distance between various blocks, and Number of Computers in each block is given below:
From To Distance Block Computers
ADMIN Inpatient 24 m Admin 10
ADMIN Outpatient 24 m Inpatient 30
ADMIN Emergency 24 m Outpatient 50
Inpatient Outpatient 50 m Emergency 20
Inpatient Emergency 50 m
Outpatient Emergency 60 m

The management of Total Health wants to restructure the existing Computer Network
setup in Rourkela hospital. You, as a network expert, need to suggest the best network-
related solutions for them to resolve the issues/problems mentioned in points (I) to (V),
keeping in mind the distances between various blocks/buildings and other given
parameters.

www.yogeshsir.com SQP2-7/9 www.youtube.com/LearnWithYK


SQP-2/XII/CS-083/2025/YK

(I) Suggest the most appropriate location of the server inside the Aurangabad
campus to ensure maximum safety of the server. Justify your choice.
(II) Which hardware device will you suggest to connect all the computers within
each block?
(III) Draw the cable layout to efficiently connect various blocks of Rourkela
hospital. Which device will you suggest to interconnect the networks of various
blocks?
(IV) Is there a requirement of a repeater in the given cable layout? Why/ Why not?
(V) (A) What would be your recommendation to wirelessly connect Rourkela
hospital to Panipat Head Office. Keep in mind that time is a critical factor in
healthcare services. The connection should be the fastest one. Select an option
from the following:
a) Satellite Link
b) Microwave connection
c) Radio wave connection
OR
(B) The doctors of the Rourkela hospital have to regularly attend online
workshops to keep themselves updated. Which protocol is used for these
workshops which involve audio-visual data communication?

www.yogeshsir.com SQP2-8/9 www.youtube.com/LearnWithYK


AnsKey/SQP-1/XII/CS-083/2025/YK
SQP-2/XII/CS-083/2025/YK

Answer Key
Sample Question Paper-2 (Theory)
Class: XII
Session: 2024-25
Computer Science (083)

Time allowed: 3 Hours Maximum Marks: 70

Section-A (21 x 1 = 21 Marks)

1. False (1)

2. (D) False (1)

3. (C) 2 and 3<1 or 3 and not 2<1 (1)

4. (D) ('E', 'n', 'tertainment') (1)

5. (C) 1 3 (1)

6. [2, 4, 6, 8] (1)

7. (B) book.setdefault(1) (1)

8. (C) str (1)

9. False (1)

10. (A) 4-4+ (1)

11. file.read(50) (1)

12. No change in the degree or cardinality of the table. (1)

13. ALTER (or ALTER TABLE) (1)

14. (A) Number of non null values in the House column. (1)

15. (C) '2024-12-21' (1)

16. (B) count() (1)

17. (B) FTP (1)

18. (D) Router (1)

19. Bus (1)

20. (D) A is false but R is true (1)

21. (D) A is false but R is true (1)

Section-B ( 7 x 2=14 Marks)

22. Example of a Boolean expression: 2>3 (2)


Possible values of a Boolean expression are True and False.

23. (i) 42.5 (2)


(ii) 2

www.yogeshsir.com SQP2-9/9 www.youtube.com/LearnWithYK


SQP-3/XII/CS-083/2025/YK

Sample Question Paper-3 (Theory)


Class: XII
Session: 2024-25
Computer Science (083)

Time allowed: 3 Hours Maximum Marks: 70

General Instructions:
• Please check this question paper contains 37 questions.
• The paper is divided into 5 Sections- A, B, C, D and E.
• Section A consists of 21 questions (1 to 21). Each question carries 1 Mark.
• Section B consists of 7 questions (22 to 28). Each question carries 2 Marks.
• Section C consists of 3 questions (29 to 31). Each question carries 3 Marks.
• Section D consists of 4 questions (32 to 35). Each question carries 4 Marks.
• Section E consists of 2 questions (36 to 37). Each question carries 5 Marks.
• All programming questions are to be answered using Python Language only.

Section-A (21 x 1 = 21 Marks)

1. State True or False: (1)


Built-in function names can be redefined as variable names in Python.

2. Identify the output of the following code snippet: (1)


a="Nice Weather".find('E')
print(a)
(A) 3
(B) 4
(C) -1
(D) Error

3. Evaluate the following expression: (1)


0 or '0' and not 0 or not []

4. What will be the output of the following statement? (1)


print('ab'.join('abc'))
(A) ababcab
(B) aabbabc
(C) ['ab','abc','ab']
(D) ['a','abc','b']

5. If T1=(1,2,3) then which of the following statements will give syntax error or run time (1)
error?
(A) T1=[1,2,3]
(B) del T1
(C) print(T1[2])
(D) T1[1]=2

6. What will be the output of the following code snippet? (1)


a= 'even'[1:10]+'odd'[-1::-1]
print(a)

7. If rec is a dictionary in Python, then write a statement which creates another dictionary (1)
with the keys of rec and value of each key should be 10.

www.yogeshsir.com SQP3-1/8 www.youtube.com/LearnWithYK


SQP-3/XII/CS-083/2025/YK

8. What type of parameter, out of the following, is valid for the list.append() method? (1)
(A) int
(B) tuple
(C) dictionary
(D) All of these

9. State whether the following statement is True or False: (1)


There can be multiple except blocks in a try..except..finally statement.

10. What will be the output of the following code snippet? (1)
a=1,2,3,
def f1(a):
a=2,3,4,5
print(len(a),end='—')
f1(a)
print(len(a),end='+')
(A) 4-4+
(B) 3-3+
(C) 3-4+
(D) 4-3+

11. Write the missing statement to complete the following code: (1)
file = open("myfile.csv", "r")
data = __________ #read first line from the file
file.close()

12. A table cannot have multiple (1)


(A) Candidate Keys
(B) Primary Keys
(C) Alternate Keys
(D) Foreign Keys

13. Which SQL command is used to view the structure of an existing table? (1)

14. A table contains data of 30 students of a class. The table has 6 columns. The roll numbers (1)
of the students are integers from 101 to 130. What is the domain of the column RollNumber
of this table?
(A) 6
(B) 101, 130
(C) Set of integers from 1 to 30.
(D) Set of integers from 101 to 130.

15. The cardinality of the cartesian product of two tables is equal to the: (1)
(A) sum of the degrees of the tables.
(B) product of the degrees of the table.
(C) sum of the cardinalities of the tables.
(D) product of the cardinalities of the tables.

16. The acronym SQL stands for: (1)


(A) Sequential Query Language
(B) Structured Queue Language
(C) Structured Query Language
(D) None of these

www.yogeshsir.com SQP3-2/8 www.youtube.com/LearnWithYK


SQP-3/XII/CS-083/2025/YK

17. In which of the following switching techniques the data is divided into packets and each (1)
packet follows its own path?
(A) Circuit Switching
(B) Packet Switching
(C) Network Switching
(D) Message Switching

18. Which of the following wireless media is used for short distance communication (For (1)
example, within a room) and cannot cross hard obstacles?
(A) Infrared Rays
(B) Radio Waves
(C) Micro Waves
(D) All of these

19. Which network topology is usually a combination of Tree and Start topologies? (1)

Questions 20 and 21 are Assertion (A) and Reasoning (R) based questions. Mark the correct choice as:
(A) Both A and R are true and R is the correct explanation for A
(B) Both A and R are true and R is not the correct explanation for A
(C) A is True but R is False
(D) A is False but R is True

20. Assertion (A): If n in nums is a valid statement in Python, then nums must be an (1)
iterable.
Reasoning (R): The second operand of in operator must be an iterable.

21. Assertion (A): The number of Alternate Keys of a table can be more than the number of (1)
its Candidate Keys.
Reasoning (R): Each Alternate Key is a Candidate Key.

Section-B ( 7 x 2=14 Marks)

22. What is a literal in Python? Give an example of an integer literal and a string literal. (2)

23. Evaluate the following expressions: (2)


(i) 15//2%2*(3+4)**2*2 (ii) True and not True or not False

24. If S1=" Alpha ", and S2="\n\nBeta ", then do the following using built- (2)
in functions/methods only:
(I)
A) Display S1 without the leading spaces.
OR
B) Remove the trailing spaces from S2 and store the resultant string in the variable
S3.
(II)
A) Display sorted list of characters of S1.
OR
B) Display the length of S2.

25. Identify the correct possible output(s) of the following code. Also write the minimum and (2)
the maximum possible values of the variable b.
import random
for i in range(4,8):
a=random.randint(1,i)
b=random.randrange(i)
print(a+b,end='-')
(A) 1-2-3-4- (B) 5-6-5-7-
(C) 1-10-3-9- (D) 5-9-6-1-
www.yogeshsir.com SQP3-3/8 www.youtube.com/LearnWithYK
SQP-3/XII/CS-083/2025/YK

26. The function provided below is intended to find and display the number of even elements (2)
in a given list (nums) of integers. For example, if the list nums is
[1,2,50,20,23,45,6] then the function should display 4 because the list contains
four even numbers. However, there are syntax and logical errors in the code. Rewrite it
after removing all the errors. Underline all the corrections made.
def countEven(nums)
c=0
for ele in nums:
if ele%2=0:
c=+1
print('c')

27. (I) (2)


A) Write an SQL command to remove a table Groups from a database Sports.
OR
B) Can we create the natural join of two tables which have a common column name
but they are not interrelated using Foreign Key constraint?
(II)
A) Write an SQL command to remove a database named Sports.
OR
B) Can we create the natural join of two tables which have two common column
names?

28. A) List one advantage and one disadvantage of Bus topology. (2)
OR
B) Expand the term SMTP. What is the use of SMTP?

Section-C ( 3 x 3 = 9 Marks)

29. A) Write a Python function that displays the last word of each line of a text file (3)
"Sports.txt". For example, if the file contains
Sports offer a wide range of benefits,
both physical and mental.
In essence, sports contribute to a
well-rounded and balanced lifestyle
by improving health.
Then the output should be:
benefits
mental
a
lifestyle
health
Note that the trailing comma(,) and dot(.) are not the part of a word.
OR
B) Write a Python function that counts and displays the number of special characters
appearing in a text file "Sports.txt".
Note: Special characters are the characters other than alphabets and digits.

30. (A) Assume that a list contains record of a movie in the following format: (3)
[Movie_ID, Movie_name, Director, Rating]
Write the following user defined functions to perform given operations on the stack
named "Ratings":
(i) Push_Movie(M) - To Push an object containing Movie_name and Director if
its rating is in the range 8 to 9. M is a list containing data of one movie.
(ii) Pop_Movie(M) - To Pop all the objects from the stack and display them.
Also, display the total number of records popped from the stack.

www.yogeshsir.com SQP3-4/8 www.youtube.com/LearnWithYK


SQP-3/XII/CS-083/2025/YK

OR
(B) (i) Write a function in Python, Push(Color, S), where Color is a tuple containing
color names, and S is a stack.

The function should push those color names in stack S, whose length is more than 5.

For example: If Color is ('Yellow', 'Blue', 'Green', 'Pink',


'Red', 'Magenta')

Then, the stack should contain


Magenta
Yellow
(ii) Write a function in Python, Pop(S), to pop all the elements from the stack S and
display them. At the end, the function should display the message "Stack
Empty".

31. A) Predict the output of the following code: (3)


a=[12,21,23,65,38]
for i in range(5):
x=a[i]%10
y=a[-i]//10
print(x+y,end='-')
OR
B) Predict the output of the following code:
a={1:2,3:4,5:6,7:8,9:10}
for ele in a.items():
x=sum(ele)
print(x,end='-')

SECTION D (4 X 4 = 16 Marks)

32. Based on the table Movies, as given below, answer part A to write the queries OR part B (4)
to write the output of the given queries.
Table: Movies
+-------+----------------+------+----------------+------------+-------+
| MID | Title | Year | Director | Actor | music |
+-------+----------------+------+----------------+------------+-------+
| MV001 | Chakravyuh | 2012 | Prakash Jha | Abhay Deol | M002 |
| MV002 | Madras Cafe | 2013 | Shoojit Sircar | J. Abraham | M001 |
| MV003 | Jai Gangajal | 2016 | Prakash Jha | P. Chopra | M002 |
| MV004 | Saand Ki Aankh | 2019 | Prakash Jha | T. Pannu | M003 |
| MV005 | Gulabo Sitabo | 2020 | Shoojit Sircar | A. Khurana | M001 |
| MV006 | Sardar Udham | 2021 | Shoojit Sircar | V. Kaushal | M001 |
+-------+----------------+------+----------------+------------+-------+
A)
I. To display the Titles of the movies whose Actor is Abhay Deol.
II. To display the details of all movies released in the year 2012.
III. To display the number of records where Music is 'M001'.
IV. To display the details of all the movies directed by Prakash Jha.
OR
B)
I. select Year, count(*) from movies group by year;
II. select Music, count(*) from movies group by Music;
III. select mid,title from movies where year between 2013 and
2018;
IV. select mid,title,year from movies where director != 'Prakash
Jha' order by title;

www.yogeshsir.com SQP3-5/8 www.youtube.com/LearnWithYK


SQP-3/XII/CS-083/2025/YK

33. A csv file "Movies.csv" contains the records of Indian Movies. Each record of the file (4)
contains the following data:
• M_ID (Movie Code – A 5 character string)
• Title (Movie Title - A string)
• Year (Year of release – An integer)
• Director (Name of the Director – A string)
• Music (Musician Code – A 4 character string)
For example, a sample record of the file may be:
['MV002', 'Madras Cafe', 2013, 'Shoojit Sircar', 'M001']
Write the following Python functions to perform the specified operations on this file:
(I) Append a record to the file. Data should be input from the user.
(II) Display the details of all the movies released in the year 2024. At the end
display the total number of such movies.

34. Alisha is a movie lover and likes to keep records of Indian movies. For this, she has created (4)
a database with two tables - Movies and Musician. Movies stores the details of the movies
and Musician stores the details of the musicians. Sample data from both these tables is
given below:
Table: Movies
+-------+----------------+------+----------------+------------+-------+
| MID | Title | Year | Director | Actor | Mu_ID |
+-------+----------------+------+----------------+------------+-------+
| MV001 | Chakravyuh | 2012 | Prakash Jha | Abhay Deol | M002 |
| MV002 | Madras Cafe | 2013 | Shoojit Sircar | J. Abraham | M001 |
| MV003 | Jai Gangajal | 2016 | Prakash Jha | P. Chopra | M002 |
| MV004 | Saand Ki Aankh | 2019 | Prakash Jha | T. Pannu | M003 |
| MV005 | Gulabo Sitabo | 2020 | Shoojit Sircar | A. Khurana | M001 |
| MV006 | Sardar Udham | 2021 | Shoojit Sircar | V. Kaushal | M001 |
+-------+----------------+------+----------------+------------+-------+

Table: Musician
+-------+-----------------+----------+--------+
| Mu_ID | Name1 | Name2 | Movies |
+-------+-----------------+----------+--------+
| M001 | Shantanu Moitra | NULL | 38 |
| M002 | Salim | Sulaiman | 49 |
| M003 | Vishal Mishra | NULL | 28 |
+-------+-----------------+----------+--------+
As a database expert, help Alisha to extract the following information by writing the
desired SQL queries as mentioned below.
(I) To display MID and the corresponding Musician details for the movies with MID
'MV001','MV002', and 'MV006'.
(II) To display MID, Title, and corresponding Name1 for each movie.
(III) To delete the records of all the movies released before 2015.
(IV) (A) To make MID the primary key of Movies table.
OR
(B) To remove the movies column from the Musician table.

35. A table, named Movies, in Cinema database, has the following structure: (4)
+----------+-------------+
| Field | Type |
+----------+-------------+
| MID | char(5) |
| Title | varchar(20) |
| Year | int(4) |
| Director | varchar(20) |
| Music | char(4) |
+----------+-------------+
Write the following Python function to perform the specified operation:

www.yogeshsir.com SQP3-6/8 www.youtube.com/LearnWithYK


SQP-3/XII/CS-083/2025/YK

AddAndDisplay(): To add a new column Actor of type varchar(15) to the table.


The function should then retrieve and display all records from
the Movies table.
Assume the following for Python-Database connectivity:
Host: 'localhost', User: 'Guest', Password: 'Cin-2025'

SECTION E (2 X 5 = 10 Marks)

36. Rashid owns a bags showroom. To keep record of the stock in his showroom, he wants to (5)
store all the relevant data in a file. He wants to store the data for each bag as a dictionary
in the following format:
{B_ID : [Brand, Type, Capacity, Price, Warranty]}
where
B_ID is the bag ID of integer type.
Brand is the brand name of string type.
Type describes the type of bag like Backpack, Laptop, Weekender etc.
Capacity is a float value specifying the capacity of the bag in litres.
Price is an integer specifying the price of the bag.
Warranty is an integer specifying the warranty duration (months) of the bag.

You, as a programmer of the company, have been assigned to do this job for Rajesh by
writing the following functions:
(I) Write a function to input the data of a bag and append it in a binary file
'Bags.dat'.
(II) Write a function to input a B_ID and display the corresponding record from
the file 'Bags.Dat'. If the record is not found, then the function should display
the message "Record Not Found".
(III) Write a function to read the data from the file display the average price of
the bags of type 'Laptop'.

37. RXports is an export house with its Head Office in Mumbai. RXports is setting up a new (5)
manufacturing unit in Kolkata, which is 1900km away from Mumbai. Kolkata unit will have
four blocks – Admin, Design, Production, and Packing.

Distance between various blocks, and Number of Computers in each block is given below:
From To Distance Block Computers
ADMIN Design 14 m Admin 10
ADMIN Production 10 m Design 15
ADMIN Packing 14 m Production 50
Design Production 10 m Packing 10
Design Packing 20 m
Production Packing 10 m

You, as a network expert, need to suggest the best network-related solutions for them to
set up the Computer Network in Kolkata Unit by answering the questions mentioned in
points (I) to (V), keeping in mind the distances between various blocks/buildings and other
given parameters.

www.yogeshsir.com SQP3-7/8 www.youtube.com/LearnWithYK


SQP-3/XII/CS-083/2025/YK

(I) Suggest the best cable to be used for the network for maximum speed of data
transfer.
(II) How many switches and how many routers should be procured?
(III) Draw a cable layout showing the interconnection of different blocks keeping in
mind that the server is placed in Admin block.
(IV) Which device should be used to ensure data security by preventing
unauthorized transfer of data?
(V) (A) Mention any one drawback of providing Internet access using Wi-Fi instead
of cabled connection?
OR
(B) Name the topology formed within each block.

www.yogeshsir.com SQP3-8/8 www.youtube.com/LearnWithYK


SQP-4/XII/CS-083/2025/YK

Sample Question Paper-4 (Theory)


Class: XII
Session: 2024-25
Computer Science (083)

Time allowed: 3 Hours Maximum Marks: 70

General Instructions:
• Please check this question paper contains 37 questions.
• The paper is divided into 5 Sections- A, B, C, D and E.
• Section A consists of 21 questions (1 to 21). Each question carries 1 Mark.
• Section B consists of 7 questions (22 to 28). Each question carries 2 Marks.
• Section C consists of 3 questions (29 to 31). Each question carries 3 Marks.
• Section D consists of 4 questions (32 to 35). Each question carries 4 Marks.
• Section E consists of 2 questions (36 to 37). Each question carries 5 Marks.
• All programming questions are to be answered using Python Language only.

Section-A (21 x 1 = 21 Marks)

1. State True or False: (1)


// (floor division) always returns an integer value.

2. If s="12 students" then which of the following expressions is True? (1)


(A) s.isalnum()
(B) s.isupper()
(C) s.isalpha()
(D) s.islower()

3. Evaluate the following expression: (1)


2 and '2' and not 0 or not ()

4. What will be the output of the following statement? (1)


print('entertainment'.index('e',3,11))
(A) 0
(B) 3
(C) 11
(D) Error

5. Which of the following statements will NOT create a tuple? (1)


(A) t=tuple()
(B) t=tuple(1,2,3)
(C) t=tuple('123')
(D) t=tuple([1,2,3])

6. What will be the output of the following code snippet? (1)


a= 'Apple and Pineapple'[-3:3:-3]+'*'
print(a)

7. If my_dict={1:10,2:20,3:30,4:40}then which of the following statements will raise (1)


an exception?
(A) my_dict.get('1')
(B) print(my_dict[1,2])
(C) my_dict['a']=20
(D) print(str(my_dict))

www.yogeshsir.com SQP4-1/8 www.youtube.com/LearnWithYK


SQP-4/XII/CS-083/2025/YK

8. If nums=['1','2','3'] then which of the following is invalid? (1)


(A) nums+'123'
(B) nums+='123'
(C) nums+[123]
(D) nums+=(1,2,3)

9. State whether the following statement is True or False: (1)


In a try..except..finally statement, finally block is always executed.

10. Which of the following function headers is invalid: (1)


(A) def f1():
(B) def f1(a,b):
(C) def f1(a=10,b):
(D) def f1(a,b=10):

11. Write the missing statement to complete the following code: (1)
file = open("sqp4.txt",'a')
_____________ #write the string "Easy" in the file.
file.close()

12. ___________ command adds a new row to a relation. (1)


(A) Append
(B) Insert
(C) Update
(D) Write

13. fetchall() is a (1)


(A) method of cursor object
(B) method of connection object
(C) function of mysql
(D) built-in function of Python

14. A table contains data of 30 students of a class. The table has 6 columns. The roll numbers (1)
of the students are integers from 101 to 130. What is the cardinality of this table?
(A) 6
(B) 30
(C) 101
(D) Set of integers from 101 to 130.

15. The cardinality of the natural join of two tables: (1)


(A) is equal to the sum of the degrees of the tables.
(B) is equal to the product of the degrees of the table.
(C) is equal to the sum of the cardinalities of the tables.
(D) Cannot be predicted without actual data.

16. Using ALTER TABLE command we cannot: (1)


(A) Add a new column to a table
(B) Delete a column from a table
(C) Add a new record to a table
(D) Update the data in a table

17. Which of the following statements is correct? (1)


(A) Radio waves travel in straight lines.
(B) Micro waves can penetrate obstacles.
(C) Infrared rays are used for short distance communication.
(D) Bluetooth uses infrared rays.

www.yogeshsir.com SQP4-2/8 www.youtube.com/LearnWithYK


SQP-4/XII/CS-083/2025/YK

18. The Ethernet cable connects the computer to the network through ___________. (1)
(A) Repeater
(B) Gateway
(C) NIC
(D) HTTP

19. Conversion of digital data into analogue signals is called: (1)


(A) Modulation
(B) Demodulation
(C) Modem
(D) Repeater

Questions 20 and 21 are Assertion (A) and Reasoning (R) based questions. Mark the correct choice as:
(A) Both A and R are true and R is the correct explanation for A
(B) Both A and R are true and R is not the correct explanation for A
(C) A is True but R is False
(D) A is False but R is True

20. Assertion (A): 'abc'*3 is a valid expression in Python. (1)


Reasoning (R): Only a string can be concatenated to a string.

21. Assertion (A): Adding a row to a table increases the cardinality of the table. (1)
Reasoning (R): Cardinality of a table is the number of rows in the table.

Section-B ( 7 x 2=14 Marks)

22. What is the difference between title() and capitalize() methods of string object? (2)
What will be the output of the following statement?
print("a bc dE-".title(), "a bc dE".capitalize())

23. Evaluate the following expressions: (2)


(i) -15%4+15%4 (ii) eval('3+3')*'3'

24. If D1={'a':'apple', 'b':'ball'} and D2={1:'a',2:'b',3:'c'} then do the (2)


following using built-in functions/methods only:
(I)
A) Display a list of all the keys of D1.
OR
B) Delete the last element of D2.
(II)
A) Add all the elements of D2 to D1.
OR
B) Append 4:'d' as a new key:value pair to D2.

25. Identify the correct possible output(s) of the following code. Also write the minimum and (2)
the maximum possible values of the variable x.
import random
for i in range(2,6):
a=random.randint(1,i)
x="printer"[a]
print(x,end='-')
(A) i-n-r-t- (B) n-r-i-r-
(C) r-t-i-n- (D) r-r-i-r-

26. The function provided below is intended to find and display the number of lowercase (2)
vowels in a given string (s). For example, if the s='An Aeroplane' then the function
should display 4 because the string contains four lowercase vowels. However, there are
syntax and logical errors in the code. Rewrite it after removing all the errors. Underline
all the corrections made.

www.yogeshsir.com SQP4-3/8 www.youtube.com/LearnWithYK


SQP-4/XII/CS-083/2025/YK

def countVowels(s)
c=0
for ch in range(s):
if 'aeiou' in ch:
c+=1
print('c')

27. (I) (2)


A) Write an SQL command to view the structure of a table Groups in the current
database.
OR
B) Two columns of a table have different names. Can these two columns have the
same domain?
(II)
A) Write an SQL statement to delete a column, named Age, from a table
Student.
OR
B) Write an SQL statement to view the cardinality of the natural join of table T1
and T2?

28. A) What is meant by bandwidth of a channel? What is the unit to measure bandwidth? (2)
OR
B) What is IP address? Give an example of version 4 IP address.

Section-C ( 3 x 3 = 9 Marks)

29. A) "Codes.txt" is a text file. write a Python function that (3)


(i) Displays a list of digits present in the file. No digit should be repeated in the
list.
(ii) Displays a tuple of uppercase consonants present in the file. No consonant
should be repeated in the tuple.
For example, if the text file contains:
A@12
ReYo-21
Yo1Ka2
B1f2V5
Bkm23Gkl
Then the function should display:
[1, 2, 5, 3]
('A', 'R', 'Y', 'K', 'B', 'V', 'G')
OR
B) Write a Python function that counts and displays each alternate line of a text file named
'Codes.txt'. For example, if the text file contains:
A@12
ReYo-21
Yo1Ka2
B1f2V5
Bkm23Gkl
Then the function should display:
A@12
Yo1Ka2
Bkm23Gkl

30. (A) A list contains following record of a student: (3)


[StudentName, AdmNo, Class, Section]

www.yogeshsir.com SQP4-4/8 www.youtube.com/LearnWithYK


SQP-4/XII/CS-083/2025/YK

Write the following user defined functions to perform given operations on the stack
named 'XIIB':
(i) pushStd() - To Push an object containing name and admission number of
students who belong to class 12 and section "B" to the stack
(ii) popStd() - To Pop the objects from the stack and display them. Also, display
"Stack Empty" when there are no more elements in the stack.
For example: If the lists of students details are:
["Rachit", "1122334455",11,"C"]
["Swarit", "2233445511",12, "B"]
["Aanchal","3344551122",10,"A"]
["Yogita", "4455112233",12,"B"]
Then the stack "XIIB" should contain"
["Swarit", "2233445511"]
["Yogita", "4455112233"]
And the output should be:
["Yogita", "4455112233"]
["Swarit", "2233445511"]
Stack Empty
OR
(B) Write a function Push(Classes) in Python, where Classes is a dictionary
containing the number of students in different classes (Class:Strength) of a school
as key:value pairs.
The function should push those Classes in the stack which have strength more than
25. Also display the count of elements pushed into the stack.
For example, if the dictionary contains the following data:
Classes={"12A":28, "12B":30, "12C":23, "11A":22, "11B":27,
"11C":25}
Then the stack should contain "12A", "12B", "11B"
And the output should be: The count of elements in the stack is 3

31. A) Predict the output of the following code: (3)


a=5
def f1(b):
global a
b.sort(reverse=True)
for i in range(len(b)):
if b[i]>100:
b[i]=b[i]%10*b[i]//10
else:
a,b[i]=b[i],a
n=[215,23,312,213,19]
f1(n)
print(n,a)
OR
B) Predict the output of the following code:
def f1(a,b=8,c=13):
a%=b+c
b//=c//a
c=a+b
print(a,b,c)
f1(6)
f1(3,7)

www.yogeshsir.com SQP4-5/8 www.youtube.com/LearnWithYK


SQP-4/XII/CS-083/2025/YK

SECTION D (4 X 4 = 16 Marks)

32. Based on the table Teachers, as given below, answer part A to write the queries OR part (4)
B to write the output of the given queries.
Table: Teachers
+-------+------------+-------+---------+------+------------+------+
| TCode | Name | Desig | SubCode | Age | DOJ | Exp |
+-------+------------+-------+---------+------+------------+------+
| PR101 | Rashmi | PRT | 041 | 28 | 2020-10-10 | 5 |
| PR102 | Bharat | PRT | 041 | 30 | 2020-12-10 | 7 |
| PG008 | Charu | PGT | 043 | 38 | 2022-12-10 | 13 |
| PG010 | Damanpreet | PGT | 042 | 33 | 2022-12-11 | 8 |
| TG010 | Rajesh | TGT | 083 | 44 | 2021-12-12 | 19 |
| TG012 | Asim | TGT | 803 | 40 | 2021-12-12 | 15 |
| PR012 | David | PRT | 042 | 38 | 2019-12-01 | 15 |
+-------+------------+-------+---------+------+------------+------+
A)
I. To increase the age and experience of all teachers by 1.
II. To display the details of all teachers whose subject is '042' and they joined in
the year 2022.
III. To display the minimum age and maximum age of teachers Desig wise.
IV. To display the Name, Age, and SubCode of all the PGTs whose experience is
more than 10.
OR
B)
I. select Name, Exp+2 Exp from teachers order by exp;
II. select count(*) from teachers where desig in ('PGT','TGT');
III. select subcode, count(*) from teachers group by subcode;
IV. select min(doj), max(doj) from teachers;

33. A csv file "Classes.csv" contains the records of different classes in a school. Each record (4)
of the file contains the following data:
• Class (An integer from 1 to 12)
• Section (A single character string)
• Strength (Number of students in the class)
• CT (Name of the Class Teacher)
For example, a sample record of the file may be:
[12, 'B', 30, 'Prasanth K']
Write the following Python functions to perform the specified operations on this file:
(I) Append a record to the file. Data should be input from the user.
(II) Find and display the average number of students in class 12.

34. Ms. Sadhana is a Principal of a school and assume that you are working as a Database (4)
Administrator (DBA) in the school. You have created two tables - Classes and Teachers.
Classes stores the details of the class and Teachers stores the details of the teachers in
the school. Sample data from both these tables is given below:
Table: Classes
+-------+-----+----------+--------+--------+
| Class | Sec | Strength | CTCode | ATCode |
+-------+-----+----------+--------+--------+
| 1 | A | 25 | PR023 | PR005 |
| 1 | B | 23 | PR024 | PR005 |
| 1 | C | 25 | PR012 | PR013 |
| 2 | A | 21 | PR015 | PR013 |
| 2 | B | 23 | PR018 | PR009 |
| 3 | A | 27 | PR019 | PR009 |
+-------+-----+----------+--------+--------+

www.yogeshsir.com SQP4-6/8 www.youtube.com/LearnWithYK


SQP-4/XII/CS-083/2025/YK

(Note: Here CTCode is the TCode of the Class Teacher, and ATCode is the TCode of
the Associate Teacher of the class. TCodes are given in the Teachers table.)

Table: Teachers
+-------+----------+------+------------+------+
| TCode | Name | Age | DOJ | Exp |
+-------+----------+------+------------+------+
| PR001 | Prathama | 34 | 2020-07-12 | 10 |
| PR013 | Rashmi | 43 | 2021-07-10 | 18 |
| PR009 | Nazia | 38 | 2020-03-17 | 12 |
+-------+----------+------+------------+------+
Help the Principal to extract the following information by writing the desired SQL queries
as mentioned below.
(I) To display Name, Class, and Section for each Associate Teacher (ATCode)
(II) To display the TCode, Name, and DOJ of each class teacher.
(III) To display the average strength of each class.
(IV) (A) To make Class+Sec the primary key of Classes table.
OR
(B) To add DOB column of type Date in the Teachers table.

35. A table, named Classes, in School database, has the following structure: (4)
+----------+---------+
| Field | Type |
+----------+---------+
| Class | int |
| Sec | char(1) |
| Strength | int |
| CTCode | char(5) |
| ATCode | char(5) |
+----------+---------+
Write the following Python function to perform the specified operation:
AddAndDisplay(): To add a new record with any suitable values in the table. The
function should then retrieve and display all those records
from the table where strength is less than 20.
Assume the following for Python-Database connectivity:
Host: 'localhost', User: 'Guest', Password: 'Sch-JkP'

SECTION E (2 X 5 = 10 Marks)

36. A binary file 'Schools.Dat' stores the information about some schools in a city. Each record (5)
of the file is in the following format:
{Aff_No : [Name, Level, Strength, Principal, WebSite]}
where
Aff_No is the Affiliation Number of the school (integer type)
Name is the name of the school.
Level is the school level ('Primary', 'Middle', 'Sec', or ''Sr. Sec' )
Strength is the number of students studying in the school.
Principal is the name of the Principal.
WebSite is the school's website.
For example, a record in the file might be:
{52814:['YRPS', 'Middle', 2000, 'R Madaan', 'yrps.edu']}

Write the following functions with reference to this file:


(I) A function to input the data of a school and append it to the file.

www.yogeshsir.com SQP4-7/8 www.youtube.com/LearnWithYK


SQP-4/XII/CS-083/2025/YK

(II) A function to input an Aff_No and delete the corresponding record from the
file. If the record is not found, then the function should display the message
"Record Not Found".
(III) A function to read the data from the file display the records of all the 'Sec'
level schools.

37. A new school 'Proton High School' is being set up. The management of the school plans to (5)
build three computer labs – Primary, Middle, and Senior with 30 computers in each lab.
The Administrative Block will have 15 computers. There will also be 5 computers in the
Activity Block of the school.

Limited access to the Internet (Blocking a number of unwanted websites) will be given in
each lab and in Activity Block. You, as a network consultant, have to help the management
in setting up the Computer Network in the school by answering the following questions,
keeping in mind the distances between various blocks/labs/buildings and other given
parameters.
From To Distance
Administrative Block Primary Lab 50 m
Administrative Block Middle Lab 60 m
Administrative Block Senior Lab 70 m
Administrative Block Activity Block 100 m
Primary Lab Middle Lab 30 m
Primary Lab Senior Lab 30 m
Primary Lab Activity Block 70m
Middle Lab Senior Lab 30m
Middle Lab Activity Block 70m
Senior Lab Activity Block 60m

(I) Suggest the best cable to be used for the network for maximum speed of data
transfer.
(II) Which device will you suggest, that should be placed in each of these Labs,
Administrative Block, and Activity Block, to efficiently connect all the
computers within these blocks/labs?
(III) Draw a cable layout showing the interconnection of different blocks keeping in
mind that the server is placed in Administrative Block.
(IV) Which device should be used to block the access to unwanted websites?
(V) (A) Is the repeater needed in this network setup? Justify your answer.
OR
(B) Name the topology formed within each lab.

www.yogeshsir.com SQP4-8/8 www.youtube.com/LearnWithYK


SQP-5/XII/CS-083/2025/YK

Sample Question Paper-5 (Theory)


Class: XII
Session: 2024-25
Computer Science (083)

Time allowed: 3 Hours Maximum Marks: 70

General Instructions:
• Please check this question paper contains 37 questions.
• The paper is divided into 5 Sections- A, B, C, D and E.
• Section A consists of 21 questions (1 to 21). Each question carries 1 Mark.
• Section B consists of 7 questions (22 to 28). Each question carries 2 Marks.
• Section C consists of 3 questions (29 to 31). Each question carries 3 Marks.
• Section D consists of 4 questions (32 to 35). Each question carries 4 Marks.
• Section E consists of 2 questions (36 to 37). Each question carries 5 Marks.
• All programming questions are to be answered using Python Language only.

Section-A (21 x 1 = 21 Marks)

1. State True or False: (1)


eval(3+2) is an invalid expression in Python.

2. If s="Co\n\tainer" then what is the length of s? (1)


(A) 13
(B) 11
(C) 10
(D) 9

3. Evaluate the following expression: (1)


2 and not 2 or not 0 and '0'

4. What will be the output of the following statement? (1)


print('entertainment'.index('e',3,11))
(A) 0
(B) 3
(C) 11
(D) Error

5. Which of the following statements will NOT create a tuple? (1)


(A) t=tuple()
(B) t=tuple(1,2,3)
(C) t=tuple('123')
(D) t=tuple([1,2,3])

6. If a= 'Apple and Pineapple' then which of the following statements will display an (1)
empty string?
(A) print(a[2:3:3])
(B) print(a[-3:3:-1])
(C) print(a[3:-3:-1])
(D) print(a[:5:5])

7. None will be output of the following code segment? (1)


my_dict={1:10,2:20,3:30,4:40}
my_dict.setdefault(5)
print(my_dict.setdefault(5,10))

www.yogeshsir.com SQP5-1/8 www.youtube.com/LearnWithYK


SQP-5/XII/CS-083/2025/YK

8. If nums=['1','2','3'] then which of the following statements will raise an error? (1)
(A) nums[1]==2
(B) nums[2].isupper()
(C) nums[3]='4'
(D) nums=123

9. State whether the following statement is True or False: (1)


In a try..except..finally statement, we can write multiple finally
blocks.

10. Write the output of the following code snippet. (1)


a='Expected'
a=[i for i in a[1:-1]]
print(a)

11. Write the missing statement to complete the following code: (1)
file = open("sqp4.txt", __) #open the file in suitable mode
file.read(20)
file.close()

12. Number of records in a relation is called its____________. (1)


(A) Degree
(B) Cardinality
(C) Length
(D) Domain

13. commit() is a (1)


(A) method of cursor object
(B) method of connection object
(C) function of mysql
(D) built-in function of Python

14. Domain of a column of a table is a: (1)


(A) set
(B) table
(C) record
(D) primary key

15. The domain of a Foreign key is: (1)


(A) same as the domain of any other column of the table.
(B) same as the domain of the Primary key to which it refers.
(C) same as the domain of the Foreign key of any other table of the database.
(D) always an integer.

16. Identify a DDL command from the following: (1)


(A) Create
(B) Delete
(C) Update
(D) Desc

17. Identify the invalid IPv4 Address from the following: (1)
(A) 1.2.3.4
(B) 255.255.255.0
(C) 198.302.192.1
(D) 60.60.60.60

www.yogeshsir.com SQP5-2/8 www.youtube.com/LearnWithYK


SQP-5/XII/CS-083/2025/YK

18. The acronym WWW expands to: (1)


(A) World With Web
(B) Word Wise Web
(C) World Wide Web
(D) World Web Workstation

19. Conversion of analogue signals into digital data is called: (1)


(A) Modulation
(B) Demodulation
(C) Modem
(D) Repeater

Questions 20 and 21 are Assertion (A) and Reasoning (R) based questions. Mark the correct choice as:
(A) Both A and R are true and R is the correct explanation for A
(B) Both A and R are true and R is not the correct explanation for A
(C) A is True but R is False
(D) A is False but R is True

20. Assertion (A): If f1.read(20) is a valid statement in Python, then f1 cannot be a binary (1)
file object.
Reasoning (R): read() method is not valid for binary files.

21. Assertion (A): We cannot use WHERE clause instead of HAVING clause with GROUP BY (1)
clause.
Reasoning (R): WHERE clause is used to apply conditions on individual rows, whereas
HAVING clause is used to apply conditions on groups.

Section-B ( 7 x 2=14 Marks)

22. (I) Name two functions of the random module which always generate integers. (2)
(II) Name two functions of the random module which always generate floating point
numbers.

23. Evaluate the following expressions: (2)


(i) int(-15/4)+(-15//4) (ii) eval('3+3')*3+3

24. If S1="Applied" and S2="Mathematics" then do the following using built-in (2)
functions/methods only:
(I)
A) Display S1 in uppercase.
OR
B) Display S2 in lowercase.
(II)
A) Display the number of times 'a' appears in S2.
OR
B) create a sorted list of the characters of S1. Name the list as LS1.

25. Identify the correct possible output(s) of the following code. Also write the minimum and (2)
the maximum possible values of the variable a.
T=(15,48,32,49,65,36)
for i in range(1,5):
a=random.randrange(i)+2
print(T[a],end='-')
(A) 49-32-49-65- (B) 32-32-49-65-
(C) 32-32-49-49- (D) 32-65-49-65-

26. The function provided below is intended to find and return the sum of all the even factors (2)
of an integer (n). For example, if the n=18 then the function should display 26

www.yogeshsir.com SQP5-3/8 www.youtube.com/LearnWithYK


SQP-5/XII/CS-083/2025/YK

(2+6+18) because 2, 6, and 18 are the even factors of 18. However, there are syntax
and logical errors in the code. Rewrite it after removing all the errors. Underline all the
corrections made.
def f1(n):
s=0
for i in range(n+1)
if i%2==0 and n%i:
s+=i
return i

27. If a table 'Teachers' stores the data of 50 teachers of a school. The table has the following (2)
structure:
+---------+-------------+
| Field | Type |
+---------+-------------+
| TCode | char(5) |
| Name | varchar(15) |
| Desig | char(5) |
| SubCode | char(3) |
| Age | int(2) |
| DOJ | date |
| Exp | int(2) |
| Dob | date |
+---------+-------------+
Minimum valid Age is 23 and maximum valid Age is 60.
Desig (Designation) of a teacher can be 'PRT', 'TGT', or 'PGT'

Based on this information, answer the following questions:


(I)
A) What is the degree of the table?
OR
B) What is the Cardinality of the table?
(II)
A) What is the domain of Age column?.
OR
B) What is the domain of Desig column?

28. A) Give one suitable example of each – URL and Domain Name. (2)
OR
B) Write any two differences between PAN and LAN types of networks.

Section-C ( 3 x 3 = 9 Marks)

29. A) "TV.txt" is a text file. write a Python function that counts and displays (3)
(i) Number of capital alphabets appearing in the file.
(ii) Number of 5 letter words appearing in the file.
(iii) Number of lines with at least 5 words appearing in the file.
OR
B) Write a Python function that reads a text file 'TV.txt', and displays the first and the last
letter appearing in each line of the file. s:
Television (TV) is an effective medium for communication.
Television is a vast medium of entertainment, information,
and education of the modern age. Television was invented
in 1925 by John Logie Baird.
Television enables children to learn moral lessons in a fun
way with special channels and programs meant for children.

www.yogeshsir.com SQP5-4/8 www.youtube.com/LearnWithYK


SQP-5/XII/CS-083/2025/YK

Then the function should display:


T n
T n
a d
i d
T n
w n
Note: Trailing comma or dot should not be considered a letter of the word.

30. (A) A list contains following record of a TV: (3)


[Brand, Size, Type, Price]
Write the following user defined functions to perform given operations on the stack
named 'OLED':
(i) pushTV() - To Push an object containing Brand, Size, and Price of TVs of type
'OLED'
(ii) popTV() - To Pop the objects from the stack and display them. Also, display
"Stack Empty" when there are no more elements in the stack.
For example: If the lists of students details are:
["SONY", 50,"FHD", 30500]
["LG", 60, "OLED", 41000]
["Samsung", 55, "4K", 38000]
["SONY", 60, "OLED", 50000]
Then the stack "OLED" should contain"
["LG", 60, 41000]
["SONY", 60, 50000]
And the output should be:
["SONY", 60, 50000]
["LG", 60, 41000]
Stack Empty
OR
(B) Assume that TV is a given string, and S1 is a stack.
(i) Write a function Push(S1,TV) in Python. The function should push all the
digits, appearing in the string TV, into the stack S1. Also display the sum of
the digits pushed into the stack.
(ii) Write a function Pop(S1) which pops all the elements from the stack S1 and
displays them. At the end the function should display the message "All Popped".
For example, if the string TV contains the following text:
"""TV was invented in 1925 by John Logie Baird.
Television came to India in 1959."""
Then the function Push(S1,TV) should push '1', '9', '2', '5', '1', '9',
'5', '9' in the stack S1.
And the output should be: Sum of digits pushed = 41

Output of the function Pop(S1) should be: 9 5 9 1 5 2 9 1 All Popped

31. A) Predict the output of the following code: (3)


def f1(x):
global a
a//=x
if x%3>1:
a*=x
else: x*=a
x//=2
print(a,x)
return(a,x)

www.yogeshsir.com SQP5-5/8 www.youtube.com/LearnWithYK


SQP-5/XII/CS-083/2025/YK

a,b=5,7
a,b=f1(a)
b,a=f1(b)
print(a,b)
OR
B) Predict the output of the following code:
def f1(x,y=5):
global a,b
a//=x
if b%3>1:
a+=x+y
else: a-=x-y
print(a,x)
return(a,x)
a,b=15,17
a,b=f1(a)
b,a=f1(b,a)
print(a,b)

SECTION D (4 X 4 = 16 Marks)

32. Based on the table TV, as given below, answer part A to write the queries OR part B to (4)
write the output of the given queries.
Table: TV
+---------+----------+------+---------+------------+-------+
| Brand | Model | Size | Display | Resolution | Price |
+---------+----------+------+---------+------------+-------+
| Sony | Bravia | 55 | LED | 4K | 59000 |
| Sony | Bravia 2 | 43 | LED | 4K | 39000 |
| Acer | GTV | 43 | QLED | 4K | 26000 |
| Acer | Pro | 50 | QLED | NULL | 27000 |
| LG | Pro | 32 | LED | 720p | 14000 |
| Samsung | Crystal | 65 | OLED | UHD | 68000 |
+---------+----------+------+---------+------------+-------+
A)
I. To decrease the price of Sony TVs by 5%.
II. To display the details of all TVs with 4K resolution.
III. To display the Brand and the corresponding number of records for each Brand.
IV. To delete all the records where Resolution is NULL.
OR
B)
I. select Brand, Size from TV where price<30000;
II. select Brand, Size, Price from TV
where resolution != '4K' order by price desc;
III. select avg(price) from TV where display='LED';
IV. select Model, Size, Display from TV
where Brand in ('Sony','Samsung');

33. A csv file "TV.csv" contains the records of different TVs in an electronics shop. Each record (4)
of the file contains the following data:
• Brand (string type)
• Model (string type)
• Size (integer type)
• Price (float type)
For example, a sample record of the file may be:
['SONY', 'Bravia', 55, 59000]

www.yogeshsir.com SQP5-6/8 www.youtube.com/LearnWithYK


SQP-5/XII/CS-083/2025/YK

Write the following Python functions to perform the specified operations on this file:
(I) Append a record to the file. Data should be input from the user.
(II) Display all the records where Price<30000.

34. Sonia is a marketing manager in an electronics showroom. She has created two tables - (4)
TV and Bills. TV stores the details of the TVs in the showroom and Bills stores the details
of the bills of TVs sold. Sample data from both these tables is given below:
Table: TV
+------+---------+----------+------+---------+------------+-------+
| T_ID | Brand | Model | Size | Display | Resolution | Price |
+------+---------+----------+------+---------+------------+-------+
| 1 | Sony | Bravia | 55 | LED | 4K | 59000 |
| 2 | Sony | Bravia 2 | 43 | LED | 4K | 39000 |
| 3 | Acer | GTV | 43 | QLED | 4K | 26000 |
| 4 | Acer | Pro | 50 | QLED | NULL | 27000 |
| 5 | LG | Pro | 32 | LED | 720p | 14000 |
| 6 | Samsung | Crystal | 65 | OLED | UHD | 68000 |
+------+---------+----------+------+---------+------------+-------+

Table: Bills
+---------+------------+------+----------+
| BNo | BDate | T_ID | Discount |
+---------+------------+------+----------+
| 2024195 | 2024-12-15 | 2 | 0.05 |
| 2024196 | 2024-12-15 | 6 | 0 |
| 2024213 | 2024-12-26 | 1 | 0.1 |
| 2025006 | 2025-01-07 | 2 | 0.05 |
| 2025019 | 2025-01-11 | 1 | 0.07 |
+---------+------------+------+----------+
As a database expert you have to help Sonia to extract the following information by
writing the desired SQL queries as mentioned below.
(I) To display the details of all the TVs sold in 2024.
(II) To display the Bill details corresponding to TVs of brand 'Sony'.
(III) To display the Bill Number (BNo) and T_ID of all the TVs of size less than 50.
(IV) (A) To make T_ID the primary key of TV table.
OR
(B) To add Cust column of type int in the Bills table.

35. A table, named TV, in SSA database, has the following structure: (4)
+------------+-------------+
| Field | Type |
+------------+-------------+
| T_ID | int(11) |
| Brand | varchar(15) |
| Model | varchar(10) |
| Size | int(3) |
+------------+-------------+
Write the following Python function to perform the specified operation:
AlterAndDisplay(): To add a new column Price of type float in the table.
The function should then retrieve and display all those records
from the table where size is not equal to 50.
Assume the following for Python-Database connectivity:
Host: 'localhost', User: 'Guest', Password: 'Sd@SSA'

SECTION E (2 X 5 = 10 Marks)

36. A binary file 'TV.Dat' stores the information about some TVs in in an electronics shop. (5)
Each record of the file is a list in the following format:
[T_ID, Brand, Model, Size, Price]

www.yogeshsir.com SQP5-7/8 www.youtube.com/LearnWithYK


SQP-5/XII/CS-083/2025/YK

where
T_ID is the TV’s identification number (integer type)
Brand is the Brand Name (Like ‘Sony’, ‘Samsung’, ‘LG’ etc.)
Model is the Model Name of the TV (string type)
Size is the Screen Size (integer type)
Price is the price of the TV (integer type)
For example, a record in the file might be:
[1, 'Sony', 'Bravia', 55, 59000]
Write the following functions with reference to this file:
(I) A function to input the data of a TV and append it to the file.
(II) A function to increase the price of Samsung brand TVs by 10%.
(III) A function to read the data from the file display all those records where Price
is more than 50000.

37. Impact Edu Care Ltd. is an educational organization with its Head Office in Delhi. It is (5)
planning to setup a new Campus in Pathankot (in India). The Pathankot campus will have
4 main buildings – ADMIN, ENGINEERING, BUSINESS and MEDIA.

Shortest distances between various buildings is:


ADMIN to ENGINEERING 55 m
ADMIN to BUSINESS 90 m
ADMIN to MEDIA 50 m
ENGINEERING to BUSINESS 55 m
ENGINEERING to MEDIA 50 m
BUSINESS to MEDIA 45 m
DELHI Head Office to Pathankot Campus 510 km

Number of Computers installed at various buildings are as follows:


ADMIN 110
ENGINEERING 75
BUSINESS 40
MEDIA 12
DELHI Head Office 20

(I) Suggest the most appropriate location of the server inside the PATHANKOT campus
(out of the 4 buildings), to get the best connectivity for maximum no. of
computers. Justify your answer.
(II) Suggest and draw the cable layout to efficiently connect various buildings within
the PATHANKOT campus for connecting the computers.
(III) Which hardware device will you suggest to be procured by the company to be
installed to protect and control the internet access within the campus?
(IV) Which of the following will you suggest to establish the online face-to-face
communication between the people in the Admin Office of PATHANKOT campus
and DELHI Head Office?
(i) Cable TV (ii) Email (iii) Video Conferencing (iv) Text Chat
(V) (A) Is there a requirement of switch(es)? Justify your answer.
OR
(B) Is there a requirement of router(s)? Justify your answer.

www.yogeshsir.com SQP5-8/8 www.youtube.com/LearnWithYK


AnsKey/SQP-1/XII/CS-083/2025/YK

Answer Key
Sample Question Paper-1 (Theory)
Class: XII
Session: 2024-25
Computer Science (083)

Section-A (21 x 1 = 21 Marks)

1. True (1)

2. (A) Insaaanaa*aaea (1)

3. (C) 2>4 and 4>2 (1)

4. (A) ['Mis', 's', 'ppi'] (1)

5. (C) 6 (1)

6. sisp (1)

7. (A) gold.fromkeys('gold') (1)

8. (A) Removes all the elements from the list (1)

9. False (1)

10. (C) 25#15% (1)

11. file.seek(20) (1)

12. Cardinality of the table increases by 5. (1)

13. ALTER (OR ALTER TABLE) (1)

14. (B) Unrepeated values from the House column of table Students. (1)

15. (A) DATA (1)

16. (D) All of these (1)

17. (C) PPP (1)

18. (D) Repeater (1)

19. Star (1)

20. (C) A is True but R is False (1)

21. (A) Both A and R are true and R is the correct explanation for A. (1)

Section-B ( 7 x 2=14 Marks)

22. in operator is used to check whether an object is a member of an iterable. For example, (2)
1 in [1,2,3] will return True because 1 is an element of the list [1,2,3]. 4 in
[1,2,3] will return False because 4 is not an element of the list [1,2,3]

23. Arithmetic Operators: +, -, /, * (Any two) (2)


Logical Operators: and, or, not (Any two)

www.yogeshsir.com AK1-1/5 www.youtube.com/LearnWithYK


AnsKey/SQP-1/XII/CS-083/2025/YK

24. (I) (2)


A) L1.append(L2)
OR
B) L1.insert(2,L2)

(II)
A) L3=L1.copy()
OR
B) L2.pop().

25. Possible outputs: (C) and (D) (2)


Minimum possible value of Pass = 1
Maximum possible value of Pass = 6

26. def sumFact(n): (2)


s=0
for i in range(1,n+1):
if n%i==0:
s+=i
return s

27. (I) (2)


A) Email_ID column in Employee table.
OR
B) Name column in Employee table.
(II)
A) Alter table DomesticHelp drop Primary key;
OR
B) Alter table DomesticHelp Add Primary key H_ID;

28. A) (2)
Advantages:
Penetration: They can penetrate through walls and obstacles, providing better
coverage in buildings and urban areas.
Disadvantages:
Interference: Radio waves are susceptible to electromagnetic interference from
other electronic devices, which can affect the quality of the signal.
OR
B) XML – Extensible Markup Language.
XML is used to define and store data in a shareable manner.

Section-C ( 3 x 3 = 9 Marks)

29. A) (3)
def vow_Words():
f=open("DomHelp.txt")
data=f.read()
words=data.split()
for word in words:
if word[0] in 'aeiou':
print(word,end=' ')
f.close()

OR

www.yogeshsir.com AK1-2/5 www.youtube.com/LearnWithYK


AnsKey/SQP-1/XII/CS-083/2025/YK

B)
def countVow():
f=open("DomHelp.txt")
data=f.read()
c=0
for ch in data:
if ch in 'aeiou':
c+=1
print(c,'lowercase vowels in the file')
f.close()

30. (A) (3)


def push_help(HelpStack, new_Help):
HelpStack.append(new_Help)
def pop_Help(HelpStack):
if HelpStack:
return HelpStack.pop()
else: print("Underflow")
def peep(Helptack):
if HelpStack:
print(helpStack[-1])
else: print("None")
OR
(B)
stack=[]
n=int(input("Enter a positive integer: "))
while n:
d=n%10
n//=10
stack.append(d)
while stack:
print(stack.pop(), end=' ')
print("Empty Stack")

31. A) {'One': 3, 'Two': 3, 'Four': 4, 'Five': 4} (3)


{3: 'Two', 4: 'Five'}
OR
B) 0-4-7-7-0-7-

SECTION D (4 X 4 = 16 Marks)

32. A) (4)
I. Select * from Dhelp order by Code;
II. Select Mobile from Dhelp where Gender='M' and age<30;
III. Select max(age), min(age) from dhelp;
IV. Select name from Dhelp where mobile is null;
OR
B)
I.
+--------+----------+
| gender | avg(age) |
+--------+----------+
| F | 30.5 |
| M | 30.0 |
+--------+----------+

www.yogeshsir.com AK1-3/5 www.youtube.com/LearnWithYK


AnsKey/SQP-1/XII/CS-083/2025/YK

II. +------+--------+
| Code | Name |
+------+--------+
| 8 | Chris |
| 4 | Sania |
| 6 | Ashish |
| 5 | Xavier |
+------+--------+
III. +------+--------+------+
| Code | Name | Age |
+------+--------+------+
| 2 | Basil | 28 |
| 8 | Chris | 32 |
| 6 | Ashish | 32 |
| 5 | Xavier | 28 |
+------+--------+------+
IV. +------------+
| count(age) |
+------------+
| 6 |
+------------+

33. (I) def displayRec(): (4)


import csv
with open("DomHelp.CSV") as f:
r=csv.reader(f)
for rec in r:
hourly=int(rec[4])/int(rec[3])
if hourly<100:
print(rec)
(II) def countRec():
import csv
with open("DomHelp.CSV") as f:
r=csv.reader(f)
data=list(r)
print("Number of records =",len(data))

34. (I) select name, mobile from dhelp,contract where Code=HCode and (4)
salary>11000;
(II) select contract.*, name from dhelp, contract
where Code=HCode and duration between 10 and 12;
(III) update contract set salary=salary+10/100*salary;
(IV) (A) select name, gender from dhelp, contract
where Code=HCode and startdate like '%-12-%';
OR
(B) alter table dhelp add primary key(code);

35. def UpdateAndDisplay(): (4)


import mysql.connector as cnctr
conn=cnctr.connect(host='localhost', user='root',
password='Help@DS', database='DomServices')
crsr=conn.cursor()
qry='update dhelp set age=age+1'
crsr.execute(qry)
conn.commit()
qry='select * from dhelp where gender="M"'
crsr.execute(qry)
for rec in crsr:
print(rec)

www.yogeshsir.com AK1-4/5 www.youtube.com/LearnWithYK


AnsKey/SQP-1/XII/CS-083/2025/YK

SECTION E (2 X 5 = 10 Marks)

36. (I) def append(): (5)


import pickle
with open('Sales.Dat','ab') as f:
sid=int(input("Enter S_ID: "))
sname=input("Enter S_Name: ")
exp=float(input("Enter experience: "))
rate=int(input("Enter S_Rating: "))
rec=[sid,sname,exp,rate]
pickle.dump(rec,f)
(II) def search():
import pickle
ID=int(input("Enter S_ID: "))
found=0
with open('Sales.Dat','rb') as f:
try:
while True:
rec=pickle.load(f)
if rec[0]==ID:
print(rec)
found=1
break
except:
if found==0:
print("Record Not Found")
(III) def display():
import pickle
with open('Sales.Dat','rb') as f:
try:
while True:
rec=pickle.load(f)
if rec[-1]>4:
print(rec)
except:
pass

37. (I) BackEnd as it has the maximum number of computers. (5)


(II) Switch
(III)

Cable: Fiber Optic cable


(IV) No, as the distance between any two connected blocks is just a few meters and
fiber optic cable can carry data upto many kilometers without any signal
deterioration.
(V) (A) b) Microwave
OR
(B) LAN

www.yogeshsir.com AK1-5/5 www.youtube.com/LearnWithYK


AnsKey/SQP-2/XII/CS-083/2025/YK

Answer Key
Sample Question Paper-2 (Theory)
Class: XII
Session: 2024-25
Computer Science (083)

Section-A (21 x 1 = 21 Marks)

1. False (1)

2. (D) False (1)

3. (C) 2 and 3<1 or 3 and not 2<1 (1)

4. (D) ('E', 'n', 'tertainment') (1)

5. (C) 1 3 (1)

6. [2, 4, 6, 8] (1)

7. (B) book.setdefault(1) (1)

8. (C) str (1)

9. False (1)

10. (A) 4-4+ (1)

11. file.read(50) (1)

12. No change in the degree or cardinality of the table. (1)

13. ALTER (or ALTER TABLE) (1)

14. (A) Number of non null values in the House column. (1)

15. (C) '2024-12-21' (1)

16. (B) count() (1)

17. (B) FTP (1)

18. (D) Router (1)

19. Bus (1)

20. (D) A is false but R is true (1)

21. (D) A is false but R is true (1)

Section-B ( 7 x 2=14 Marks)

22. Example of a Boolean expression: 2>3 (2)


Possible values of a Boolean expression are True and False.

23. (i) 42.5 (2)


(ii) 2

24. (I) A) print(S2.upper()) (2)


OR
B) list(S1)

www.yogeshsir.com AK2-1/6 www.youtube.com/LearnWithYK


AnsKey/SQP-2/XII/CS-083/2025/YK

(II) A) print(S1.count('m'))
OR
B) print('-'.join(S1))

25. Correct possible output(s): (A) 1-2-1-0- and (B) 3-3-2-6- (2)
Minimum possible values of Pos is 3
Maximum possible values of Pos is 6

26. def sumDigits(n): (2)


s=0
while n!=0:
d=n%10
s+=d
n//=10
return s

27. (I) (2)


A) (i) It cannot accept duplicate values
(ii) It cannot accept NULL values
OR
B) A primary key containing multiple columns is called a composite primary key.
(II)
A) Alter table Juice drop column Sugar;
OR
B) Alter table Juice add column Sugar char(1);

28. A) Advantage: (2)


High Bandwidth: Microwaves offer higher bandwidth compared to other unguided
media, allowing for faster data transmission.
Disadvantages:
Line of Sight: Microwaves require a clear line of sight between the transmitter
and receiver, which can be obstructed by physical objects.
OR
B) HTML – Hypertext Markup Language
HTML is used to create and design web pages.

Section-C ( 3 x 3 = 9 Marks)
29. A) def vowelLines(): (3)
f=open("Juice.txt")
for line in f:
line=line[:-1] #to remove '\n' from the line
if line[-1] in 'aeiou':
print(line)
f.close()
OR
B)
def fiveLetterWords():
f=open("Juices.txt")
data=f.read()
words=data.split()
for w in words:
if len(w)==5:
print(w,end=' ')
f.close()
30. (A) (3)
def push_Juice(Juices, new_Juice):
Juices.append(new_Juice)
def pop_Juice(Juices):
if Juices:

www.yogeshsir.com AK2-2/6 www.youtube.com/LearnWithYK


AnsKey/SQP-2/XII/CS-083/2025/YK

return Juices.pop()
else: print("Underflow")
def peep(Juicetack):
if Juices:
print(Juices[-1])
else: print("None")
OR
(B)
import random
nums=[random.randint(10,99) for i in range(20)];
print(nums)
stack=[]
for n in nums:
if n%5==0:
stack.append(n)
while stack:
print(stack.pop(), end=' ')
print("Empty Stack")
31. A) {'T': 3, 'i': 1, 'c': 2, '-': 2, 'a': 1, 'o': 1, 'e': 1} (3)
OR
B) 3-5-3-5-3-1-

SECTION D (4 X 4 = 16 Marks)

32. Based on the table Drinks, as given below, answer part A to write the queries OR part B (4)
to write the output of the given queries.
Table: Drinks
+-------+------+-------+------------+
| Name | Size | Price | Remarks |
+-------+------+-------+------------+
| Apple | S | 0.75 | Apple Only |
| Apple | M | 1 | Apple Only |
| Apple | L | 1.5 | Apple Only |
| Mango | L | 2 | Shake |
| Mango | M | 1.5 | Shake |
| Mango | S | 0.75 | Mango Only |
+-------+------+-------+------------+
A)
I. select Name, avg(Price) from Drinks group by Name;
II. select * from Drinks where remarks='Shake';
III. select count(*) from Drinks where remarks like '%Only%';
IV. select * from Drinks where Price<1;
OR
B)
I. +-------+-------+
| name | price |
+-------+-------+
| Apple | 0.75 |
| Apple | 1 |
| Mango | 1.5 |
| Mango | 0.75 |
+-------+-------+

www.yogeshsir.com AK2-3/6 www.youtube.com/LearnWithYK


AnsKey/SQP-2/XII/CS-083/2025/YK

II. +------------+------------+
| min(price) | max(price) |
+------------+------------+
| 0.75 | 0.75 |
| 1 | 1.5 |
| 1.5 | 2 |
+------------+------------+

III. +------+
| size |
+------+
| S |
| M |
| L |
+------+

IV. +-------+------+-------+
| Name | Size | Price |
+-------+------+-------+
| Apple | M | 1 |
| Apple | L | 1.5 |
| Mango | M | 1.5 |
| Mango | L | 2 |
+-------+------+-------+

33. (I) def appendRec(): (4)


import csv
with open("Juices.CSV",'a',newline='') as f:
w=csv.writer(f)
ID=int(input("Enter ID: "))
Content=input("Enter Content: ")
Sugar=input("Contains sugar (Y/N)? ")
Qty=int(input("Enter quantity"))
Price=int(input("Enter Price: "))
rec=[ID,Content,Sugar,Qty,Price]
w.writerow(rec)

(II) def SugarN():


import csv
with open("Juices.CSV") as f:
r=csv.reader(f)
for rec in r:
if rec[2]=='N':
print(rec)

34. (I) select Juices.* from Juices natural join Orders; (4)
(II) Select Orders.*,Content from Juices natural join Orders
where O_date like '2024%';
(III) select O_No, O_Qty*Price*(100-Discount) as value from Juices
natural join orders;
(IV) (A) select J_ID, Price from Juices natural join orders
where discount=0 or discount is null;
OR
(B) alter table juices add column BalQty int(4);

35. def DeleteAndDisplay(): (4)


import mysql.connector as cnctr

www.yogeshsir.com AK2-4/6 www.youtube.com/LearnWithYK


AnsKey/SQP-2/XII/CS-083/2025/YK

conn=cnctr.connect(host='localhost', user='Guest',
password=' Abhi-J', database='AbhiSales')
crsr=conn.cursor()
ID=input("Enter J_ID to delete: ")
qry=f"delete from Juices where J_ID='{ID}'"
crsr.execute(qry)
conn.commit()
qry='select * from Juices'
crsr.execute(qry)
for rec in crsr:
print(rec)

SECTION E (2 X 5 = 10 Marks)

36. (I) def append(): (5)


import pickle
with open('Emp.dat','ab') as f:
ID=int(input("Enter E_ID: "))
Name=input("Enter Name: ")
Age=int(input("Enter age: "))
Salary=int(input("Enter Salary: "))
Exp=float(input("Enter experience: "))
rec=[ID,Name,Age,Salary,Exp]
pickle.dump(rec,f)

(II) def search():


import pickle
ID=int(input("Enter E_ID: "))
found=0
with open('Emp.Dat','rb') as f:
try:
while True:
rec=pickle.load(f)
if rec[0]==ID:
print(rec)
found=1
break
except:
if found==0:
print("Record Not Found")
(III) def display():
import pickle
c=0
with open('Emp.Dat','rb') as f:
try:
while True:
rec=pickle.load(f)
if rec[2]<30:
c+=1
except:
print("Number of employees with Age<30:",c)

37. (I) Admin block. This is the most secured block as it has restricted public (5)
movement.
(II) Switch

www.yogeshsir.com AK2-5/6 www.youtube.com/LearnWithYK


AnsKey/SQP-2/XII/CS-083/2025/YK

(III)

Router should be used to interconnect the networks of various blocks.


(IV) No, as the distance between any two connected blocks is just a few meters and
any cable can carry data upto that distance without any signal loss.
(V) (A) Satellite link
OR
(B) VoIP

www.yogeshsir.com AK2-6/6 www.youtube.com/LearnWithYK


AnsKey/SQP-3/XII/CS-083/2025/YK

Answer Key
Sample Question Paper-3 (Theory)
Class: XII
Session: 2024-25
Computer Science (083)

Section-A (21 x 1 = 21 Marks)

1. True (1)

2. (C) -1 (1)

3. True (1)

4. (B) aabbabc (1)

5. (D) T1[1]=2 (1)

6. venddo (1)

7. dict.fromkeys(rec,10) (1)

8. (D) All of these (1)

9. True (1)

10. (D) 4-3+ (1)

11. file.readline() (1)

12. (B) Primary Keys (1)

13. Desc (1)

14. (D) Set of integers from 101 to 130. (1)

15. (D) Product of the cardinalities of the tables. (1)

16. (C) Structured Query Language (1)

17. (B) Packet Switching (1)

18. (A) Infrared Rays (1)

19. Tree topology (1)

20. (A) (1)

21. (D) (1)

Section-B ( 7 x 2=14 Marks)

22. A constant value is called a literal. (2)


Examples:
integer literal: 5
string literal: '5'

23. (i) 98 (ii) True (2)

24. (I) (2)


A) print(S1.lstrip())

www.yogeshsir.com AK3-1/5 www.youtube.com/LearnWithYK


AnsKey/SQP-3/XII/CS-083/2025/YK

OR
B) S3=S2.rstrip()

(II)
A) print(sorted(S1))
OR
B) print(len(S2))

25. Correct possible output(s): (A) and (B) (2)


Minimum possible values of the variable b is 0
Maximum possible values of the variable b is 7

26. def countEven(nums): (2)


c=0
for ele in nums:
if ele%2==0:
c+=1
print(c)

27. (I) (2)


A) Drop table Groups;
OR
B) Yes
(II)
A) Drop database Sports.
OR
B) Yes

28. A) Advantage: (2)


Simplicity: Bus topology is easy to set up and requires less cable compared to other
topologies, making it cost-effective.
Disadvantage:
Limited Length: The length of the bus cable is limited, which can restrict the
size of the network.
B) SMTP – Simple Mail Transfer Protocol
SMTP is a transportation protocol used to transfer E-mail messages over the Internet.
All E-mail servers use the SMTP to send E-mails from one E-mail server to another.

Section-C ( 3 x 3 = 9 Marks)

29. A) def lastWord(): (3)


f=open('Sports.txt')
for line in f:
words=line.split()
last=words[-1]
if last[-1] in '.,':
last=last[:-1]
print(last)
OR
B) def splChar():
f=open('Sports.txt')
data=f.read()
c=0
for ch in data:
if not (ch.isalnum()):
c+=1
print("Number of special characters =",c)

www.yogeshsir.com AK3-2/5 www.youtube.com/LearnWithYK


AnsKey/SQP-3/XII/CS-083/2025/YK

30. (A) def Push_Movie(M): (3)


if 8<=M[-1]<=9:
rec=[M[0],M[-1]]
Ratings.append(rec)

def Pop_Movies():
c=0
while Ratings:
print(Ratings.pop(), end=' ')
c+=1
else: print(c,"Records popped")
OR
(B) def Push(Color, S):
for clr in Color:
if len(clr)>5:
S.append(clr)

def Pop(S):
while S:
print(S.pop(), end=' ')
else: print("Stack Empty")

31. A) 3-4-9-7-10- (3)


OR
B) 3-7-11-15-19-

SECTION D (4 X 4 = 16 Marks)

32. A) (4)
I. Select Title from movies where Actor='Abhay Deol';
II. Select * from movies where year = 2012;
III. Select count(*) from movies where Music='M001';
IV. Select * from movies where Director='Prakash Jha';
OR
B)
I. +------+----------+
| Year | count(*) |
+------+----------+
| 2012 | 1 |
| 2013 | 1 |
| 2016 | 1 |
| 2019 | 1 |
| 2020 | 1 |
| 2021 | 1 |
+------+----------+

II. +-------+----------+
| Music | count(*) |
+-------+----------+
| M002 | 2 |
| M001 | 3 |
| M003 | 1 |
+-------+----------+

III. +-------+--------------+
| mid | title |
+-------+--------------+
| MV002 | Madras Cafe |
| MV003 | Jai Gangajal |
+-------+--------------+

www.yogeshsir.com AK3-3/5 www.youtube.com/LearnWithYK


AnsKey/SQP-3/XII/CS-083/2025/YK

IV. +-------+---------------+------+
| mid | title | year |
+-------+---------------+------+
| MV005 | Gulabo Sitabo | 2020 |
| MV002 | Madras Cafe | 2013 |
| MV006 | Sardar Udham | 2021 |
+-------+---------------+------+

33. (I) def appendRec(): (4)


import csv
with open("Movies.CSV",'a',newline='') as f:
w=csv.writer(f)
ID=int(input("Enter Movie ID: "))
Title=input("Enter Title of the movie: ")
Year=int(input("Enter the release year: "))
Dir=input("Enter the Director name: ")
Music=input("Enter the Musician code: ")
rec=[ID,Title,Year,Dir,Music]
w.writerow(rec)
(II) def Rel2024():
import csv
c=0
with open("Movies.CSV") as f:
r=csv.reader(f)
for rec in r:
if int(rec[2])==2024:
c+=1
print(rec)
print("Number of movies released in 2024 =",c)

34. (I) select MID,Musician.* from movies natural join musician where (4)
MID in ('MV001','MV002','MV006');
(II) select MID, Title, Name1 from movies natural join musician;
(III) delete from movies where year<2015;.
(IV) (A) alter table movies add primary key(MID);
OR
(B) alter table musician drop column movies;

35. def UpdateAndDisplay(): (4)


import mysql.connector as cnctr
conn=cnctr.connect(host='localhost', user='root',
password='Cin-2025', database='Cinema')
crsr=conn.cursor()
qry='alter table Movies add column Actor varchar(15)'
crsr.execute(qry)
qry='select * from Movies'
crsr.execute(qry)
data=crsr.fetchall()
for rec in data:
print(rec)

SECTION E (2 X 5 = 10 Marks)

36. (I) def append(): (5)


import pickle
with open('Bags.dat','ab') as f:

www.yogeshsir.com AK3-4/5 www.youtube.com/LearnWithYK


AnsKey/SQP-3/XII/CS-083/2025/YK

bid=int(input("Enter B_ID: "))


brand=input("Enter Brand Name: ")
btype=input("Enter type of the bag: ")
cap=float(input("Enter bag capacity in litres: "))
price=int(input("Enter price of the bag: "))
war=int(input("Enter bag warranty: "))
rec={bid:[brand,btype,cap,price,war]}
pickle.dump(rec,f)

(II) def search():


import pickle
ID=int(input("Enter B_ID: "))
found=0
with open('Bags.dat','rb') as f:
try:
while True:
rec=pickle.load(f)
for k in rec.keys():
if k==ID:
print(rec)
found=1
break
except:
if found==0:
print("Record Not Found")
(III) def display():
import pickle
with open('Bags.dat','rb') as f:
s=c=0
try:
while True:
rec=pickle.load(f)
for v in rec.values():
if v[1]=='Laptop':
s+=v[3]
c+=1
except:
if c==0:
print("No Laptop bag in the file")
else: print("Laptop bag average price =",s/c)

37. (I) Optical Fiber Cable. (5)


(II) 4 switches, and 1 Router
(III)

(IV) Firewall.
(V) (A) Data transfer over Wi-Fi is less secure than data transfer using cables?
OR
(B) Star.

www.yogeshsir.com AK3-5/5 www.youtube.com/LearnWithYK


AnsKey/SQP-4/XII/CS-083/2025/YK

Answer Key
Sample Question Paper-4 (Theory)
Class: XII
Session: 2024-25
Computer Science (083)

Section-A (21 x 1 = 21 Marks)

1. False (1)

2. (D) s.islower() (1)

3. True (1)

4. (B) 3 (1)

5. (B) t=tuple(1,2,3) (1)

6. pePne* (1)

7. print(my_dict[1,2]) (1)

8. (A) nums+'123' (1)

9. True (1)

10. (C) def f1(a=10,b): (1)

11. file.write("Easy") (1)

12. (B) Insert (1)

13. (A) method of cursor object (1)

14. (B) 30 (1)

15. (D) Cannot be predicted without actual data. (1)

16. (A) Add a new column to a table (1)

17. (C) Infrared rays are used for short distance communication. (1)

18. (C) NIC (1)

19. (A) Modulation (1)

20. (B) (1)

21. (A) (1)

Section-B ( 7 x 2=14 Marks)

22. title() turns the first letter of each word of the given string into uppercase and turns (2)
all other characters into lowercase.
capitalize() turns the first letter of the given string into uppercase and turns all other
characters into lowercase.
Output: A Bc De- A bc de

23. (i) 4 (ii) '333333' (2)

www.yogeshsir.com AK4-1/6 www.youtube.com/LearnWithYK


AnsKey/SQP-4/XII/CS-083/2025/YK

24. (I) (2)


A) print(list(D1))
OR
B) D2.popitem()
(II)
A) D1.update(D2)
OR
B) D2[4]='d'

25. Correct possible output(s): (A) and (D) (2)


Minimum possible value of the variable x is 'e'
Maximum possible value of the variable x is 't'

26. def countVowels(s): (2)


c=0
for ch in s:
if ch in 'aeiou':
c+=1
print(c)

27. (I) (2)


A) Desc Groups;
OR
B) Yes
(II)
A) Alter table Student drop column Age;
OR
B) Select count(*) from T1 natural join T2;

28. A) Bandwidth of a channel is the range of frequencies available for transmission of data (2)
The unit to measure bandwidth is Hertz (Hz).
OR
B) IP address, also known as Internet Protocol address, is a unique address that can be
used to uniquely identify each node in a network.
Example: 192:168:0:178

Section-C ( 3 x 3 = 9 Marks)

29. A) def digitsAndAlpha(): (3)


f=open("Codes.txt")
data=f.read()
d=[]
a=[]
for ch in data:
if ch.isdigit() and int(ch) not in d:
d.append(int(ch))
if ch.isupper() and ch not in a:
a.append(ch)
print(d)
print(tuple(a))
OR
B) def alternate():
f=open("Codes.txt")
data=f.readlines()
for line in data[::2]:
print(line.strip())

www.yogeshsir.com AK4-2/6 www.youtube.com/LearnWithYK


AnsKey/SQP-4/XII/CS-083/2025/YK

30. (A) (3)


(i) def pushStd(std):
if std[2]==12 and std[3]=='B':
XIIB.append([std[0],std[1]])
(ii) def popStd():
while XIIB:
print(XIIB.pop())
else: print("Empty Stack")
OR
(B)
def push(Classes):
for k,v in Classes.items():
if v>25:
stack.append(k)
print("The count of elements in the stack is",len(stack))

31. A) [62, 107, 63, 5, 23] 19 (3)


OR
B) 6 4 10
3 1 4

SECTION D (4 X 4 = 16 Marks)

32. A) (4)
I. Update teachers set Age=Age+1, Exp=Exp+1;
II. Select * from Teachers where SubCode='042' and DOJ like
'2022%';
III. Select Desig, min(Age), max(Age) from teachers group by
Desig;
IV. Select Name, Age, SubCode from Teachers where Desig='PGT'and
Exp>10;
OR
B)
I. +------------+------+
| Name | Exp |
+------------+------+
| Rashmi | 7 |
| Bharat | 9 |
| Damanpreet | 10 |
| Charu | 15 |
| Asim | 17 |
| David | 17 |
| Rajesh | 21 |
+------------+------+
II. +----------+
| count(*) |
+----------+
| 4 |
+----------+
III. +---------+----------+
| subcode | count(*) |
+---------+----------+
| 041 | 2 |
| 043 | 1 |
| 042 | 2 |
| 083 | 1 |
| 803 | 1 |
+---------+----------+

www.yogeshsir.com AK4-3/6 www.youtube.com/LearnWithYK


AnsKey/SQP-4/XII/CS-083/2025/YK

IV. +------------+------------+
| min(doj) | max(doj) |
+------------+------------+
| 2019-12-01 | 2022-12-11 |
+------------+------------+

33. (I) def appendRec(): (4)


import csv
with open("Classes.CSV",'a',newline='') as f:
w=csv.writer(f)
C=int(input("Enter Class: "))
Sec=input("Enter Section: ")
Str=int(input("Enter Class strength: "))
CT=input("Enter class teacher's name: ")
Music=input("Enter the Musician code: ")
rec=[C,Sec,Str,CT]
w.writerow(rec)

(II) def Rel2024():


import csv
s=c=0
with open("Classes.CSV") as f:
r=csv.reader(f)
for rec in r:
if int(rec[0])==12:
c+=1
s+=int(rec[2])
if c>0:
print("Average number of students in class 12 =",s/c)
else:
print("No student in class 12")

34. (I) select Name,Class,Sec from Teachers T1, Classes T2 (4)


where ATCode=TCode;
(II) select TCode, Name, DOJ from Teachers T1, Classes T2
where CTCode=TCode;
(III) select class, avg(strength) from Classes group by class;
(IV) (A) alter table classes add primary key (Classes, Sec);
OR
(B) alter table teachers add dob date;

35. def AddAndDisplay(): (4)


import mysql.connector as cnctr
conn=cnctr.connect(host='localhost', user='Guest',
password='Sch-JkP', database='School')
crsr=conn.cursor()
a,b,c,d,e=12,'B',12,'PG030','PG101'
qry="insert into classes values ({},'{}',{},'{}','{}')"
qry=qry.format(a,b,c,d,e)
crsr.execute(qry)
conn.commit()
qry='select * from Classes where Strength<20'
crsr.execute(qry)
for rec in crsr:
print(rec)

www.yogeshsir.com AK4-4/6 www.youtube.com/LearnWithYK


AnsKey/SQP-4/XII/CS-083/2025/YK

SECTION E (2 X 5 = 10 Marks)

36. (I) def append(): (5)


import pickle
with open('Schools.Dat','ab') as f:
Aff_No=int(input("Enter Affiliation Number: "))
Name=input("Enter School Name: ")
Level=input("Enter School Level: ")
Strength=float(input("Enter school strength: "))
Prin=input("Enter name of the Principal: ")
Web=input("Enter school website address: ")
rec={Aff_No:[Name,Level,Strength,Prin,Web]}
pickle.dump(rec,f)

(II) def deleteRec():


import pickle
ID=int(input("Enter Affiliation Number: "))
found=0
data=[]
with open('Schools.Dat','rb') as f:
try:
while True:
rec=pickle.load(f)
for k in rec.keys():
if k==ID:
found=1
else:
data.append(rec)
except:
pass
if found==0:
print("Record Not Found")
else:
with open('Schools.Dat','wb') as f:
for rec in data:
pickle.dump(rec,f)

(III) def display():


import pickle
with open('Schools.Dat','rb') as f:
try:
while True:
rec=pickle.load(f)
for k,v in rec.items():
if v[1]=='Sec':
print(rec)
except:
pass

37. (I) Optical Fibre Cable. (5)


(II) Switch

www.yogeshsir.com AK4-5/6 www.youtube.com/LearnWithYK


AnsKey/SQP-4/XII/CS-083/2025/YK

(III)

(IV) Firewall
(V) (A) No, as we are using Optical Fibre Cable
OR
(B) Star topology.

www.yogeshsir.com AK4-6/6 www.youtube.com/LearnWithYK


AnsKey/SQP-5/XII/CS-083/2025/YK

Answer Key
Sample Question Paper-5 (Theory)
Class: XII
Session: 2024-25
Computer Science (083)

Section-A (21 x 1 = 21 Marks)

1. True (1)

2. (D) 9 (1)

3. '0' (1)

4. (B) 3 (1)

5. (B) t=tuple(1,2,3) (1)

6. (C) print(a[3:-3:-1]) (1)

7. None (1)

8. (C) nums[3]='4' (1)

9. False (1)

10. ['x', 'p', 'e', 'c', 't', 'e'] (1)

11. 'r' (OR 'rt' OR 'tr' OR 't') (1)

12. (B) Cardinality (1)

13. (B) method of connection object (1)

14. (A) Set (1)

15. (B) same as the domain of the Primary key to which it refers. (1)

16. (A) Create (1)

17. (C) 198.302.192.1 (1)

18. (C) World Wide Web (1)

19. (B) Demodulation (1)

20. (A) (1)

21. (A) (1)

Section-B ( 7 x 2=14 Marks)

22. (I) randrange(), randint() (2)


(II) random(), uniform()

23. (i) -7 (ii) 21 (2)

24. (I) (2)


A) print(S1.upper())
OR
B) print(S2.lower())

www.yogeshsir.com AK5-1/5 www.youtube.com/LearnWithYK


AnsKey/SQP-5/XII/CS-083/2025/YK

(II)
A) print(S2.count('a'))
OR
B) LS1=sorted(list(S1))

25. Correct possible output(s) are (B) and (C) (2)


Minimum possible value of a is 2
Maximum possible value of a is 5

26. def f1(n): (2)


s=0
for i in range(1,n+1):
if i%2==0 and n%i==0:
s+=i
return s

27. (I) (2)


A) 8
OR
B) 50
(II)
A) {23,60} (OR Set of integers from 23 to 60)
OR
B) {'PRT', 'TGT', 'PGT'}

28. A) URL: www.yogeshsir.com/resources/css.html (2)


Domain Name: www.alpha.com
OR
B) (i) PAN (Personal Area Network) belongs to an individual, whereas a LAN usually belongs
to an organization.
(ii) USB cables, Wi-fi, and Bluetooth are generally used to setup a PAN, whereas Twisted
Pair Cable, Co-axial Cable, or Optical Fibre cable are generally used to setup a LAN.

Section-C ( 3 x 3 = 9 Marks)

29. A) def TV(): (3)


f=open("TV.txt")
c1=c2=c3=0
data=f.read()
words=data.split()
lines=data.split('\n')
for ch in data:
if ch.isupper():
c1+=1
for w in words:
if len(w)==5:
c2+=1
for line in lines:
w=line.split()
if len(w)>=5:
c3+=1
print("Number of capital alphabets =",c1)
print("Number of 5 letter words = ",c2)
print("Number of lines with at least 5 words =",c3)

OR

www.yogeshsir.com AK5-2/5 www.youtube.com/LearnWithYK


AnsKey/SQP-5/XII/CS-083/2025/YK

B) def readTV():
with open('TV.txt') as f:
for line in f:
line=line.rstrip()
if line[-1] in '.,':
line=line[:-1]
print(line[0],line[-1])

30. (A) (i) def pushTV(TV): (3)


if std[2]=='OLED':
OLED.append([TV[0],TV[1],TV[3]])
(ii) def popTV():
while OLED:
print(OLED.pop())
else: print("Stack Empty")

OR

(B) (i) def Push(S1,TV):


s=0
for ch in TV:
if ch.isdigit():
S1.append(ch)
s+=int(ch)
print("Sum of digits pushed =",s)
(ii) def Pop(S1):
while S1:
print(S1.pop(),end=' ')
print("All Popped")

31. A) 5 2 (3)
4 1
1 4
OR
B) 21 15
7 15
15 7

SECTION D (4 X 4 = 16 Marks)

32. A) (4)
I. Update TV set price=price*95/100 where Brand='Sony';
II. Select * from TV where Resolution='4K';
III. Select Brand, count(*) from TV group by Brand;
IV. Delete from TV where Resolution is NULL;
OR
B)
I. +-------+------+
| Brand | Size |
+-------+------+
| Acer | 43 |
| Acer | 50 |
| LG | 32 |
+-------+------+

www.yogeshsir.com AK5-3/5 www.youtube.com/LearnWithYK


AnsKey/SQP-5/XII/CS-083/2025/YK

II. +---------+------+-------+
| Brand | Size | Price |
+---------+------+-------+
| Samsung | 65 | 68000 |
| LG | 32 | 14000 |
+---------+------+-------+

III. +------------+
| avg(price) |
+------------+
| 37333.3333 |
+------------+

IV. +----------+------+---------+
| Model | Size | Display |
+----------+------+---------+
| Bravia | 55 | LED |
| Bravia 2 | 43 | LED |
| Crystal | 65 | OLED |
+----------+------+---------+

33. (I) def appendRec(): (4)


import csv
with open("TV.CSV",'a',newline='') as f:
w=csv.writer(f)
B=input("Enter Brand: ")
M=input("Enter Model: ")
S=int(input("Enter Size: "))
P=float(input("Enter Price: "))
rec=[B,M,S,P]
w.writerow(rec)
(II) def Display():
import csv
with open("TV.CSV") as f:
r=csv.reader(f)
for rec in r:
if float(rec[-1])<30000:
print(rec)

34. (I) select TV.* from TV natural join Bills where BDate like (4)
'2024%';
(II) select Bills.* from TV natural join Bills where Brand='Sony';
(III) select BNo,T_ID from TV natural join Bills where Size<50;
(IV) (A) alter table TV add Primary key(T_ID);
OR
(B) alter table Bills add Cust int;

35. def AlterAndDisplay(): (4)


import mysql.connector as cnc
conn=cnc.connect(host='localhost', user='Guest',
password='Sd@SSA', database='SSA')
crsr=conn.cursor()
qry="alter table tv add price float"
crsr.execute(qry)
qry='select * from TV'
crsr.execute(qry)
data=crsr.fetchall()
for rec in data:
print(rec)

www.yogeshsir.com AK5-4/5 www.youtube.com/LearnWithYK


AnsKey/SQP-5/XII/CS-083/2025/YK

SECTION E (2 X 5 = 10 Marks)

36. (I) def append(): (5)


import pickle
with open('TV.Dat','ab') as f:
T_ID=int(input("Enter T_ID: "))
Br=input("Enter Brand Name: ")
Model=input("Enter Model Name: ")
Size=int(input("Enter Screen Size: "))
Pr=int(input("Enter Price: "))
rec=[T_ID, Br, Model, Size, Pr]
pickle.dump(rec,f)

(II) def update():


import pickle
data=[]
with open('TV.Dat','rb') as f:
try:
while True:
rec=pickle.load(f)
if rec[1]=='Samsung':
rec[-1]+=int(rec[-1]*10/100)
data.append(rec)
except:
f.close()
with open('TV.Dat','wb') as f:
for rec in data:
pickle.dump(rec,f)

(III) def display():


import pickle
with open('TV.Dat','rb') as f:
try:
while True:
rec=pickle.load(f)
if rec[-1]>50000:
print(rec)
except:
pass

37. (I) ADMIN building, as it has the maximum number of computers. (5)
(II)

(III) Suggest and draw the cable layout to efficiently connect various buildings within the
PATHANKOT campus for connecting the computers.
(IV) Firewall
(V) Video Conferencing
(VI) (A) Yes. Switches are needed in each building to interconnect the computers within
that building.
OR
(B) Yes. Router is needed to interconnect all the buildings and to provide Internet in
the campus.

www.yogeshsir.com AK5-5/5 www.youtube.com/LearnWithYK


QB/XII/CS-083/2025/YK

Floor Division (//) and Remainder(%) operators Slicing

+= for lists and tuples Working with CSV files

Formatted Output
Absolute and Relative file paths

Working with Dates in Python Python Tutorials Playlist

Shorts – split() vs partition() Shorts – append() vs extend()

Shorts – iterables Shorts - // and %

Shorts - += for lists and tuples

www.yogeshsir.com www.youtube.com/LearnWithYK

You might also like