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

Question Paper Python Sem1 Krishna Gupta

Uploaded by

SHEETAL TANEJA
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
0% found this document useful (0 votes)
28 views

Question Paper Python Sem1 Krishna Gupta

Uploaded by

SHEETAL TANEJA
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
You are on page 1/ 7
[This ques question paper contains 12 printed pages.] Your Roll NoO.....cree0%" Sr. No. of Question Paper: 1546 G Unique Paper Code : 2342011101 Name of the Paper : Programming using Python (DSC-1) Name of the Course + B.Sc. (H) Computer Science Semester ak Duration : 3 Hours Maximum Marks : 90 Instructions for Candidates 1. Write your Roll No. on the top immediately on receipt of this question paper. 2. Section A is compulsory. Attempt any 4 questions from Section B. 4. Parts of a question must be answered together. > PEO. 1546 2 1. @) Give the pseudocode or largest of three numbers, @ x/z (i) x+y Gi) [3] (cz Determine the output of following code, State the values of mand sum for all iterations, (3) | n, sum = 371, 0 i while n > 0: sum = sum + (n % 10) ** 3 n=n//10 print(sum) lain 3 Ss vailable for o access modes ® ailable ny two a e ia) Explain anY ae - S ng in python. Use S le examples. file handling P : the following code snippet QB) ne output o} {¢) Determil 2 = ‘ihleD fo ytisrevinU! mysir myStr = myStr(: :-1] print(myStr + “+ '110007') print(len(mySt)) ( Write a function studentData(n), that returns a dictionary with keys as the student roll number and value as student name. The function should accept roll number and name, for m students, as input from the user, Example, the returned dictionary should look like : {101:'Sahir’, 192: 'Sam’,...} (S) PTO; iS uf 1546 4 5 (B) In the iven code snippet, state ont 1546 eo ae Value Qe after execution of each statement a a @o-tey LI = [10, 20, 30,20) = asymmetric_difference(b) L1.append(s0) Gi) © set of Bond) (p, Write a function factors(nt) that returns a set iy, Write a “ L1.remove(20) ‘all the factors of the number nl. print(L1) | ! 1 SECTION B + (L1.extend(‘aroma') ] ene paar) 2. (a) Write a python program which contains the following functions : ” (B) Consider sets a and b: @) @ readflle(file1) that prints the total number a= (5, 12, 33, 14, 55} of lines present in file file. b = {101, 13, 14, 55, 16} Gi) copy(filet, file2) that copies even lines of ‘ t! - Find the value of ¢ for each of the following the file filel in file file2, statements : P.T.O. | Lhe & | RIF he 3. (@) Fi Find the output of the fol following code, d= {RED':4, ‘GREEN’; 14, "BLUE. 24} dkeys = list(d.keys()) % print(dkeys[(0}) print("blue’ in d) d['ORANGE'] = 12 d['GREEN’] += 10 print(d) process(stri) that performs the (10) following @ Calculates the frequency of each character ne eee type. print this dictionary. i) Function should return the string which has | the words in the reverse order. Example: if strl = ‘Best of luck Savital’, the function should return the string 'Savita! luck of Best’. 4 ‘ (@) State the value of y after each step: oO ¥ += x{9] + x[-9] P.T.O 1546 8 9. Ace 6 7 y <= x[-5] + x13] + 154! y(listh) po =< PP — += x15} + x12] + x2] opy(tist!) es as = e097 OPP ypartition(’ ) we Be a 1ist3(0) = in _§ + “join(y12] split’) 2 Sal 2 yestt2) (0) = 75 5 ns i 1 ind ond justify the values OF listl, list2 a1 =e (Describe the following string functions wi ist es examples = a a @ (b) Generate a list containing the cube of the odd Eo © capitalized) | a | numbers from 1 to m, using = (8) GO isdigitO ( 2 user-defined function myCube(m) be (Gi) upper) (i list comprehension _ Gv) isalpha() B 6. (a) Determine the output of the followi lowing code: = 5. (gf Consider the following set of statements : Se wy=45 oe import copy pos. So um = listl =[ 1, 2, [ 3, 4 - £3, while (y > 0); § P.T.0. fore Z 2) Oves [[ 3) tee 1546 10 : if (y & 1) 1546 grays) sum = sum + x print 133) rax<<1 prin(t-count(7) yry>t ; s2iytol- § prin, 9 [ae miata) 13 = tl + tuple(India’) (®) Write a program that does the following checks | on the age entered by the user: ® © age should not contain alphabets or speci characters (i) age should not be Jess than 21 Raise and handle appropriate exception(s). (@ Compute the output of the following code: th= d, 2, 3.7, 9, 05,7) 12 = (23, [24, 25]) print(t3) (©) Define a class Drone that contains following data (8) members : Instance variables: droneld - id of drone Class variable: totalCount - for keeping count of all the drones manufactured ‘The class should contain the following methods: @ i '—O ~ initialize data members and increment totalCount (i) getldO ~ returns droneld P.T.o. 1546 12 (iii) getTotalCount() - returns ‘to (iv) _del_() - to destroy ne decrement the totalCount

You might also like