0% found this document useful (0 votes)
44 views

GE - Computer Scien 81iXSLh

Uploaded by

shouryasingh2412
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
44 views

GE - Computer Scien 81iXSLh

Uploaded by

shouryasingh2412
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

2393 't2 [This q,udstion paper contains l2 printed pages.

(i) try: You r Roll No,..........,...


f = open('filel.txt', 'r') Sr. No. of Question Paper: 2393 G
except IOError:
Unique Paper Code 234400t102
print("Problem with input output")
Name of the Paper Programming with Python
else:

printf("No problem with input output")


N ame of the Course Computer Science: Generic
Elective
C r,ll e
(ii) try: Scmester I '1.
f = open(filel.txt'. 'w') Duration: 3 Hours 'Maximum Marks : 90
except IOError: \\* \
Instructions for Candidates
)t
print("Problem with input output") .l::,i+;
"'r.C:-.r ---1^i(:"'
else: Write your Roll No. on the top immediately o, receipt
of this question paper.
print("No problem with input output")
2. Question I in Section A is compulsory.
(c) Write statements in Python to accept two strings 3. Attempt any 4 questions from Section B
Sl and 52 from the user. Subsequently, display
4. Answer all parts of a question together.
distinct characters in both the strings in ascending
order. (5)
Section - A

I (a) Draw a flow chart to find whether a positive


integer is even or odd. (J)

(500) P.T.O.
.,
2393 2393 11

(b) Construct logical exprEssion 'for representing the, (iii) total = 0

following condition : (3) total : total +x


print(total)
RollNo should not be negative and Marks should
be in between 0 and 100. (iv) if age > 18

print("EIigible for License")


(c) Identify valid/invalid identifiers from the
(c) Write a function in Python that accepts a list of
following :

integers L from the user. The function should count


(i) First Number and return the number of elements that are greater
than 50. (5)
(ii) Number I

(iii) Number#List i (a) Write a function in Python that takes a digit (from
0 to 9) as an input parameter and returns the
(iv) Pass corresponding text in words. For example, on input
5, the function should return 'Five'. Use a
(v) ,N umber
dictionary for mapping digits to their string
(vi) Del (3) representation. (5)

(d) List any 3 operators of dictionary that can be used


(b) What will be the output of the following
code segment if the file being opened does not
only with the keys of the dictionary. Cive example
exist: (5)
of one operator with its usage. (3)

P. T. O.
2393 10 2393 3

(ii) tupl = (10) (e) Consider a tuple t: ("Harry", "Jack", [40,35])


print(tupl.index( I 0))
Indicate error (if any) in the following code

(iii) listl : 154,76,34, 'Hello', 421 segments else write no error. Justify your answer.
print(sum(list I ) )
(i) tlll : "Rinni"
(iv) strl = "Hi, wow are you?" print(t)
strl [4] : 'h'
(ii) tt2l[0] : 4s
(v) dictl : {'A':65, 'B':66, 'A':67} (3)
print(t)
print(dictl)

(f) Describe three modes used for opening a text


6 (a) Write a function that takes two files filel and file. (3)
file2 as input. The function should read the contents
of file filel line by line and should write them to (g) Consider a dictionary: (3 )

another file file2. Display the contents of file 2.

(6)
papers = {'GEl' : 'Python File', 'GE2': 'DBMS',
'GE3':'Computer Networks','GE4':'Information
(b) Identify the error(s) in the following: (4) Security')

(i) listl = ['Apple','Mango','Orange','Cherry'] What will be the output of the following function
listl [5] = 'PineaPPle' calls:

(ii) tuplel = (1, 'a', 4,'r',7,9) (i) print(papers. get('GE5'))


print(min(tuple I ))

P. T. O.
2393 4 2393 9

(ii) print(papers.get('GE5','.No such paper 5. , (a) Write a function FnFactorQ that accepts a number
ist" ) )
ex as input parameter and print its factors. (4)

(h) Identify two exceptions that may be raised while (b) What will be the output of the following code
executing the following statement and justify your
segments: (6)
answer. (3)
(i) x : [1,2,3,4,s,6,7,8,9, I 0]
product = x/y
result:0
(i) Consider a string : (3) for i in x:
strl = "SEC, Front End Web Design and '
if i%oZ l= 0:
Development"
result += i
Find the output of the following statements : print(result)

(i) strl[7:]
(ii) series = [i for i in range(I, 50) if i%5 == 0]
(ii) strl[-len(strl) : len(srrl)] print(series)

O Consider the following: (3) (c) Identify the output/error (if any) for the following.
Justify your answer if it is an error. (5)
names = ["Abhinav", "Riya", "Kirti", "Divya"]
(i) setl : {"Word", "Excel", "PowerPoint"}
rollno = (101, 104, 106, 109)
print(set1[2])
subject : ["Maths", "English", "Chemistry",
"Economics"l

P.T.O.
2393 E 2393 5

(iii) print(func(lA = l2)) What will be the output of the following


statements:
(iv) print(func(67 ,20, 5))
ii) data = list(zip(names, rollno, subject))

4 (a) Write a function FnreverseQ that accepts a number print(data)


from the user and print the reverse of the entered
(ii) names.sort0
number. (5)
print(names)

(b) Consider the following string : (5)

Pname = "Programm.ng with python" Section - B

What will be the outlut of the following:


2 (a) Wrile a function FnStrQ in Python to accept a
(i) Pname. count('P')
string from the user. Replace all the consonants
(ii) Panme.partition( " ) in the given string with the symbol "#". Return
the rnodified string from the function. (5)
(iii) Pname.swapcrse0
(b) Consider three sets : (5)
(iv) Pname.rfind('n')

(v) Pname.split (' ')


setl: { 1,2,3 }

ser2 : {4,5,6,2,3}
(c) Differentiate between copy( ) and deepcopy( ) set3: {4,5,7,8,9,2}
functions of the list, with the help of an example.
(s) What will be the output of the following:

P.T.O.
2393 6 2393 7

(i) set.intersdction(set I , set2, iset3) def funct0:

name : int(input("Enter your name"))


(ii) set I . intersection(set2. intersection (set3))
salary = 25000
(iii) set. difference(set3, set2, setl)
salary = salary + incentive
(iv) set3. difference(set2. difference(set I ))
info=name+salary
(v) set3.difference(set2.union(setl )) print(info)

funct0
(c) Differentiate between extendQ and append0
functions of the list, with the help of an example Identify and describe 3 exceptions that can be
for each. (5) raised while executing the above function funct0.

3 (a) Write a function to print the following pattern: (c) What will be the output/error (if any) of the
(s) following code segment: (4)

55555 marks = 65

4444 def func(marks, IA):


333 tA:23
2Z marks:marks+IA
I return marks

(i) print(func(57))
(b) Consider the following function: (6)

(ii) print(func(53, 24))

P. T. O.

You might also like