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

B Sc Computer ScienceH 2022 PYQ Paper Programming Using Python PYQ

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

B Sc Computer ScienceH 2022 PYQ Paper Programming Using Python PYQ

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

a

\ Westion Paper Sontainy 12 printed pages]


Your Roll Nov
i... us
Sr. No, oif Question
i
Unique Paper Code
Name of the Paper
Name of the Course
Semester
Paper; 1920
B
2342011101
: Programming
(DSC-1)
using Python
: B.Sc. (H) Computer Science
Hd
Maximum Marks : 90

2
function
checkPrime(n)
number 0 is prime OF not. Th,
mf if the number p is p
to check whe
ion in main( ) to check the number
(4)
fe function
fe else
lowing expressions:
=9//4-2 and ‘hello’ >= Hello
“5
HOnary groupDict representing
(4)

10
1020
3
@ Access the value of the subject Chemistry.
(@) Extract the value of the key group, and
Use the default value as -1 if key is not
found,
(iii) Create a copy of a groupDict into a
dictionary object newGroup.
(iv) print the dictionary mewGroup after
removing the element with the key section.
efine a class Rectangle having the following
“Structure:
(6)
Attributes: length, breadth
_init_() for
lizing the attributes.
getLength()
which retumsthelength of the
rectangle.
perimeter, ) which returnsthe perimeter of
ted’, 'Blue', 'Green'y
allow’,Whiter

1020
5
(iv) mondays =(Januay31/Fear: 28Ma%
Month =monthDays
Month[February]=1
print(monthDays before clear») moathDeys)
print(’Month before clear->’, Month)
Month.clear()
print(‘monthDays after clear", monthDays)
print(’Month after clear->', Month)
SECTION B
(a) Write a program that accepts x and n as input to
_
compute the following series.
(6)
2 x xt
.
ota
ider the following code snippet
for k in ‘Computer Science’:
(9)

lowing tuples
jon swapTuple(T1, 12) «
falues of T1 and T2
d output is as follows
', ‘Tuesday’, Wednesday’)
300)
mergeTuple(T!, T2) to
uples containing the
Cn ent from tuples Tl and
is as follows :

1
ronsider jist 14 as follows
11= 1100, 209, 300, {400,500}]
Writecode Snippets to create the following lists
@ Las, shallow copy of Li
”13 48 a deep copy of L1.
aa,
Demonstrate the effect of the following
ions
in L1, L2 and L3:
@ LIL2} = 909
-Gi) Li3}10) =799
function doubleDict() that creates the
Dictl where the keys are numbers
and § andvalues fetwice the keys
ifthe key is 5, its value is 10. The
4
”)
1
should returnthedictionary

1020
8
1b) Consider two lists Lat!
and Ls
declared
>
follows
Latl © ['green’, ‘blue’)
Lst2 = [’blue’, ‘yellow ]
Write a python Script to do the following
(i) Convert list Lst! as set SI
set $2.
and Lst2 ay
(ii) Add the elements ofthe list ['black
to'S2.
yan"
1 and $2,
d the symmetric difference between sets
Set newSet
Using set
eR containing elements of S$]
Gat the end of each element,
ould appear as:
‘greens'}
e(marks, total)
marks for a
(6)

9
‘def percentage (marks, total):
a,
Percent = (marks/total) * 100
xcept ValucError:
Print("Value Error’)
‘Xcept TypeError:
Print(‘Type Error’)
xcept ZeroDivisionError:
Print(‘Zero Division Error’)
marten
_ Print(‘Any i

10
Gi) percentage ('200.0', 2999)
the following functions to
on a string.
(9)
untVowel(Str1)
to Count the vowels in a
Char(Str1) to replace al] Occurrence
Character ',' with a space.
img(Str1) to Teverse a string
call these functions and Provide
the given string Str].
"pends upon ourselves!’
the following code snippets:
G)

1020
a
AB) Explain the wpe ot exwoption raised in the following
Statomonts
@)
() xsd
PriAt(S/y)
(ii) print(’Phe amount for the day is :' + 300)
(ii) int(’Morning!)
(iv) Ll = [11,22,33,44,55]
print(Lt[5])
Describe the following methods for the class
‘objects with suitable examples,
(8)
@) _init__

12
program to read a file myFile and perform
‘operations:
(10)
the total number of lines in the file.
i
en lines of the file to a file named
e and odd lines to another file named

You might also like