0% found this document useful (0 votes)
6 views4 pages

KV RKP4 Class -12 CS Autumn Holiday HW

This document outlines homework assignments for Class-XII Computer Science students at PM SHRI KV SEC-4 RK PURAM DELHI. It includes a series of programming questions and tasks related to Python, covering topics such as data structures, file handling, and function definitions. Students are instructed to write their answers in a notebook and complete various coding exercises.

Uploaded by

Pri21 Legend
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
0% found this document useful (0 votes)
6 views4 pages

KV RKP4 Class -12 CS Autumn Holiday HW

This document outlines homework assignments for Class-XII Computer Science students at PM SHRI KV SEC-4 RK PURAM DELHI. It includes a series of programming questions and tasks related to Python, covering topics such as data structures, file handling, and function definitions. Students are instructed to write their answers in a notebook and complete various coding exercises.

Uploaded by

Pri21 Legend
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 4

PM SHRI KV SEC-4 RK PURAM DELHI

Class-XII Computer Science


Autumn Break HW
Q1) Do write answers of SQP 2024-25 in your Notebook.
Q2) Write The answers of following questions in your notebook.
QN QUESTIONS
1 What is LIFO in stack? Write the built-in function used to
(i) add a new element in the stack (ii) delete the Last element of the stack
2 Find the invalid identifier(s) from the following: (a) 12CS (b) _gmail (c) pRinT (d) def
3 Which statement will return one line from a file (file object is ‘f’)?
(a) f.readline( ) (b) f.readlines( ) (c) f.read( ) (d) f.line( )
4 Which Library must be imported for the function, randint() to run successfully?
5 What is the full form of CSV?
6 Consider a tuple tup1 = (10, 15, 25, 30) Identify the statement that will result in an error.
a. print(tup1[2]) b. tup1[2] = 20 c. print(min(tup1)) d. print(len(tup1))
7 Given the following dictionaries
dict_exam={"Exam":"AISSCE", "Year":2023}
dict_result={"Total":500, "Pass_Marks":165}
Which statement will merge the contents of both dictionaries?
a) dict_exam.update(dict_result) b) dict_exam + dict_result
c) dict_exam.add(dict_result) d) dict_exam.merge(dict_result)
8 What will the following expression be evaluated to in Python? print(15.0 / 4 + (8 + 3.0))
(a) 14.75 (b)14.0 (c) 15 (d) 15.5
9 Find the output of the following:
d = {9: 'd', 0: 'e', 4: 'f'}
for x in d.values():
print(x*2, end=",")
10 Write the output of the following code :
L = [5, 4, 78, 6, 12, 32, 45,67]
print(L.pop())
print(L.pop(5))
print(L)
11 Convert the following code to while loop:
for i in range(10,20,5):
print(i)
12 Find the error(s) in the following code snippet and write the corrected code.
def magic :
N=25
for i in range(0,N):
If N%2==0:
print(N*2)
elif N%3==0:
print(N*3)
else
print[N]
magic( )
13 Write a program in Python to read the entire content from file “data.txt” and copy only those words
to “story.txt” which start from vowels.
HINT: open two files in different modes as per the requirement
14 Write a statement in Python to declare a dictionary dict whose keys are 1, 2, 3,4 and values are
January, February, March and April respectively.
15 Find and write the output of the following Python code:
def Display(str):
m=""
for i in range(0,len(str)):
if(str[i].isupper()):
m=m+str[i].lower()
elif str[i].islower():
m=m+str[i].upper()
else:
if i%2==0:
m=m+str[i-1]
else:
m=m+"#"
print(m)
Display(‘Computer Science@2020’)
16 Write a function INDEX_LIST(L), where L is the list of elements passed as argument to the function.
The function returns another list named ‘indexList’ that stores the indices of all Non-Zero Elements of
L.
For example:
If L contains [12,4,0,11,0,56]
The indexList will have - [0,1,3,5]
17 p=5
def sum(q,r=2):
global p
p=r+q**2
print(p, end= '#')
a=10
b=5
sum(a,b)
sum(r=5,q=1)
18 (a) Given is a Python string declaration: myexam="@@CBSE Examination 2022@@"
Write the output of: print(myexam[::-2])

(b) Write the output of the code given below:


my_dict = {"name": "Aman", "age": 26}
my_dict['age'] = 27
my_dict['address'] = "Delhi"
print(my_dict.items())
19 Write a program in python to count those lines from the file “div.txt” which are starting from ‘T’ or
‘M’.
20 Write a function Show_words() in Python to read the content of a text file “Notes.TXT” and display
only such lines of the file which have exactly 5 words in them.
Example, if the file contains:
This is a sample file.
The file contains many sentences.
But needs only sentences which have only 5 words.
Then the function should display the output as:
This is a sample file.
The file contains many sentences
21 Write a program in python to replace all the ‘a’ by ‘@’ in a file “data.txt”.
22 Write a program in Python which counts all the special characters(Excluding whitespaces,digits and
alphabets) from the text file “Friend.txt”.
23 Given a Tuple T = (100, 200, 300, 400, 500, 600, 700, 800)
What will be the output of print( T [ : -5 : -1] ) ?
24 “A variable created outside all function body” is known as .
a. Default Variable b. Local Variable c. Global Variable d. Named Arguments

25 Find the output of the following code:


def change(x,y=85):
x+=y
y=x-y
print(x,'$',y)
return (x)
a=500
b=250
a=change(a,b)
print(a,"@",b)
b=change(b)
26 Write the difference between the following with example: (Any 7)
(i) Text File and Binary File
(ii) ‘w+’ and ‘a+’ file modes
(iii) Absolute path and relative path
(iv) Global variable and Local variable
(v) String and Dictionary
(vi) Mandatory arguments and keyword arguments
(vii) Implicit type conversion and explicit type conversion
(viii) Fruitful functions and non-fruitful functions
(ix) read( ) and write( ) function in text files
27 Aruna has a list containing temperatures of 10 cities. You need to help her 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 negative temperatures into a stack.
• Pop and display the content of the stack.
For Example: If the sample Content of the list is as follows: Sample Output of the code
should be:
[-9,3,31,-6,12,19,-2,15,-5,38] -5 -2 -6 -9
28 Rajiv has created a dictionary containing worker names and their wages as the key:value pairs of 6
workers of a factory.
Write a program with separate user-defined functions to perform the following operations:
• Push the keys (worker names) of the dictionary into a stack where the corresponding wage is
less than 500.
• Pop and display the content of the stack.
For example: if the sample content of the dictionary is as follows:
Worker={‘Bhola’:400, ‘Aseema’:450, ‘Ranga’:700, ‘Sanju’:500, ‘Ratna’:650, ‘Ruma’:550}
The output from program should be:
Sanju , Aseema, Bhola
29 Write a function Push(student) and Pop(student) to add a new student name and remove a student
name from a list student, considering them to act as PUSH and POP operations of stack Data
Structure in Python.

You might also like