CS Question Bank 2
CS Question Bank 2
30=To
for K in range(0,To):
if k%4==0:
print (K*4)
else:
print (K+3)
11. Write a program to enter any number and check it is divisible by 7 or not. (3)
12. How many times loop will execute:
P=5
Q=35
while P<=Q:
P+=6
13. Find and write the output of the following python code: (3)
Msg="CompuTer" Msg1=''
for i in range(0, len(Msg)):
if Msg[i].isupper():
Msg1=Msg1+Msg[i].lower()
elif i%2==0:
Msg1=Msg1+'*'
else:
Msg1=Msg1+Msg[i].upper()
print(Msg1)
FUNCTIONS
1. What is the area of memory called, which stores the parameters and local variables of a function call?
(1)
2. What is the default return value for a function that does not return any value explicitly? (1)
3. Pick the following statements to correctly complete the function body in the given code snippet. (1)
def f(number):
#Missing function body
print(f(5))
4. What is the result of this code? (2)
def print_double(x):
print(2 ** x)
print_double(3)
5. A parameter having default value in the function header is known as a default parameter. (True/False)
6. Variables that are listed within the parentheses of a function header are called function variables.
(True/Flase)
7. Default parameters cannot be skipped in function call. (True/False)
8. A program having multiple functions is considered better designed than a program without any
functions. Why? (2)
9. What all information does a function header give you about the function? (2)
10. What are arguments? What are parameters? How are these two terms different yet related? Give
example. (4)
11. What is the utility of : (i) default arguments, (ii) keyword arguments? (4)
12. What is scope? What is the scope resolving rule of Python? (4)
13. What is the difference between local and global variable? (3)
14. What are the errors in following codes? Correct the code and predict output:
16. __________ function of writer object is used to send data to csv file to store. (1)
17. Write a python function CSVCOPY() to take sourcefile, targetfile as parameter and create a
targetfile and copy the contents of sourcefile to targetfile. (4)
DATA STRUCTURE
1. What is Data Structure? (1)
2. Stack data structure is following ____________ principle. (1)
3. In stack data can be inserted or deleted from ____________ only. (1)
4. The insert operation in the stack is known as pop. (True/False) (1)
5. A condition raise due to the stack is full is known as ___________. (1)
6. What are the basic operations that can be performed on the stack? (2)
7. Write steps on how you implement stack? (2)
8. Write a python function to delete an element from the stack. (4)
9. Write functions AddPlayer(player) and DeletePlayer(player) in python to add and remove a player by
considering them as push and pop operations in a stack. (4)
10. Vedika has created a dictionary containing names and marks as key-value pairs of 5 students. Write
a program, with separate user-defined functions to perform the following operations: (5)
1. Push the keys (name of the student) of the dictionary into a stack, where the corresponding value
(marks) is greater than 70.
2. Pop and display the content of the stack.