ClassP2
ClassP2
General Instructions:
1. This question paper contains three sections – A, B and C. Each part is compulsory.
2. Section A, consists of 10 questions (1-10). Each question carries 1 mark.
3. Section B, having two parts part 1 and part 2.
part 1 consists of 6 questions (11-16). Each question carries 2 marks.
Part 2 consists of 6 questions (17-22). Each question carries 3 marks.
4. Section C, consists of 4 questions (23-28). Each question carries 5 marks.
Section -A
Q.1 Find the invalid identifier from the following
a. none
b. address
c. Name
d. pass
Q.2 Consider a declaration L = (1, 'Python', '3.14'). Which of
the following represents the data type of L?
a. list
b. tuple
c. dictionary
d. string
Q.3 Given a Tuple tup1= (10, 20, 30, 40, 50, 60, 70, 80, 90).
What will be the output of print (tup1 [3:7:2])?
a. (40,50,60,70,80)
b. (40,50,60,70)
c. [40,60]
d. (40,60)
Q.4 Which of the following option is not correct?
a. if we try to read a text file that does not exist, an error occurs.
b. if we try to read a text file that does not exist, the file gets created.
c. if we try to write on a text file that does not exist, no error occurs.
d. if we try to write on a text file that does not exist, the file gets Created.
Q.5 Which of the following options can be used to read the first line of a text file Myfile.txt?
a. myfile = open('Myfile.txt'); myfile.read()
b. myfile = open('Myfile.txt','r'); myfile.read(n)
c. myfile = open('Myfile.txt'); myfile.readline()
d. myfile = open('Myfile.txt'); myfile.readlines()
Q.6 Assume that the position of the file pointer is at the beginning of 3rd line in a text file. Which
of the following option can be used to read all the remaining lines?
a. myfile.read()
b. myfile.read(n)
c. myfile.readline()
d. myfile.readlines()
Q.7 Consider a tuple tup1 = (10, 15, 25, and 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))
Section-B
Part -I
Q.11 An Immutable data type is that one that cannot change after being created. Give
three reasons to use
Q.12 What is the significance of having function in a program?
Q.13 What role is played by file modes in file operations? Describe the various file
mode constants and their meanings.
Q.14 What is stack? What basis operations can be performed on them?
Q.15 Explain with a code example the usage of default arguments and positional
arguments.
Q.16 How are keywords different from identifiers?
Part -II
Q.17 Predict the outputs of the program.
X=’one’
Y=’two’
Counter=0
While Counter < len(x):
Print(x[Counter],y[counter]
Counter +=1
Q.18 Write a program to print cubes of numbers in the range 15 to 20.
Q.19 Discuss Bubble sort and Insertion sort techniques
Q.20 Write a Function simple interest
Q.21 predict the output.
keepgoing =True
X=100
While keepgoing:
Print(X)
X=X-10
If X <50:
Keepgoing=False
Q.22What is indexing in context to python strings? why is it also called two-way indx
Section -C
Q.23 Write a program to print a square multiplication table (1 to 9).
Q.24 Program to sort a list using Bubble sort.
Q.25 Write a function that takes amount-in-dollars and dollar-to-ruppee conversion
price; it then return the amount converted to rupees. Create the function in both
void and non- void forms.
Q.26 python program to implement stack operation.
Q.27 Write a program that checks for presence of a value inside a dictionary and
prints its key.
Q.28 Write a program that generates 4 terms of an AP by providing initial and step
values to a function that returns first four terms of the series.
Hint: - a, (a + d), (a + 2d), (a + 3d)