Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
30 views17 pages

Python Question Paper

The document outlines a series of examination questions for an Introduction to Python Programming course, covering various topics such as file handling, object-oriented programming, and Python data structures. It includes questions on file operations, exception handling, and the use of modules like shutil and shelve. The exam format requires students to answer five full questions from different modules, with a focus on practical programming skills and theoretical understanding.
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)
30 views17 pages

Python Question Paper

The document outlines a series of examination questions for an Introduction to Python Programming course, covering various topics such as file handling, object-oriented programming, and Python data structures. It includes questions on file operations, exception handling, and the use of modules like shutil and shelve. The exam format requires students to answer five full questions from different modules, with a focus on practical programming skills and theoretical understanding.
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/ 17
eed Ee <€ Posts Dist Semester B.E/B.Tech. Degree Exam Introduction to Python Pr Or Pome eL 0 in function DivExp and raise an exception rib b= 0. Develop.a suitable program which reads two values from le and calls 2” function DivExp. q o) L oa - Module —5 = Q9 Ja Define a class and object, construct the las¥ called rectangle and initialize | ® it with height= 100, width = 200, starting point as (x = 0, y.= 0). Write a program to display the center point e.ondinaes ofa rectangle ed concept oteoni pe ‘copy module cn an example. 6 5 cO4 Esa the concep oF nba Wik an carpe [s 5 cos OR Q.:0 | a. SBatine 2 Taner vich wakes two obj and returns lex number with # addition of two complex numbers. Define a suitable class ‘Compl represent the complex number. to read Ni 2) complex numbers and to compute complex nui Fepresenting complex numbers | 8 | L2 | Explain ——init__() and —str__() method with examples. - 6 cos Briefly explain the printing of objects with an examples. 6 Coa x aaa 7 2of2 CMRIT LIBRARY BANGALORE - 560 037 Qu Q3 £2 Qa [i TWrite « python pap Kifst Semester B.E/B.Tech Degree Examination, Ju Introduction to Python Programming Note: I. Answer any FIVE full questions, choosing ONE full question from eich mod: 2M: Marks, L: Bloom's level , C: Course outcomes Module - 1 x fh operatowy uséd in Python with exaniple, a, | List and explain m b. | Writ k whether the number is even or odd. ' Python program. el = | With an example expllip user defined functions 7 OR ‘a. | With an example €xplain the following buillsin functions i) prim) ii) input) i) Lenk ) B | How to handle exceptions in Python explain with agiefampe | Write a program fo pri Even numbers using Siepize in a Module —2 cy ‘a. | Explain the fallowing list methods with examples. index( ), -append(), nsert( sort), sreyerse( ) n to create a distidnary of 10 key-value pairs and print only keys On the screen. | explain in ded pot in operatorsised in Tits wih an example = OR ‘a | Show that lists are mutable, wy Wrie a program 1p count the frequency of characte using module Print (Pretty Putting) . | Explain randdmthoice and random shuffle functions with lists. e/Suly 2023 6 Max. Marks: 100 i BPLCKB105/BPLCK105B cor cor Col cor cor col €02 Oz coz coz coz C02 Qs _ Module 2. | Write the output of following Python code )>>>Spam{0] ii) >>Spam(4] iti) >>>Spam(-1 v) Spam{0: 5] v)>>> Spam |:5] _ vi) >>>Spa >Spam = "Helio, World 6 [LI | CO3 |b. | Write a program to accept string and display totaligumber of alphabets. 6 1/13) co3 | Explain how to save variables with the Shelve, module 8 Li Cos] a < «2. | Explain the following string methods with examples 10] LI | C03 Q6 i) isalpha() i) isalnum( ) i) isdcimial( ) iv) isspace( ) )istile( ) b:] Write a Python program thatertpeatedly asks users foPtheir age and a| 6 [13 | CO3 Password until they provide Valid input. [age is in digit and Password in alphabet an digit only}, |e] Differentiate between Absolute and relative paths in specifying file paths. | 4 | 12 | CO3 ea Module 4 a. | Show that files and folders can be copied using Shutil module ¥ [LI | Cos b. | Write oinot®n Raising exceptions in Python. 7/11 | Cos ‘| Expliin five buttons available iq thé Debug Control Window vs [2 [cos — OR ae a. | Describe logging levelused in Python to“categorize log messages by | 10] L2 | CO4 importance. b. | With example show how files and folders Gan be permanenil 10) L1 | Cos Qo Q10 ___“Module~5__¢ ‘a, | Write @jprogram to implemen the following object diagram and its] 10) L3 | COS functionality as shown in Fig %a). Initialize whe attributes through a ‘constructor and print the satme [wank 00! s Fig.Q9(a) CMRIT LIBRARY i. | Discuss operator overouding. Mention any five operators with respective | 10] 12 | COS special functions to be overloaded in Python —e OR ~~ a | Explain the following with an example [2] co# i) isinstanceG i) asatt, ) i) copy.copy iv) copy.deepcopy). b. | Write program to explain pure function and modifier fanction fa) cos CBCSISCHEME TTL BEDCKI0SB/BPLCKBIOS ester B.E./B.Tech. Degree Examination, Dec.2023/Jan.2024 Introduction to Python Programming ‘ ‘Max. Marks: 100 eT a ecm cet NS ft nein frm wh 2M: Marks, L: Bloom's level, C: Coe outcomes. _ % f ~ ie M Qi [a | List and explain the use of rin python, Write the’step by | 6 step execution of the following re in python, 32° 4+3+(10/4)*3 -2 L| Li) c coi © ga eo a, 16 os, oi wig pp Hm and 6 | 12) cor examples = nerap + pyle pan Wo Ss ie ag ed cheats oF # | 13) Cor) “| ccnp the valu a nd print he eels, OR G2 |. | Explain the sting concatenation and string replication operator with an] 6 | L2| Cor | | example. « ) | Explain local and ba spot wb with xeegumle [6 | t2) cor, = Develop « program to feadthe sadeat details Like Name, USN and Matis [® | L3 [COI | in three subjects Disha the den deal, tol marks and per=nage with suitable messages. | ie : ; | ~~ | [QS [a What is list? Caine nce of ng nan wil eae Te] 12] coz oe Se a oO ¥ | 12 | Coz) sort(), count) and pop. cad N numbers figmvthe console and djeate’a list. Develop a program to | 6 print mean, variance and standard deviatioff With suitable message. & gl fea Ta, | Define tuple data type? List out the difference between tuple and list | 6 | 12) coz} \b. | Identify and explain the @ietionary methods like get( ), item(), keys( ) and | 8 | L2 Cor | values () in python with examples. “Te Develop @ python program to swap two numbers without “using Intermediate variables. Prompt the user for input | | 5 cos — todule-3__ OS | a | Write the output of the following i) *HeLLo* -upper( ) « isupper () | fi) “HeL.Lo’ -upper() -lowert ) | | ii) *_* -Join("There can be only one'-split() ) fo. W ith exampl . weexusnn cD 6 [i2| Cos" RC [Qa [a.| Make use of the concept process with suitable python programs: hm —— ee Te. | Develop a python program to count the total number of vowels, consonants | 8 “Tb. T Explain the concept of file path, also discuss absolute and relative paths. 4 Briefly, explain saving variables with shelve module pe Modale— 4 __— “ _____ Explain the following file operations in python withsuitable examples. i) Copying files and folders | ii) Moving fies and folders iii) Permanently deleting files and folders Thc) List out the benefits of compressing file with zip file module, also explain | 8 | the coneepts of walking a directory tree. Tet Liat Bar the difference between? shutiLeopy( ) and shuti.eopytree( ) 6 methods. st + gx Tas Biety explain Assertion and aiing a exception ~T6 4 t bb. | Develop a python program with a function named DivExP which takes two | 8 | parameters a, b'and returns a value C, (C= a/b). Write suitable assertion for | a> 0 in function DivExP and raise,on exception for when b™ 0. Program | hhas to read two values from the console and call a function DivExP. fo Ja.) Define classes and objeets in Pytho ‘Consifuct the class | and initialize it with eight = 100, width= 200, starting point as (x = 0, SY = 0) and write the method to display the center point coordinates of J ~ BANGALORE 5 ‘and __str( )__ method with examples. “Q.0 | a. | Explain the term ot jjects are mutable with an example. |b. | Explain the concept of iymorphism with examples is 13) COs) 12 | os) 13 [Cos | rectangle, r Briefly explain the concept of prenolyping and planning CMRIT LiBARY | 12 | Coa [12 cos | 1 | | BPLCK20SB/ i tion, Dec.2023/Jan.2024 2 /. Introduction to Python Programming Tin: 3Vhrs. Max. Marks: 100 Note: 1. Answer any FIVE full questions, choosing ONE full question from each module. 2. M: Marks, L: Bloom's level, C: Course outcomes. Me Ly c Q.1 | a. | Explain Local and global variable and scope of variable in python. 7 Li cor at comparison and Boolearfoperators. | 8 | LI | CO1| cor) | Tb. | List and explain with example differei % Write a python program to generate Fibonalli sequence of length ‘n" | Q2 Ja. | List and explain with syfitax and example the flow control statement in | 10] Li | COI python | . Demonstrate With Example print( ), input(.) and string replication function | 6 | L2 | COL | in python. %. Develop a program to read the name and year of birth of a person, Display| 4 | L3 | CO1| weather person is senior citizen or not? Oo ~Module=2 = ____| a What is a list? Explain append( ), insert( ), and remove methods with | 10] Lt | CO2 example |b. | Explain the methods of list data types in python for the following | 10| Li | CO2 ‘operations with suitable code snippet for cach. i) Adding value to list ii) Remaining value from list iii) Finding a value ina list iv) Sorting the value in a list vy) Reversing a value in list R ‘a J Explain get( ), Wem( ), Keys ) and values() methods of dictionary in] 8 | L2 | COZ python. |} bow is tuple different from list? Which fiction is used to convert list to | 7 Li) coz) tuple? | Te. Differentiate between list and dictionary. a 5 | L2| Coz — c Module-3 Qs Explain the syntax and example various string methods [7 | Li | cos Tb. 7 Discuss the fallowing methods of OS module a Te L1/ cos i) chdir( ) ii) rmdir( ) ii) walk( ) iv) list dire ) Je. | Read multidigit number from console. Develop “a program to print |S | 13 frequency of occurrence of each digit with suitable message, —OR_ Ae - @6 | a. Explain Pile reading and writing process with suitable python program. 7 13) Cos With code snippet, explain saving variables using shelve module ‘and |6 | 12 | CO3| prini( ) and print format( ) functions. | ‘e. Write a python code to implement multielip board project in python. 7 13) cos) | | - - _ Module —4 —~ ___| Explain the functions of shutil module with example. 10] Li] €O3 "What is meant by compressing files? Explain reading, extracting and | 10 }Li | cos | crating zip files with code snippet | | | OR Explain the folowing file operation in python with example. oyu i) Copying files and folders ii) Moving files and folders ) Permanently deleting files and folders Define assertions. What does afl assert statement in/python consists of? |7 | Lt | CO3 Give an example. Develop & program W sort contents of a text file and write the forted Wi content into a separate file bj) __Mpdgi@='$__,__ ~ Explain operator overloading and polymorphism with example. 7 1b, Explain the concept of pure functions and modifiers with python code, 7 ba ~v_ | ‘c. Write a function called print time that takes a print itinthe |6 | 13) Cos form of hour: minute: second? object | CMRIT LIBRARY \ BANGALORE 500037 | | +r — _OR_ = O10 | a. | What is clay? How do we define class? How class members are accessed, | 6 | LI | CO# explain with examples. | b.| Explain ~ ini( ) and — st) method with an example. is TL cos ‘c. | Discuss type based dispatch in python. 16 (Li) Cos Introduction to Python Programming Max. Marks: 100 ations, choosing ONE full question from each module. Bloom's level . Module =1 IM[L]| ¢ ‘tring Feplication operation with an| 06) L1| COI string concatenation |__| example. WA _| |_| [b. | Illustrate the use of break and continue With example {os 13 | Cor, «. | Write a Python program to check-Whether the given number is positive, oe] tr] cor | negative or zero. OR Q.2 | a.| What are functions in'Python and how they arésdefined and used to] 06| Li | CO2 modularize code? {[b. | Explain the local aid jlobal scope with local and global variables. ‘c. | Write a program to generate Fabonacei sequence of length (N). Read N| 06 | from console — Module =2 Q3 |a.| What are lists in Python and how. they used to store and manipulate | 06 [ L2 | CO3 || collections of data. . | Explain any four built-in methods available for working with Read N numbers from console afd create a list. Develop a program torptint | 06 | L2 | CO2 =| the mean of numbers. OR ifferentiate Between lists and dictionary. Explain with example keep( ), values( ) and’items( ) methods. Toe | 1: @ program to.adl elements into dictiofary using while Iodp. [06 | 12 | co2 . - Module 3 oo @Q5 | a. | Explain any five built-in methods available for working with string along | 10| 1.2 | co3 with example. Th. ] Read a mutti-digit number (a3 chirs) from console 10) 12) Cos | print the frequency of each digit with suitable example. | OR Q.6 | a. | Explain the file readicigiahd writing process with suilable example [ie] 12 | cox b. | Illustrate the role of shelve module in working with files 10) L2 Cos Moduile — 4 Q.7_| a. | Fxplain the fuietions of shutil module with examples. [10 [12 [eos bb. | What is meant by compressing files? Explain reading, extracting and | 10/12 | CO3 |__| creating ZIP files with code snippet fe =» OR - ‘QS |. | Explain the buttons in the Debug control window. eT rr | Gos Hitiiraontig sep ita e03 _ Module—S Q9 [a | What do you mean by’class, object and attributes? Explain with example. | 08 cou [ilustrate the concept of inheritance and class diagrams with example. 12/12) cos} OR _ = iy four object oriented characteristics possessed by | 08 | L2 | CO4 Q.10 | a. | List and_expl | Python. b. | Briefly-discuss the importance of along with example. cor it__() and __str__() methods | 12 22: Model Question Paper-I with effect from 2022-23 (CBCS scher OD USN First/Second Semester B.E. Degree Examination Introductionto Python Programming TIME: 03 Hours Max. Marks: 100 Note: 01, Answer any FIVE full questions, choosing at least ONE question from each MODULE. *Bloom’s Module -1 Taxonomy | Marks Level QO01_]@ | With Python programming examples to cach, explain the syntax and control a i flow diagrams of break and continue statements. Explain TWO ways of importing modules into application in Python with b oe syntax and suitable programming examples. © Write a funetion to calculate factorial of « number. Develop a program to * oe compute binomialcoefficient (Given N and R). - I OR 1Q02- Ta | Explain looping control statements in Python with a syntax and example to D mi cach. 'b Develop a Python program to generate Fibonacci sequence of length (N). Read “a o4 N from the console. ‘¢ | Write a function named DivExp which takes TWO parameters a, b and returns value ¢ (¢=wb). Write suitable assertion for 2>0 in function DivExp and raise an exception for when b=0. B 06 Develop a Python program which reads two values from the console and alls a | function DivExp, Explain FOUR scope rules of variables in Python 2 om “Module-2 OOF [a | Explain witha programming example to cach (ai) gett) 2 06 (ii) setdefaul) 'b | Develop suitable Python programs with nested lists to explain copy.copy( )and | 4 8 < ) methods. ¢__ Explain append() and index() functions with respect to lists in Python. [FI 06 OR QOt [a | Explain different ways to delte an element from a list with suitable Python D o syntay and progammning examples, 'b | Read a multi-digit number (as chars) from the console. Develop a program to Lb oe ‘print the frequency of cach digit with suitable message. ‘| Tuples are immutable. Explain with Python programming example. D2 a Module-3 05 [= | Eagan Prion sing Raling tio wih example drwy Db to Ijust(), center), Itrip() {Explain rcading and saving python program variables using shelve module D ve with suitable Python ¢ _ Develop a Python program to read and print the contents of a text file. ub oF OR 006 [a | Explain Python string handling methods with examples: join), D 0 startswith()riust(), strip), rstrip() — Explain with suitable Python program segments (I) ox path basename) (i) ie oe path join) 2 ‘© | Develop a Python program find the total size of all the files in the given B o a directory. Module-4 Q07 Ja | Explain permanent delete and safe delete with a suitable Python programming example to each. ke b | Develop a program to backing Upa given Folder (Folder in a current working Db directory) into a ZIP File by using relevant modules and suitable methods. 3 © [Explain the role of Assertions in Python with a suitable program. DB OR @ 08 | a | Explain the functions with examples: (i) shutil.copytree() (ii) shutil.move() ry (iii) shutil.rmtree(). B | Develop a Python program to traverse the current directory by listing sub- D folders and files = © [Explain the support for Logging with logging module in Python oy Module-5 @ 09 ]a | Explain the methods —init_ and __sir__ with suitable code example to 7 each, 2 B | Explain the program development concept ‘prototype and patch’ with suitable D example. 2 © | Define a function which takes TWO objects representing complex numbers and returns new complex number with a addition of two complex numbers Define a suitable class ‘Complex’ to represent the complex number. L3 Develop a program to read N (N >=2) complex numbers and to compute the addition of N complex numbers. OR Q.10 Ja | Explain the following with syntax and suitable code snippet i) Class definition ii) instantiation iii) passing an instance (or objects) as an L2 argument __ iy) instan return valu b | Define pure function and modifier. Explain the role of pure functions and modifiers in application development with suitable python programs. *Bloom’s Taxonomy Level: Indicate as L1, L2, L3, L4, etc. It is also desirable to indicate the COs and attained by every bit of questions. aK CBCSISCHENE | ] BPLCK105B emester B.E/B.Tech. Degree Examination, Dec.2024/Jan.2025 Introduction to Python Programming Max. Marks:100 Note: J. Answer any FIVE full questions; choosing ONE full question from each module. 2. M: Marks , L: Bloom’s level, C: Course outcomes. I Module —1 MIL] Cc [71 | @ | Explain basic data types like int, float, double and string with an example. 6 |12/ Cor [ b. | Differentiate between local scope and global scope. ~6 | L2/ COI ©. | Develop a program to caleulate factorial of a number. Program to compute | 8 | L3 | COT binomial coefficient (Given N and R). OR 2] a | Define functions. Explain how to pass pa | retum statement. 'b. | What is exception? How exception are handled in python? Write a programto| 6 | L2 | COI solve divide by zero exception. |__| © | Develop a program to generate Fibonacci sequence of length (N). Read\N| 8 | L3 | COI from the console. | ers through the function with| 6 | L2 | COI Module =2 [3 [a [Explain Augmented short hand assignment operators with an example, a COZ b. | Explain different type of methods like append( ), Remove( ), sort( }, pop()in | 7 coz python programming list. | | ©. | Develop a program to find mean, variance and standard deviation 6 | 13) C03) OR > 4 | a. | Explain set() and setdefauit( )method in dictionary. [7 [2 [coz ’b._| Develop a python to print area of rectangle. 6 | 13 | Coz) c. | Define pretty printing. How does pretty print work in python with an example. | 7 | L2 | CO2| iv) Lower | v) Upper vi) Replace with an example. | ®. [Develop a python code to determine whether given s not a palindrome. . | Explain :i) isalpha ii) isalnum iii) isspace( ). ing is a palindrome al 6 | 13) CO3 | Lof2 Td 14/18 BPLCK105B OR 6 | a. | Explain OS path module with an example. 6 | 13 | CO2 _ | Explain the concept of file path. Also discuss absolute and relative file patha | 8 | L3 | CO3 c._| Program to print of multi clipboard with appropriate message. 6 | 13 | Cos Module —4 7] a. | Develop a program to backing up a given folder (folder in a current working] 6 | L3 | CO4 directory) into a zip file by using relevant modules and suitable methods. b_ | List out the difference between shutil.copy( ) and shutil.copythree() method. | 6 | Li | CO4 c. | Explain the following file operations in pythons with suitable example : 8 | L2| COs i) Copying files and folders ii) Moving files and folders iii) Permanently deleting files and folders. OR 8 | a. | Briefly explain assertion and raising a exception. 8 [12] Cos b._| List out the benefits of using logging module with an example. 6 | L1 | Cos c. | Write a function named DivExp which takes two parameters a, b and retumsa| 6 | L3 | CO4 value C(c= a/b). Write suitable assertion for a 70 in function DivExp and raise an exception for when b = 0. Develop a suitable program which reads two values from the console and calls a function DivExp. Module —5 9 | a. | Define a function which takes two objects representing complex numbers and | 8 [L3 | COS retums a new complex “number with a addition of two complex numbers. Define a suitable class ‘complex’ to represefit the complex number. Develop a program to read N(N >= 2) complex numbers and compute the addition of 10 complex numbers. b._| Explain the concept of inheritance with an example. 6 [12 {COs ©. | Explain the | str _ and the_init_ method with an example. 6 | L2| COs OR BANGALORE - 560 10 | a. | Define a class and object, construct the class called rectangle and initialize it] 8 | L3 | COS with height = 100, width = 200, starting point as (x = 0, y = 0). Write a | program to display the centre pint co-ordinates of a rectangle. b._| Briefly explain the printing of objects with an example. 6 | 12) Cos Tre. | Differentiate operator over loading and operator overriding in python. 6 | L2| COs vee RESIS GH ENE USN \ BPLCK105B/ BPLCKE Go rinses Times 3.4. Max. Marks: 100 Note: 1. Answer any FIVE full questions, choosing ONE ful 2M: Marks , L: Bloom's level , C: Course outcomes. Module—1 MIL] < Qi [a. | Define compar and its type. Give the difference | 4 /L1 | Cor ween == and = opt b. Explain flow control stat detail with if, else, whi 10 12 Cor e. Build a fimetion to ealeula al mber. Di 6/13 / Cor OR Q2 [a | Define € in python programmi give i 8 /LI | cor ception handling b th bb. Explain ho’ nction and to make a functio 4/12) Cor argument with an example « D hon program to ind year of birth of a p 8/3) cor and to display whether the person i Module —2 Q3 | a. Explain in detail about append( ) and index( ) function w 6 [2 | Cor b. | Develop suitable python m with nesied list to explain copy) and | 6 | L3 | CO2 deepeopy( ) method: ©. | Tuples are ble. F with an ex 8 12 Cor OR Qa | a. | Explain the below methods in list with suitable cod 6 [12 | Coz b. Outline dictionaries with some of their method 8/12) €o2 c. | Explain Nested dictionaries with an examp! 6/12) Coz Qs Qe Qo Q.0 BPLCK1 Module — 3 Develop a code to print to most frequently appearing words in a text file Explain below python string handling function with example i) split( )- i) rjust( ) ii) partition( ) iv) join( )v) startwitht ), OR Explain the method to restore the data to variable from the hard drive tent file and write the sorted am 10 sort the contents of Develop a prog Module ~4 Explain various shell utilities function -am to read and to extract all the files and folder into a ZIP Develop a pro levant methods. OR delete and safe delete with a suitable python Explain perman Define Assertion. Explain the use of Assertion in a Traffic light simulation Module ~§ Define pure function and modifier. Explain the role of pure function and in development. ifier applic: Explain the methods _int_ and _str_ with example, CMRIT LIBRARY OR e in with suitable python program. Define operator overload Expl Define polymorphism and gi able pyth 0 0 0 10 10 10 10 C03 CO3 C03 C03 cos cos CO3 CO3 CO3 CO3 cod cos ao \ BPLCK20SB / BPLC@RINA MEST Second Semester B.E./B.Tech. De ation, June/July 2024 Introduction to Python Prog: mming Modut BPLCK20SB / BPLCKAQMMRSIMESD 10 13 \¢ 0) 12) ce or 07 12 | cos 1 0.

You might also like