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

Python 2023

In this document... You can find the pyq of Masters of Operational Research (delhi University)
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)
6 views

Python 2023

In this document... You can find the pyq of Masters of Operational Research (delhi University)
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/ 4
‘on paper contains four printed pages. Master of Opers Your RollNo. 22 I2WEDEtoIo al Research (MOR), SEM 1, 2023 je- Python Programming (UPC:223601105a) (N.Gx ~ Admission of 2019 nnd onwards) ‘Time: 3 Hours Write your Roll No, On the top imm . (Answer 1. Saf Explain the significance of “Sequence” ‘considered as a sequence? Stelain binary left shift and binar y Fight shift operators. Explain the same for number 29 when itis eM shifted by 2 and right shifted by 2. a Q) Course ~ MORLOS(a), Paper Tit BF Write the salient features of python programming language aN ‘What are negative indexes and why are they used? ay Jiri ‘between the following, Q. re.search () and rematch () find ( and index £4F When to use tuples in Python, Give some examples of programming situations mentioning its usefulness, @ _Ja What is the significance of NumPy library in Python? What advantages do NumPy arrays offer ‘over (nested) Python lists? @ 26 Write a program to calculate in how ‘many days a work will be completed by three persons A, 'B and C together. A, B, C take x days, y days and z days respectively to do the job alone. The formula to calculate the number of days if they work together is xyz/(xy + yz.+ xz) days where x, y,andzare given as input to the program. @ wo fo print (var) ip def findValue( vall = 1.1, val2, val3): final = (val2 + val3)/ vall print(final) findvalue() cor or runtime error with the help of examples. (2) Oo A Differentiate between syntax error, logical err = strate its usage. Aowrat is the significance of a“pass” statement? Demons Page 10f4 . 3. Covi ¢ the relationship between a define a class, Programming, aN Explain your answer. Seni the output of the following code: val while var> 0; print(Current variable valuc:, var) var = var - 1 . ifvar==3: break else: ifva var = var - continue print("Good bye!") Consider the following string mySubject: mySubject = "Operational Rescarel ‘What will be the output of the following string operations? i. printGnySubject[O:ten(nys ii, print(mySubject(::2)) iii. print(mySubject{len(mySubject)-1]) print(mySubject{::-2)) print(mySubject{:3] + mySubject{3:]) vi. print(mySubject.swapcase()) jee) I What will be the output of the following Python code? while i<10: prin(("\n Continuing wit", ) continue and i== 10): prin(("\n Breaking on’, i) break print(i, end print("\n Done") ire Lambda functions? Describe. What (Explain the working ofthe following code and find the output. ?- inpul(‘Enter a non-zero value: ') while num == 0: rum = input(Enter a non-2er0 vale) num Page 2 of 4 ass and object? Write a program wnich shows how to Tow to access member Functions and how (0 create and access objects in python @) With the help of an example, differentiate between Seties and DataFrame in context of Panadas, Q) @) @) @ @ 2) pS Erptin the usage of recursion a iteration as two separate and yet connected approaches of problem solving, G) grMais a zip function? Explain itu ngan example, 0} 5. (@) Explain the following code and find the output @ lass Time: det _ init__(self, hours, minutes, seconds) selfhours = hours selfaminutes = minutes > self'seconds = seconds def add_time(self, duration): opera_hours = selfthours + duration. hours ‘opera_minutes = selfminutes + duration.minutes ‘opera_seconds = self.seconds + duration.seconds while opera_seconds >= 60: ‘opera_seconds = opera_seconds - 60 ‘opera_minutes = opera_minutes + 1 while opera_minutes >= 60: ‘opera_minutes = opera_minutes - 60 opera_hours = opera_hours + 1 print(f*Opera ends at {opera_hours);{opera_minutes}:{opera,_seconds}") def main() opera_start = Time(10, 30, 30) ‘opera_duration = Time(2, 45, 50) opera_start.add_time(opera_duration) if__name_ ‘main() (b) Write the output of the following code. (2) jport numpy as np p.array({9,11,19,1,17,5,24D print(b) bool_arr=b>9 print(bool_arr) new_arr = b{bool_arr] print(new_arr) (©) Write a program that will generate a random password, ‘The program should take input as, number of letters, symbols and’ digits one would like to keep in the password, and then the code will generate a random password each time the user inputs the arguments. @ (@ With the help of an example explain the significance ofthe_init__ method. ay Page 3 of 4 (©) Following information about three students is provided in the form of dictionary of lists Create a dan tte” L23}, “Totas]350.5 400,420}, "Percenage"{70,80,84] } Teale a dataframe and write the required set of statements in order to have this information in a {abular manner, Write the output as well, w ©) Write a program to plot a bar chart in python to display the pass percentage of Department of Operational Research for five consecutive years for the given dat Year Pass Percentage 2019 98.50 2020 70.25 2021 $5.20 . 2022. 90.50 2023 96.58 @ rt Tow multiple inheritance is different from multi-level inheritance? Explain with the help of example. Q (Mite amgnu driven python program to perform various list operations, such as: @ _Aehpbend an clement G1 Insert an element 4, Append a list to the given list 48. Modify an existing element Delete an existing clemert from its position LreDelete an existing clement with a given value “pit: Sort the lis in ascending order “Aili. Sort the list in descending order (Hint: Say your list has 5 elements: [24, 3, 86, 15,7) What is the purpose of using function in python programming? Give the syntax of defining a ction in python. @ page 4 0f4

You might also like