Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
11 views
12 pages
Python Sem-1
For bsc Computer science hons pyq
Uploaded by
hs1762366
AI-enhanced title
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Download
Save
Save PYTHON SEM-1 For Later
Share
0%
0% found this document useful, undefined
0%
, undefined
Print
Embed
Report
0 ratings
0% found this document useful (0 votes)
11 views
12 pages
Python Sem-1
For bsc Computer science hons pyq
Uploaded by
hs1762366
AI-enhanced title
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Carousel Previous
Carousel Next
Download
Save
Save PYTHON SEM-1 For Later
Share
0%
0% found this document useful, undefined
0%
, undefined
Print
Embed
Report
Download
Save PYTHON SEM-1 For Later
You are on page 1
/ 12
Search
Fullscreen
it) ee (T hi is Westion Pet contains 12 printed pages] Your Roll Nowe" Sr. N, 0. * Qtetn Paper: 1920 Uniqu ; NS PSP Code > 2342011101 Nam morte Paper : Programming using Python (DSC-1) Name of the Course - BSe. (H) Computer Scienté Semester - Duration : 3 Hours vfasiemrn Blois «88 Instructions for Candidates 1. Write your Roll No. on the top immediately on receipt of this question paper. Section A is compulsory. wm 3, Attempt any 4 questions from Section B. 4. Parts of a question must be answered together. SECTION A (Compulsory) tis an algorithm? Write an algorithm to solve ha to (iW atic equation ne the quadt P.T.O,1020 0 check n is prime or not. The Write the python ev operations :1020 3 pemistry: (i) Access the value of the § (ii) Extract the value of the if key is use the default value § ° , found. ses ict i (iii) Create a copy of 4 groupDic dictionary object newGroup- : : fter (iv) print the dictionary newGroup 4 : s ion. removing the element with the key secti XN (oy Define a class Rectangle having .the following (6) structure: Attributes: length, breadth Methods: __init__() for initializing the attributes. getLength() which returns the length of the rectangle. perimeter( ) which retums the perimeter of the rectangle. (f) Find the output for the following python script Pts: (8) P.T.o,1020 4 (i) myString = Hibs Rveryong Wethome athe Session! Q print(myString [len(myString) :: -1}) © print(myString [:-15] + myString [-15:]) print(myString.partition('Welcome')) print(myString.rfind('to')) eo = ['Red', 'Blue', 'Green’] Y= ['Yellow','White'] X.extend(Y) X.append(23) X.pop() X.remove("Yellow') print(X) print(Y) Gi try: num = 8 print(num + ‘hello') Print(num / 4) except ZeroDivisionError: print(‘Divided by zero’) except(ValueEtror, TypeError): print('Error occurred’) finally: print('Stop')1020 5 1.28, asc: 31} (a) monthDays = (anuray' 31, see Month = monthDays Month{'February'] += ! \ onthDays) Print(‘monthDays before clea-7™ print(Month before cleat" Month) Month.clear() + monthD2ys) Print(‘monthDays after clear-”» mon print(Month after clear’, Month) SECTION B WS Write a program that accepts x and n as input to compute the following series. (6) x? x3 4 x-at a7 qty mterms (hf Consider the following code snippet (9) for k in ‘Computer Science': if k = 'e: S1 print(k, end=",") Compare the output when S1 is replaced with a of the following statements: c PTO,1020 6 (i) break (ii) continue (iii) pass CY (3 Consider the following tuples (6) T1 =(100, 200, 300) T2 = (‘Monday', 'Tuesday', 'Wednesday') AK, wire a function swapTuple(T1, T2) to swap the values of T1 and T2. The expected output is as follows: Tl = (‘Monday', 'Tuesday’', 'Wednesday'). T2 = (100, 200, 300) i) Write a function mergeTuple(T1, T2) to return a list of tuples containing the Corresponding element from tuples T1 and T2. The expected output is as follows: T3 = [(‘Monday', 100), (‘Tuesday', 200), (‘Wednesday', 300)]1020 , 7 : (9) (b) Consider list L1 as follows * L1 = [100, 200, 300, [400,500]] ; ing lists : Write code snippets to create the following Phas as a shallow copy of Ll G13 as a deep copy of LI. Demonstrate the effect of the following modifications in L1, L2 and L3: G11) = 900 Gd LIBI(01 = 700 x (a) Write a function doubleDict() that creates the dictionary Dict1 where the keys are numbers between 1 and 5 and values are twice the keys. For example: if the key is 5, its value is 10. The function should return the dictionary Dict1. Write a program that calls doubleDict( ) and print : in the values of the following operations when appli 4 to the Dict1. . (i) maximum key (ii) sum of keys (7) P.T.o,8 1020 ; ists Lstl (b) Consider two lists Pstl and po) dec] follows : aed ag (8) st] = ['green!, "blue'] Lst2 = ['blue'; 'yellow'] Write a python script to do the following : (i) Convert list Lstl as set gy and Lstd 4 S set $2. (ii) Add the elements of the list ['black’, 'cyan’] to $2. (iii) Find the symmetric difference between sets S1 and S2. (iv) Create a set mewSet using set comprehension containing elements of SI with ‘s’ added at the end of each element. The newSet should appear 4s: newSet = {'blues’, 'greens'} s, total) ‘a A . e(mark ) Consider the function percentag ¢ "for a ark that computes the percentage of m Student,def percentage (mar! 9 ks, total): try: percent = (marks/total) * 100 except ValueError: print('Value Error’) except TypeError: print('Type Error') except ZeroDivisionError: print('Zero Division Error') except: print(‘Any other error’) else: print(percent) finally: print('Completed!') Explain the output corresponding to the follows ng function calls. \ of percentage (17.0, 20.0) (iiY percentage (19.0, 0.0) PTo.1020 10 oe percentage ('200.0', 200.0) A Define the following functions to perform the operations on a string. (9) (i) countVowel(Str1) to count the vowels in a string. (ii) replaceChar(Str1) to replace all occurrence of the character 'a' with a space. rs reverseString(Str1) to reverse a string Write a program to call these functions and provide the output for the given string Strl. fee a ei Strl = 'Happiness depends upon ourselves! se (a) Find the error(s) in the following code snippets: ; (3) (i) filel = open('Myfile', 'w') filel.read() filel .close() (ii) tuplel = (2120, 'abc’) del tuple1 [0]> 020 11 (b) Explain the type of exception raised in the following | statements : (4) | (i) x=0 ~ | print(5/x) Gi) print('The amount for the day is :' + 300) | (ii) int(‘Morning’y (iv) L1 = (11,22,33,44,55} print(L1[5]) (c) Describe the following metho ds for the class objects with suitable examples. (8) (@) _init_ (i) _str_ ii) __del__ (iv) __main_ Koya rite a function sumDigits(Num) which computes the sum of digits of a number Num ang returns it. (5) PTo,1020 ite a program to read a file MYFile ang Perfor, ae llowing operations: : the fo 12 (10) UG print the total number o¢ lines in the file (iif copy even lines of the fite 44 evenFile and odd lines to another file Named oddFile. a file named (500)
You might also like
Ashish Question Paper
PDF
No ratings yet
Ashish Question Paper
7 pages
Question Paper Python
PDF
No ratings yet
Question Paper Python
12 pages
B. Sc. H Computer S YA1to4r
PDF
No ratings yet
B. Sc. H Computer S YA1to4r
6 pages
B SC Computer ScienceH 2022 PYQ Paper Programming Using Python PYQ
PDF
No ratings yet
B SC Computer ScienceH 2022 PYQ Paper Programming Using Python PYQ
4 pages
Question Paper Python Sem1 Krishna Gupta
PDF
No ratings yet
Question Paper Python Sem1 Krishna Gupta
7 pages
Computer Science Questions With Answers
PDF
No ratings yet
Computer Science Questions With Answers
8 pages
GE - Computer Scien LnptIBy
PDF
No ratings yet
GE - Computer Scien LnptIBy
5 pages
Sample Paper 11
PDF
No ratings yet
Sample Paper 11
4 pages
Python P Cycle 2021
PDF
No ratings yet
Python P Cycle 2021
4 pages
Ge Cs Question Paper
PDF
No ratings yet
Ge Cs Question Paper
8 pages
U VX 74 MDL 10311
PDF
No ratings yet
U VX 74 MDL 10311
4 pages
(NPTEL Activity) CSE 2nd Semester
PDF
No ratings yet
(NPTEL Activity) CSE 2nd Semester
7 pages
XI AnnualExam CS-coimbtore
PDF
No ratings yet
XI AnnualExam CS-coimbtore
8 pages
XII CS PractisePaper 4
PDF
No ratings yet
XII CS PractisePaper 4
12 pages
Python Final
PDF
No ratings yet
Python Final
11 pages
XI AnnualExam CS
PDF
No ratings yet
XI AnnualExam CS
6 pages
Computer Science Xi Paper PT-1 Hy PT-2 See
PDF
No ratings yet
Computer Science Xi Paper PT-1 Hy PT-2 See
14 pages
12 CSC 1
PDF
No ratings yet
12 CSC 1
7 pages
Grade 11 Computer Science HY - QP
PDF
No ratings yet
Grade 11 Computer Science HY - QP
6 pages
Practice Program For Annual Practical Exam
PDF
No ratings yet
Practice Program For Annual Practical Exam
13 pages
Winter Holidays Home Work-Class-XI-CS
PDF
No ratings yet
Winter Holidays Home Work-Class-XI-CS
1 page
RT-1 Mat Cs (Ch1,2) Ans
PDF
No ratings yet
RT-1 Mat Cs (Ch1,2) Ans
4 pages
Ch-1,2,3 Back Exercises
PDF
No ratings yet
Ch-1,2,3 Back Exercises
8 pages
Winter Holidays Home Work Class XI CS
PDF
No ratings yet
Winter Holidays Home Work Class XI CS
1 page
Std. 11 Computer Science - Half Yearly
PDF
No ratings yet
Std. 11 Computer Science - Half Yearly
5 pages
C SC Grade 11 QP Annual Exam March 2024 - Final
PDF
No ratings yet
C SC Grade 11 QP Annual Exam March 2024 - Final
7 pages
Oop With Python Lab
PDF
No ratings yet
Oop With Python Lab
48 pages
Winter Holidays Home Work-Class-XI-CS (2023-24)
PDF
No ratings yet
Winter Holidays Home Work-Class-XI-CS (2023-24)
1 page
Question Papers
PDF
No ratings yet
Question Papers
15 pages
Comp setA&B GB
PDF
No ratings yet
Comp setA&B GB
14 pages
Python 2023
PDF
No ratings yet
Python 2023
4 pages
GE - Computer Scien UyRAgNj
PDF
No ratings yet
GE - Computer Scien UyRAgNj
6 pages
Python Programs
PDF
No ratings yet
Python Programs
10 pages
Python IA 2
PDF
No ratings yet
Python IA 2
3 pages
11CS T2 2022 23SetB
PDF
No ratings yet
11CS T2 2022 23SetB
5 pages
Informatics Practices (Part-2)
PDF
No ratings yet
Informatics Practices (Part-2)
28 pages
Python 2nd Sem Previous Year Papers
PDF
100% (1)
Python 2nd Sem Previous Year Papers
6 pages
Python Practical Assignment
PDF
No ratings yet
Python Practical Assignment
7 pages
Sol PYTHON PROG - III Sem Question Paper (2023-24) Odd
PDF
No ratings yet
Sol PYTHON PROG - III Sem Question Paper (2023-24) Odd
25 pages
Xi QP Hy CS 231116 210839
PDF
No ratings yet
Xi QP Hy CS 231116 210839
7 pages
Holiday Worksheet New XII CS
PDF
No ratings yet
Holiday Worksheet New XII CS
4 pages
فتح COMP2101 Final SP24 (With Solution) PDF
PDF
No ratings yet
فتح COMP2101 Final SP24 (With Solution) PDF
10 pages
HOLIDAY ASSIGNMENT CSC
PDF
No ratings yet
HOLIDAY ASSIGNMENT CSC
6 pages
COMP2101 Final SP24 (With Solution)
PDF
No ratings yet
COMP2101 Final SP24 (With Solution)
10 pages
Python Lab Manual
PDF
No ratings yet
Python Lab Manual
163 pages
Computer Science 11 STD
PDF
No ratings yet
Computer Science 11 STD
9 pages
6781794-XII - CS - Worksheet 1 - RevisionTour
PDF
No ratings yet
6781794-XII - CS - Worksheet 1 - RevisionTour
4 pages
Computer Science Class 11 - Sultan Chand - SamplePaper2 (Key)
PDF
No ratings yet
Computer Science Class 11 - Sultan Chand - SamplePaper2 (Key)
12 pages
Practical Assignment
PDF
No ratings yet
Practical Assignment
9 pages
GE - Computer Scien 81iXSLh
PDF
No ratings yet
GE - Computer Scien 81iXSLh
6 pages
Student Support Material Class Xii - Cs
PDF
100% (1)
Student Support Material Class Xii - Cs
150 pages
Recordprgms
PDF
No ratings yet
Recordprgms
26 pages
B. Sc. H Computer S 62VSRUe
PDF
No ratings yet
B. Sc. H Computer S 62VSRUe
6 pages
23 Python External Paper 2020-21 ODD
PDF
No ratings yet
23 Python External Paper 2020-21 ODD
4 pages
Python Revision Tour
PDF
No ratings yet
Python Revision Tour
5 pages
Kartik Nagi XII A (Computer Science - Assignment)
PDF
No ratings yet
Kartik Nagi XII A (Computer Science - Assignment)
18 pages
Winter Holidays Home Work-Class-XI-CS
PDF
100% (1)
Winter Holidays Home Work-Class-XI-CS
1 page
Cs PPT 33
PDF
No ratings yet
Cs PPT 33
8 pages
Kaagaz 20250430 220413261429
PDF
No ratings yet
Kaagaz 20250430 220413261429
10 pages
Prob Assgn 2025
PDF
No ratings yet
Prob Assgn 2025
1 page
B. SC.H Computer SC Nadcv9e
PDF
No ratings yet
B. SC.H Computer SC Nadcv9e
4 pages
B. Sc. H Computer S GeYRW7E
PDF
No ratings yet
B. Sc. H Computer S GeYRW7E
4 pages