🎧 New: AI-Generated Podcasts Turn your study notes into engaging audio conversations. Learn more

Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...

Full Transcript

41 1:- Which method is used to check if a file exists before trying to open it? a) file_exists() b) is_file() c) exists() d) os.path.exists() D 2:- How do you write data to a file in Python ? a) write(data) b) append(data) c) file.write(data) d) insert(data) C 3:- What mode is used to open a file...

41 1:- Which method is used to check if a file exists before trying to open it? a) file_exists() b) is_file() c) exists() d) os.path.exists() D 2:- How do you write data to a file in Python ? a) write(data) b) append(data) c) file.write(data) d) insert(data) C 3:- What mode is used to open a file for reading in Python ? a) w b) r c) a d) x B 4:- Which function is used to read a single line from an open file? a) read() b) read_line() c) readline() d) getline() C 5:- Which function is used to open a file in Python ? a) open_file() b) read_file() c) file_open() d) open() A 6:- Which method is used to set the position of the file pointer within an open file? a) file.seek() b) file.move() c) file.position() d) file.set_pointer() A 7:- How can you list all files and directories in a directory using Python ? a) os.list() b) os.list_all() c) os.listdir() d) os.get_dir() C 8:- What is the purpose of the 'os.path.isfile() ' function ? a) It checks if a file exists. b) It checks if a path points to a regular file. c) It checks if a directory exists. d) It checks if a path is empty. B 9:- Which method is used to extract a file from a zip archive using the 'zipfile' module ? a) extract() \ b) unzip() c) get_file() d) open_file() A 10:- In Python, which module is used for working with compressed (zipped) files? a) zipfile b) compress c) gzfile d) pyzip A 11:- What is the purpose of the 'xml.etree.ElementTree' module ? a) It provides functions for manipulating XML files. b) It is used for reading and writing JSON files. c) It helps in parsing HTML documents. d) It provides tools for working with XML data structures. D 12:- Which module is commonly used for working with XML files in Python ? a) xml b) lxml c) xmlparse d) pyxml B 13:- What is the purpose of the 'json.load()' function? a) It loads a JSON file into memory. b) It writes data to a JSON file. c) It converts JSON data to a Python dictionary. d) It encodes JSON data. A 14:- Which method is used to write a Python dictionary to a JSON file? a) write_json() b) dump() c) write_dict() d) save_json() B 15:- Which module is used for working with JSON data in Python? a) jsondata b) jsonlib c) jsonutils d) json D 16:- How can you read and write binary data from and to a file in Python? a) Using the 'rb' and 'wb' modes when opening the file. b) Using the 'binary' mode when opening the file. c) Using the 'br' and 'bw' modes when opening the file. d) Using the 'read_binary' and 'write_binary' methods. A 17:- What is the purpose of the 'os.path.exists()' function? a) It checks if a file exists. b) It creates a new file if it does not exist. c) It retrieves the size of a file. d) It reads the contents of a file. A 18:-Which function is used to delete a directory in Python? a) os.remove() b) os.delete() c) os.rmdir() d) os.dirdelete() C 19:- is the purpose of the csv.reader() function from the csv module? a) It reads the entire CSV file into memory as a string. b) It reads a single line from the CSV file. c) It provides a way to iterate through the rows of a CSV file. d) It reads binary data from a CSV file. C 20:- which module is commonly used for working with CSV files? a) csvmod b) tablib c) tabular d) csv D 21:-Which method is used to write binary data to a file in Python? a) write() b) writebinary() c) writebin() d) writebytes() A 22:-What is the purpose of the' with' statement when working with files ? a) It specifies the encoding of the file. b) It ensures that the file is automatically closed after use. c) It opens multiple files simultaneously. d) It renames the file. B 23:-Which method is used to read a single line from an open file? a) read() b) readline() c) readlines() d) line() B 24:-Which mode should be used to open a file for both reading and writing without truncating a) 'r' b) 'w' c) 'a' d) 'r+' D 25:-Which method is used to write a string to a file in Python? a) write() b) append() c) insert() d) save() A 30 1:-Which of the following commands will create a list? a) list1 = list() b) list1 = [] c) list1 = list([1, 2, 3]) d) all of the mentioned D 2:-What is the output when we execute list(“hello”)? a) [‘h’, ‘e’, ‘l’, ‘l’, ‘o’] b) [‘hello’] c) [‘llo’] d) [‘olleh’] A 3:-Suppose listExample is [‘h’,’e’,’l’,’l’,’o’], what is len(listExample)? a) 5 b) 4 c) None d) Error A 4:-Suppose list1 is [2445,133,12454,123], what is max(list1)? a) 2445 b) 133 c) 12454 d) 123 C 5:-Suppose list1 is [3, 5, 25, 1, 3], what is min(list1)? a) 3 b) 5 c) 25 d) 1 D 6:-Suppose list1 is [1, 5, 9], what is sum(list1)? a)1 b) 9 c) 15 d) Error C 7:-To shuffle the list(say list1) what function do we use? a) list1.shuffle() b) shuffle(list1) c) random.shuffle(list1) d) random.shuffleList(list1) C 8:-Suppose list1 is [4, 2, 2, 4, 5, 2, 1, 0], Which of the following is correct syntax for s a) print(list1[2:]) b) print(list1[:2]) c) print(list1[:-2]) d) all of the mentioned D 9:- Suppose list1 is [2, 33, 222, 14, 25], What is list1[-1]? a) Error b) None c) 25 d) 2 C 10:-Suppose list1 is [2, 33, 222, 14, 25], What is list1[:-1]? a) [2, 33, 222, 14] b) Error c) 25 d) [25, 14, 222, 33, 2] A 11:- Suppose list1 is [1, 3, 2], What is list1 * 2? a) [2, 6, 4] b) [1, 3, 2, 1, 3] c) [1, 3, 2, 1, 3, 2] d) [1, 3, 2, 3, 2, 1] C 12:-Suppose list1 = [0.5 * x for x in range(0, 4)], list1 is: a) [0, 1, 2, 3] b) [0, 1, 2, 3, 4] c) [0.0, 0.5, 1.0, 1.5] d) [0.0, 0.5, 1.0, 1.5, 2.0] C 13:-To add a new element to a list we use which command? a) list1.add(5) b) list1.append(5) c) list1.addLast(5) d) list1.addEnd(5) B 14:- To insert 5 to the third position in list1, we use which command? a) list1.insert(3, 5) b) list1.insert(2, 5) c) list1.add(3, 5) d) list1.append(3, 5) B 15:-To remove string “hello” from list1, we use which command? a) list1.remove(“hello”) b) list1.remove(hello) c) list1.removeAll(“hello”) d) list1.removeOne(“hello”) A 16:-Suppose list1 is [3, 4, 5, 20, 5], what is list1.index(5)? a) 0 b) 1 c) 4 d) 2 D 17:- Suppose list1 is [3, 4, 5, 20, 5, 25, 1, 3], what is list1.count(5)? a) 0 b) 4 c) 1 d) 2 D 18:-To which of the following the “in” operator can be used to check if an item is in it? a) Lists b) Dictionary c) Set d) All of the mentioned D 19:-What will be the output of the following Python code? def f(i, values = []): values.append(i) return values f(1) f(2) v = f(3) print(v) a) b) [1, 2] [1, 2, 3] c) [1, 2, 3] d) 1 2 3 C 20:-What will be the output of the following Python code? names1 = ['Amir', 'Bala', 'Chales'] if 'amir' in names1: print(1) else: print(2) a) None b) 1 c) 2 d) Error C 21:-What will be the output of the following Python code? names1 = ['Amir', 'Bala', 'Charlie'] names2 = [name.lower() for name in names1] print(names2) a) None b) a c) b d) c D 22:-What will be the output of the following Python code? numbers = [1, 2, 3, 4] numbers.append([5,6,7,8]) print(len(numbers)) a) 4 b) 5 c) 8 d) 12 B 23:-What will be the output of the following Python code? list1 = [1, 2, 3, 4] list2 = [5, 6, 7, 8] print(len(list1 + list2)) a) 2 b) 4 c) 5 d) 8 D 24:-What will be the output of the following Python code? def addItem(listParam): listParam += mylist = [1, 2, 3, 4] addItem(mylist) print(len(mylist)) a) 1 b) 4 c) 5 d) 8 C 25:-What will be the output of the following Python code? a=[10,23,56,] b=list(a) a=95 a=34 print(b) a) [10,34,56,] b) [10,23,56,] c) [10,23,56,] d) [10,34,56,] A 4 1:- What will be the output of the following Python code snippet if x=1? x2 a) 8 b) 4 c) 2 d) 1 A 4:- What will be the output of the following Python expression? int(1011)? a) 1011 b) 11 c) 13 d) 1101 A 5:- To find the decimal value of 1111, that is 15, we can use the function: a) int(1111,10) b) int(‘1111’,10) c) int(1111,2) d) int(‘1111’,2) D 6:- What will be the output of the following Python expression if x=15 and y=12? x&y a) b1101 b) 0b1101 c) 12 d) 1101 C 7:- Which of the following expressions results in an error? a) int(1011) b) int(‘1011’,23) c) int(1011,2) d) int(‘1011’) C 8:- Which of the following represents the bitwise XOR operator? a) & b) ^ c) | d) ! B 9:- What is the value of the following Python expression? bin(0x8) a) ‘0bx1000’ b) 8 c) 1000 d) ‘0b1000’ D 10:- It is not possible for the two’s complement value to be equal to the original value in a) TRUE b) FALSE b 11:- The one’s complement of 110010101 is: a) 1101:-10 b) 110010101 c) 1101011 d) 110010100 A 12:- Bitwise _________ gives 1 if either of the bits is 1 and 0 when both of the bits are 1. a) OR b) AND c) XOR d) NOT C 13:- What will be the output of the following Python expression? 4^12 a) 2 b) 4 c) 8 d) 12 C 14:- Any odd number on being AND-ed with ________ always gives 1. Hint: Any even number on b a) 10 b) 2 c) 1 d) 0 C 15:- What will be the value of the following Python expression? bin(10-2)+bin(12^4) a) 0b10000 b) 0b10001000 c) 0b1000b1000 d) 0b10000b1000 D 16:- Which of the following expressions can be used to multiply a given number ‘a’ by 4? a) a4 A 17:- What is the two’s complement of -44? a) 1011011 b) 11010100 c) 11101011 d) 10110011 B 18:- What will be the output of the following Python code snippet? ['hello', 'morning'][bool('')] a) error b) no output c) hello d) morning C 19:- What will be the output of the following Python code? ['f', 't'][bool('spam')] a) t b) f c) No output d) Error A 20:- What will be the output of the following Python code? "l=[1, 0, 2, 0, 'hello', '', []] list(filter(bool, l))" a) Error b) [1, 0, 2, 0, ‘hello’, ”, []] c) [1, 0, 2, ‘hello’, ”, []] d) [1, 2, ‘hello’] D 21:- What will be the output of the following Python code? "class Truth: pass x=Truth() bool(x)" a) pass b) TRUE c) FALSE d) error B 22:- What will be the output of the following Python code? "if (9 < 0) and (0 < -9): print(""hello"") elif (9 > 0) or False: print(""good"") else: print(""bad"")" a) error b) hello c) good d) bad C 23:- Which of the following Boolean expressions is not logically equivalent to the other thr a) not(-610) b) 6>=0 and -68, 4>2, 1>2]) a) Error b) True c) False d) 4>2 B 6:- What will be the output of the following Python function? import math abs(math.sqrt(25)) a) Error b) -5 c) 5 d) 5.0 D 7:- What will be the output of the following Python function? sum(2,4,6) sum([1,2,3]) a) Error, 6 b) 12, Error c) 12, 6 d) Error, Error A 8:- What will be the output of the following Python function? complex(1+2j) a) Error b) 1 c) 2j d) 1+2j D 9:- What will be the output of the following Python function? list(enumerate([2, 3])) a) Error b) [(1, 2), (2, 3)] c) [(0, 2), (1, 3)] d) [(2, 3)] C 10:- What is the output of the function complex()? a) 0j b) 0+0j c) 0 d) Error A 11:- The function divmod(a,b), where both ‘a’ and ‘b’ are integers is evaluated as: a) (a%b, a//b) b) (a//b, a%b) c) (a//b, a*b) d) (a/b, a%b) B 12:- What will be the output of the following Python functions? float('1e-003') float('2e+003') a)3.00 300 b)0.001 2000.0 c)0.001 200 d)Error 2003View B 13:- Which of the following functions does not necessarily accept only iterables as argument a) enumerate() b) all() c) chr() d) max() C 15:- Which of the following functions will not result in an error when no arguments are pass a) min() b) divmod() c) all() d) float() D 16:- Suppose there is a list such that: l=[2,3,4]. If we want to print this list in reverse a) reverse(l) b) list(reverse[(l)]) c) reversed(l) d) list(reversed(l)) D 17:- Which of the following functions accepts only integers as arguments? a) ord() b) min() c) chr() d) any() C 18:- What will be the output of the following Python function? len(["hello",2, 4, 6]) a) 4 b) 3 c) Error d)6 A 19:- Which of the following functions does not throw an error? a) ord() b) ord(‘ ‘) c) ord(”) d) ord(“”) B 20:- What will be the output of the following Python function? hex(15) a) f b) 0xF c) 0Xf d) 0xf D 21:- Which of the following functions will not result in an error when no arguments are pass a) min() b) divmod() c) all() d) float() D 22:- Which of the following functions does not necessarily accept only iterables as argument a) enumerate() b) all() c) chr() d) max() D 23:- The function complex(‘2-3j’) is valid but the function complex(‘2 – 3j’) is invalid. a) True b) False A 24:- What will be the output of the following Python functions? float('1e-003') float('2e+003') a) 3.00, 300 b) 0.001, 2000.0 c) 0.001, 200 d) Error, 2003 B 25:- What will be the output of the following Python function? divmod(10.5,5) divmod(2.4,1.2) a) (2.00, 0.50), (2.00, 0.00) b) (2, 0.5), (2, 0) c) (2.0, 0.5), (2.0, 0.0) d) (2, 0.5), (2) C 28 1:- What is the purpose of a while loop in Python? a) To iterate over a sequence of items. b) To execute a block of code a specific number of times. c) To execute a block of code as long as a certain condition is true. d) To create a finite loop. C 2:- Which keyword is used to exit a while loop prematurely? a) stop b) quit c) break d) exit C 3:- What is the purpose of a for loop in Python? a) To execute a block of code repeatedly for a specific number of times. b) To iterate over a sequence of items. c) To execute a block of code as long as a certain condition is true. d) To create an infinite loop. B 4:- Which function is used to generate a sequence of numbers to be used in a for loop? a) generate() b) range() c) sequence() d) numbers() B 5:- How can you iterate over both the index and the value of items in a list using a for loo a) for item in list: b) for index, item in list: c) for i in range(len(list)): d) for index in list: C 6:- What keyword is used to skip the current iteration of a for loop and continue with the n a) next b) pass c) continue d) skip C 7:- Which loop is more suitable when you know the exact number of iterations beforehand? a) while loop b) for loop B 8:- What is the key difference between a while loop and a do-while loop? a) A while loop only executes the code block if the condition is initially true. b) A do-while loop always executes the code block at least once before checking the conditio c) There is no difference; they are two names for the same loop type. d) A do-while loop can only be used with integers. B 9:- Which loop is more suitable when the number of iterations is determined by a specific co a) while loop b) for loop A 10:- What is the primary purpose of a for loop in Python? a) To execute a block of code as long as a condition is true. b) To create an infinite loop. c) To iterate over a sequence of items. d) To perform mathematical calculations. C 11:- Which loop is more appropriate for iterating through a string character by character? a) while loop b) for loop B 12:- What is the purpose of the enumerate() function when used with a for loop? a) It generates a sequence of numbers. b) It calculates the sum of all elements in a list. c) It helps iterate over both the index and value of items in a sequence. D 13:- How can you terminate a for loop prematurely? a) end b) terminate c) exit d) break D 14:- Which loop is better suited for cases where you do not know the exact number of iterati a) while loop b) for loop A 15:- In a while loop, what must you ensure to prevent an infinite loop? a) The loop must contain a for loop. b) The loop must contain the break statement. c) The loop must contain the continue statement. d) The loop must have a condition that eventually becomes false. D 16:- What does the range() function return when used in a for loop? a) A list of numbers. b) A tuple of numbers. c) An iterator of numbers. d) A dictionary of numbers. C 17:- What is the key difference between a for loop and a while loop? a) A for loop only executes the code block if the condition is initially true. b) A while loop is used for definite iteration, while a for loop is used for indefinite iter c) A for loop is used for definite iteration, while a while loop is used for indefinite iter d) There is no difference; they are two names for the same loop type. C 18:- Which loop would you use to print the numbers from 1 to 10? a) for loop b) while loop A 19:- In a for loop, which function can be used to calculate the sum of all elements in a lis a) add() b) sum() c) total() d) accumulate() B 20:- How can you reverse iterate over a range of numbers using a for loop? a) for i in range(start, end, step): b) for i in range(end, start, -step): c) for i in range(start, end): d) for i in range(end, start): B 21:- What will be the output of the following code snippet? Python Copy code for char a) P-y-t-h-o-n- b) Python c) P-y-t-h-o-n d) P y t h o n A 22:- What is the purpose of the pass statement in a loop? a) It terminates the loop immediately. b) It creates a temporary placeholder for code to be added later. c) It forces the loop to execute forever. d) It skips the current iteration and moves to the next one. B 23:- How can you reverse iterate over a range of numbers using a for loop? a) for i in range(start, end, step): b) for i in range(end, start, -step): c) for i in range(start, end): d) for i in range(end, start): B 24:- What is the purpose of the pass statement in a loop? a) It terminates the loop immediately. b) It creates a temporary placeholder for code to be added later. c) It forces the loop to execute forever. d) It skips the current iteration and moves to the next one. B 25:- Which loop would you use when the number of iterations is determined by a specific cond a) for loop b) while loop B 11 1:- Which of these about a set is not true? a) Mutable data type b) Does not allow duplicate values c) Data type with unordered value d) Immutable data type D 2:- Which of the following is not the correct syntax for creating a set? a) set([[1,2],[3,4]]) b) set([1,2,2,3,4]) c) set((1,2,3,4)) d) {1,2,3,4} A 3:- What will be the output of the following Python code? a = [5,5,6,7,7,7] b = set(a) def test(lst): if lst in b: return 1 else: return 0 for i in filter(test,a): print(i,end="" "") a) 5 5 6 b) 5 6 7 c) 5 5 6 7 7 7 d) 5 6 7 7 7 C 4:- Which of the following statements is used to create an empty set? a) { } b) set() c) [ ] d) ( ) B 5:- What will be the output of the following Python code? a={5,4} b={1,2,4,5} a 5 and not 8 < 7 d) 10 > 5 or not 8 < 7 B 21:- What is the result of the expression `4 + 5 * 3 - 2`? a) 17 b) 19 c) 14 d) 15 C 22:- Which operator is used for logical AND in Python? a) && b) & c) and d) andand C 23:- What is the result of the expression `7 // 2 + 3 / 2`? a) 4.5 b) 4 c) 3.5 d) 3 B 24:- Which of the following expressions evaluates to `False`? a) 10 == 5 + 5 b) 5 != 7 - 3 c) 8 >= 2 * 4 d) 3 < 2 + 1 D 25:- What is the result of the expression `True or False and not True`? a) True b) False c) Error d) None A 21 1:- Which of the following is correct with respect to OOP concept in Python? A) Objects are real world entities while classes are not real. B) Classes are real world entities while objects are not real. C) Both objects and classes are real world entities. D) Both object and classes are not real. A 2:- How many objects and reference variables are there for the given Python code? class A: print("Inside class") A() A() obj=A() A) 2 and 1 B) 3 and 3 C) 3 and 1 D) 3 and 2 C 3:- Which of the following is False with respect Python code? class Student: def __init__(self,id,age): self.id=id self.age=age std=Student(1,20) A) "std" is the reference variable for object Student(1,20) B) id and age are called the parameters. C) Every class must have a constructor. D) None of the above C 5:- What will be the output of below Python code? class A(): def __init__(self,count=100): self.count=count obj1=A() obj2=A(102) print(obj1.count) print(obj2.count) A) 100,100 B) 100,102 C) 102,102 D) Error B 6:- Which of the following is correct? class A: def __init__(self,name): self.name=name a1=A("john") a2=A("john") A) id(a1) and id(a2) will have same value. B) id(a1) and id(a2) will have different values. C) Two objects with same value of attribute cannot be created. D) None of the above B 7:- Which of the following is correct? class A: def __init__(self): self.count=5 self.count=count+1 a=A() print(a.count) A) 5 B) 6 C) 0 D) Error D 8:- Which of the following is correct? class Book: def __init__(self,author): self.author=author book1=Book("V.M.Shah") book2=book1 A) Both book1 and book2 will have reference to two different objects of class Book. B) id(book1) and id(book2) will have same value. C) It will throw error as multiple references to same object is not possible. D) None of the above B 9:- In python, what is method inside class? A) attribute B) object C) argument D) function D 10:- What will be the output of below Python code? class A: def __init__(self,num): num=3 self.num=num def change(self): self.num=7 a=A(5) print(a.num) a.change() print(a.num) A) 5,7 B) 5,5 C) 3,3 D) 3,7 D 11:- Which is not a feature of OOP in general definitions? a) Efficient Code b) Code reusability c) Modularity d) Duplicate/Redundant data D 12:- When OOP concept did first came into picture? a) 1980’s b) 1995 c) 1970’s d) 1993 C 13:- Which feature of OOP indicates code reusability? a) Abstraction b) Polymorphism c) Encapsulation d) Inheritance" D 14:- What is Instantiation in terms of OOP terminology? a) Deleting an instance of class b) Modifying an instance of class c) Copying an instance of class d) Creating an instance of class D 15:- What is getattr() used for? a) To access the attribute of the object b) To delete an attribute c) To check if an attribute exists or not d) To set an attribute C 16:- What will be the output of the following Python code? class fruits: def __init__(self, price): self.price = price obj=fruits(50) obj.quantity=10 obj.bags=2 print(obj.quantity+len(obj.__dict__)) a) 12 b) 52 c) 13 d) 60 C 17:- The assignment of more than one function to a particular operator is _______ a) Operator over-assignment b) Operator overriding c) Operator overloading d) Operator instance C 18:- What is the implicit return type of constructor? a) No return type b) A class object in which it is defined. c) void d) None B 19:- When is the object created with a new keyword? a) At run time b) At compile time c) Depends on the code d) None A 20:- Identify the scope resolution operator. a) : b) :: c) ?: d) None B 64 1:- _____ represents an entity in the real world with its identity and behaviour. a) A method b) An object c) A class d) An operator b 2:- _____ is used to create an object. a) class b) constructor c) User-defined functions d) In-built functions B 3:- What is setattr() used for? a) To access the attribute of the object b) To set an attribute c) To check if an attribute exists or not d) To delete an attribute B 4:- What is getattr() used for? a) To access the attribute of the object b) To delete an attribute c) To check if an attribute exists or not d) To set an attribute A 5:- What will be the output of the following Python code? def __init__(self, x, y, z): self.a = x + y + z x = change(1,2,3) y = getattr(x, 'a') setattr(x, 'a', y+1) print(x.a) a) 6 b) 7 c) Error d) 0 B 6:- What will be the output of the following Python code? class test: def __init__(self,a): self.a=a def display(self): print(self.a) obj=test() obj.display() a) Runs normally, doesn’t display anything b) Displays 0, which is the automatic default value c) Error as one argument is required while creating the object d) Error as display function requires additional argument C 7:- Is the following Python code correct? class A: def __init__(self,b): self.b=b def display(self): print(self.b) obj=A("Hello") del obj a) True b) False A 8:- What will be the output of the following Python code? class test: def __init__(self): self.variable = 'Old' self.Change(self.variable) def Change(self, var): var = 'New' obj=test() print(obj.variable) a) Error because function change can’t be called in the __init__ function b) ‘New’ is printed c) ‘Old’ is printed d) Nothing is printed C 9:- What is Instantiation in terms of OOP terminology? a) Deleting an instance of class b) Modifying an instance of class c) Copying an instance of class d) Creating an instance of class D 10:- What will be the output of the following Python code? class fruits: def __init__(self, price): self.price = price obj=fruits(50) obj.quantity=10 obj.bags=2 print(obj.quantity+len(obj.__dict__)) a) 12 b) 52 c) 13 d) 60 C 11:- What will be the output of the following Python code? class Demo: def __init__(self): pass def test(self): print(__name__) obj = Demo() obj.test() a) Exception is thrown b) __main__ c) Demo d) test B 12:- The assignment of more than one function to a particular operator is _______ a) Operator over-assignment b) Operator overriding c) Operator overloading d) Operator instance C 13:- Which of the following is not a class method? a) Non-static b) Static c) Bounded d) Unbounded A 14:- What will be the output of the following Python code? def add(c,k): c.test=c.test+1 k=k+1 class A: def __init__(self): self.test = 0 def main(): Count=A() k=0 for i in range(0,25): add(Count,k) print("Count.test=", Count.test) print("k =", k) main() a) Exception is thrown b) Count.test=25,k=25 c) Count.test=25,k=0 d) Count.test=0,k=0 C 15:- Which of the following Python code creates an empty class? a)class A: return b)class A: pass c)class A: d) It is not possible to create an empty class B 16:- Is the following Python code valid? class B(object): def first(self): print("First method called") def second(): print("Second method called") ob = B() B.first(ob) a) It isn’t as the object declaration isn’t right b) It isn’t as there isn’t any __init__ method for initializing class members c) Yes, this method of calling is called unbounded method call d) Yes, this method of calling is called bounded method call C 17:- What are the methods which begin and end with two underscore characters called? a) Special methods b) In-built methods c) User-defined methods d) Additional methods A 18:- Special methods need to be explicitly called during object creation. a) True b) False B 19:- What will be the output of the following Python code? class demo(): def __repr__(self): return '__repr__ built-in function called' def __str__(self): return '__str__ built-in function called' s=demo() print(s) a) Error b) Nothing is printed c) __str__ called d) __repr__ called C 20:- What will be the output of the following Python code? class demo(): def __repr__(self): return '__repr__ built-in function called' def __str__(self): return '__str__ built-in function called' s=demo() print(s) a) __str__ called b) __repr__ called c) Error d) Nothing is printed A 21:- What is hasattr(obj,name) used for? a) To access the attribute of the object b) To delete an attribute c) To check if an attribute exists or not d) To set an attribute C 22:- What will be the output of the following Python code? class stud: def __init__(self, roll_no, grade): self.roll_no = roll_no self.grade = grade def display (self): print("Roll no : ", self.roll_no, ", Grade: ", self.grade) stud1 = stud(34, 'S') stud1.age=7 print(hasattr(stud1, 'age')) a) Error as age isn’t defined b) True c) False d) 7 B 23:- What is delattr(obj,name) used for? a) To print deleted attribute b) To delete an attribute c) To check if an attribute is deleted or not d) To set an attribute B 24:- __del__ method is used to destroy instances of a class. a) True b) False A 25:- What will be the output of the following Python code? class stud: ‘Base class for all students’ def __init__(self, roll_no, grade): self.roll_no = roll_no self.grade = grade def display (self): print("Roll no : ", self.roll_no, ", Grade: ", self.grade) print(student.__doc__) a) Exception is thrown b) __main__ c) Nothing is displayed d) Base class for all students D 26 1:- Which of the following represents the bitwise XOR operator? a) & b) ^ c) | d) ! B 2:- Bitwise _________ gives 1 if either of the bits is 1 and 0 when both of the bits are 1. a) OR b) AND c) XOR d) NOT C 3:- What will be the output of the following Python expression? bin(29) a) ‘0b10111’ b) ‘0b11101’ c) ‘0b11111’ d) ‘0b11011’ B 4:- What will be the output of the following Python expression? int(1011)? a) 1011 b) 11 c) 13 d) 1101 A 5:- To find the decimal value of 1111, that is 15, we can use the function: a) int(1111,10) b) int(‘1111’,10) c) int(1111,2) d) int(‘1111’,2) D 6:- What will be the output of the following Python expression if x=15 and y=12? x&y a) b1101 b) 0b1101 c) 12 d) 1101 C 7:- Which of the following expressions results in an error? a) int(1011) b) int(‘1011’,23) c) int(1011,2) d) int(‘1011’) C 8:- What is the value of the following Python expression? bin(0x8) a) ‘0bx1000’ b) 8 c) 1000 d) ‘0b1000’ D 9:- What will be the output of the following Python expression? 0x35 | 0x75 a) 115 b) 116 c) 117 d) 118 C 10:- It is not possible for the two’s complement value to be equal to the original value in any case. a) True b) False B 11:- The one’s complement of 110010101 is: a) 001101010 b) 110010101 c) 001101011 d) 110010100 A 12:- What will be the output of the following Python expression? 4^12 a) 2 b) 4 c) 8 d) 12 C 13:- What will be the value of the following Python expression? bin(10-2)+bin(12^4) a) 0b10000 b) 0b10001000 c) 0b1000b1000 d) 0b10000b1000 D 14:- Which of the following expressions can be used to multiply a given number ‘a’ by 4? a) a4 A 15:- What will be the output of the following Python code if a=10 and b =20? a=10 b=20 a=a^b b=a^b a=a^b print(a,b) a) 10 20 b) 10 10 c) 20 10 d) 20 20 C 16:- What is the two’s complement of -44? a) 1011011 b) 11010100 c) 11101011 d) 10110011 B 17:- What will be the output of the following Python expression? ~100? a) 101 b) -101 c) 100 d) -100 B 18:- What will be the output of the following Python code? class Truth: x=Truth() bool(x) a) pass b) true c) false d) error B 19:- What will be the output of the following Python code? if (9 < 0) and (0 < -9): print("hello") elif (9 > 0) or False: print("good") else: print("bad") a) error b) hello c) good d) bad C 20:- Which of the following Boolean expressions is not logically equivalent to the other three? a) not(-610) b) -6>=0 and -6>>p = re.compile("/d") b) p = re.escape(‘hello’) c) p = re.subn() d) p = re.purge() c 4. What will be the output of the following Python code? re.split('\W+', 'Hello, hello, hello.') a) [‘Hello’, ‘hello’, ‘hello.’] b) [‘Hello, ‘hello’, ‘hello’] c) [‘Hello’, ‘hello’, ‘hello’, ‘.’] d) [‘Hello’, ‘hello’, ‘hello’, ”] b 5. What will be the output of the following Python function? re.findall("hello world", "hello") a) [“hello”] b) [ ] c) hello d) hello world b 6. Choose the function whose output can be:. a) re.search(‘aaaa’, “alohaaaa”, 0) b) re.match(‘aaaa’, “alohaaaa”, 0) c) re.match(‘aaa’, “alohaaa”, 0) d) re.search(‘aaa’, “alohaaa”, 0) a 7. Which of the following functions clears the regular expression cache? a) re.sub() b) re.pos() c) re.purge() d) re.subn() c 8. What will be the output of the following Python code? import re re.ASCII a) 8 b) 32 c) 64 d) 256 d 9. Which of the following functions results in case insensitive matching? a) re.A b) re.U c) re.I d) re.X c 10. Which of the following functions returns a dictionary mapping group names to group numbers? a) re.compile.group b) re.compile.groupindex c) re.compile.index d) re.compile.indexgroup b 11. Which of the following statements regarding the output of the function re.match is incorrect? a) ‘pq*’ will match ‘pq’ b) ‘pq?’ matches ‘p’ c) ‘p{4}, q’ does not match ‘pppq’ d) ‘pq+’ matches ‘p’ d 12. The following Python code snippet results in an error. c=re.compile(r'(\d+)(\[A-Z]+)([a-z]+)') c.groupindex a) True b) False b 13. Which of the following functions does not accept any argument? a) re.purge b) re.compile c) re.findall d) re.match a 14. What will be the output of the following Python code? a = re.compile('0-9') a.findall('3 trees') a) [] b) [‘3’] c) Error d) [‘trees’] c 15. Which of the following lines of code will not show a match? a) re.match(‘ab*’, ‘a’) b) re.match(‘ab*’, ‘ab’) c) re.match(‘ab*’, ‘abb’) d) re.match(‘ab*’, ‘ba’) d 16. What will be the output of the following Python code? m = re.search('a', 'The blue umbrella') m.re.pattern a) {} b) ‘The blue umbrella’ c) ‘a’ d) No output c 17. What will be the output of the following Python code? re.sub('Y', 'X', 'AAAAAA', count=2) a) ‘YXAAAA’ b) (‘YXAAAA’) c) (‘AAAAAA’) d) ‘AAAAAA’ d 18. What will be the output of the following Python code? re.split(r'(n\d)=', 'n1=3.1, n2=5, n3=4.565') a) Error b) [”, ‘n1’, ‘3.1, ‘, ‘n2’, ‘5, ‘, ‘n3’, ‘4.565’] c) [‘n1’, ‘3.1, ‘, ‘n2’, ‘5, ‘, ‘n3’, ‘4.565’] d) [‘3.1, ‘, ‘5, ‘, ‘4.565’] b 19. The function of re.search is __________ a)Matches a pattern at the start of the string b) Matches a pattern at the end of the string c) Matches a pattern from any part of a string d) Such a function does not exist c 20. Which of the following functions creates a Python object? a) re.compile(str) b) re.assemble(str) c) re.regex(str) d) re.create(str) a 21. Which of the following pattern matching modifiers permits whitespace and comments inside the regular expression? a) re.L b) re.S c) re.U d) re.X d 22. What will be the output of the following Python code? s = 'welcome home' m = re.match(r'(.*)(.*?)', s) print(m.group()) a) (‘welcome’, ‘home’) b) [‘welcome’, ‘home’] c) welcome home d) [‘welcome’ // ‘home’ ] c 23. The function of re.match is ____________ a) Error b) Matches a pattern anywhere in the string c) Matches a pattern at the end of the string d) Matches a pattern at the start of the string d 24. The special character \B matches the empty string, but only when it is _____________ a) at the beginning or end of a word b) not at the beginning or end of a word c) at the beginning of the word d) at the end of the word b 25. Which of the following special characters matches a pattern only at the end of the string? a) \B b) \X c) \Z d) \A c 26. What will be the output of the following Python code? re.match('sp(.*)am', 'spam') a) b) c) No output d) Error b 27. Which of the following special characters represents a comment (that is, the contents of the parenthesis are simply ignor a) (?:…) b) (?=…) c) (?!…) d) (?#…) d 28. The function re.error raises an exception if a particular string contains no match for the given pattern. a) True b) False b 29. What will be the output of the following Python code? re.compile('hello', re.X) a) [‘h’, ‘e’, ‘l’, ‘l’, ‘o’] b) re.compile(‘hello’, re.VERBOSE) c) Error d) Junk value b 30. What will be the output of the following Python code? re.split('[a-c]', '0a3B6', re.I) a) Error b) [‘a’, ‘B’] c) [‘0’, ‘3B6’] d) [‘a’] c 31. What will be the output of the following Python code? re.sub('morning', 'evening', 'good morning') a) ‘good evening’ b) ‘good’ c) ‘morning’ d) ‘evening’ a 32. What will be the output of the following Python code? re.escape('new**world') a) ‘new world’ b) ‘new\\*\\*world’ c) ‘**’ d) ‘new’, ‘*’, ‘*’, ‘world’ b 33. What will be the output of the following Python code? re.fullmatch('hello', 'hello world') a) No output b) [] c) d) Error a 34. The difference between the functions re.sub and re.subn is that re.sub returns a _______________ whereas re.subn retur a) string, list b) list, tuple c) string, tuple d) tuple, list c 35. What will be the output of the following Python code? re.split('mum', 'mumbai*', 1) a) Error b) [”, ‘bai*’] c) [”, ‘bai’] d) [‘bai*’] b 36. What will be the output of the following Python code? re.split(r'(a)(t)', 'Maths is a difficult subject') a) [‘M a t h s i s a d i f f i c u l t s u b j e c t’] b) [‘Maths’, ‘is’, ‘a’, ‘difficult’, ‘subject’] c) ‘Maths is a difficult subject’ d) [‘M’, ‘a’, ‘t’, ‘hs is a difficult subject’] d 37. What will be the output of the following Python code? re.subn('A', 'X', 'AAAAAA', count=4) a) ‘XXXXAA, 4’ b) (‘AAAAAA’, 4) c) (‘XXXXAA’, 4) d) ‘AAAAAA, 4’ c 38. In the functions re.search.start(group) and re.search.end(group), if the argument groups not specified, it defaults to ____ a) Zero b) None c) One d) Error a 39. What will be the output of the following Python code? a=re.compile('[0-9]+') a.findall('7 apples and 3 mangoes') a) [‘apples’ ‘and’ ‘mangoes’] b) (7, 4) c) [‘7’, ‘4’] d) Error c 47 1. The value of the expressions 4/(3*(2-1)) and 4/3*(2-1) is the same. a) True b) False C) none of the above D) may be A 2. What will be the value of the following Python expression? 4+3%5 a) 4 b) 7 c) 2 d) 0 B 3. Evaluate the expression given below if A = 16 and B = 15. A % B // A a) 0.0 b) 0 c) 1.0 d) 1 B 4. Which of the following operators has its associativity from right to left? a) + b) // c) % d) ** d 5. What will be the value of x in the following Python expression? x = int(43.55+2/2) a) 43 b) 44 c) 22 d) 23 B 6. What is the value of the following expression? 2+4.00, 2**4.0 a) (6.0, 16.0) b) (6.00, 16.00) c) (6, 16) d) (6.00, 16.0) A 7. Which of the following is the truncation division operator? a) / b) % c) // d) | C 8. What are the values of the following Python expressions? 2*(3*2) (2**3)**2 2*3*2 a) 64, 512, 64 b) 64, 64, 64 c) 512, 512, 512 d) 512, 64, 512 d 9. What is the value of the following expression? 8/4/2, 8/(4/2) a) (1.0, 4.0) b) (1.0, 1.0) c) (4.0. 1.0) d) (4.0, 4.0) a 10. What is the value of the following expression? float(22//3+3/3) a) 8 b) 8.0 c) 8.3 d) 8.33 B 11. What will be the output of the following Python expression? print(4.00/(2.0+2.0)) a) Error b) 1.0 c) 1.00 d) 1 B 12.What will be the value of X in the following Python expression? X = 2+9*((3*12)-8)/10 a) 30.0 b) 30.8 c) 28.4 d) 27.2 D 13. Which of the following expressions involves coercion when evaluated in Python? a) 4.7 – 1.5 b) 7.9 * 6.3 c) 1.7 % 2 d) 3.4 + 4.6 C 14. What will be the output of the following Python expression? 24//6%3, 24//4//2 a) (1,3) b) (0,3) c) (1,0) d) (3,1) A 15. Which among the following list of operators has the highest precedence? +, -, **, %, /, , | a) b) ** c) | d) % B 16. What will be the value of the following Python expression? float(4+int(2.39)%2) a) 5.0 b) 5 c) 4.0 d) 4 c 17. Which of the following expressions is an example of type conversion? a) 4.0 + float(3) b) 5.3 + 6.3 c) 5.0 + 3 d) 3 + 7 A 18.Which of the following expressions results in an error? a) float(‘10’) b) int(‘10’) c) float(’10.8’) d) int(’10.8’) d 19. What will be the value of the following Python expression? 4+2**5//10 a) 3 b) 7 c) 77 d) 0 b 20. The expression 2*23 is evaluates as: (2*2)**3. a) True b) False C)will not execute D)none of the above B 21.Given the expression; 5 + 4 ** 2 * 3 / 6 What is the result? a) 14.0 b) 13.0 c) 11.0 d) 10.0 c) 26 d) 11 A 22.Consider the code: x=8 y=2 z=3 result = x - y * z What will result be? a) 3 b) 2 c) 0 d) 10 c 23.Given the values `a = 5`, `b = 2`, and `c = 3`, what does the expression a % b + c ** b evaluate to? a) 7 b) 10 c) 11 d) 8 a 24.Consider the expression 6 + 8 / 2 ** 2 * 4 What is the result? a) 10.0 b) 14.0 c) 12.0 d) 8.0 B 25.Which of the following best defines operator precedence in Python? a) The order in which operators are evaluated based on their position in the code. b) The order in which operators are evaluated based on their priority or hierarchy. c) The order in which operators are evaluated randomly. d) The order in which operators are evaluated alphabetically. B 59 1. Fill in the line of the following Python code for calculating the factorial of a number. def fact(num): if num == 0: return 1 else: return ____________________ a) num*fact(num-1) b) (num-1)*(num-2) c) num*(num-1) d) fact(num)*fact(num-1) (A) 2. What will be the output of the following Python code? l=[] def convert(b): if(b==0): return l dig=b%2 l.append(dig) convert(b//2) convert(6) l.reverse() for i in l: print(i,end=" ") a) 011 b) 110 c) 3 d) Infinite loop (B) 3. All keywords in Python are in _________ a) lower case b) UPPER CASE c) Capitalized d) None of the mentioned (D) 4. What is the type of each element in sys.argv? a) set b) list c) tuple d) string (D) 5. What will be the output of the following Python code? def foo(fname, val): print(fname(val)) foo(max, [1, 2, 3]) foo(min, [1, 2, 3]) a) 3 1 b) 1 3 c) error d) none of the mentioned answer: (A) 6. Which bitwise operator is used to perform the bitwise XOR operation? a) ^ b) || c) ~ d) & a 7. Given the binary values 1010 and 1100, what is the result of the bitwise OR operation? a) 1000 b) 1110 c) 0010 d) 1111 b 8. What does the expression `4 >> 1` evaluate to? a) 1 b) 2 c) 4 d) 0 b 9. Which of the following is true for the expression `True and False`? a) Result is True b) Result is False c) Result is None d) Raises an error b 10. Which operator is used for performing the bitwise left shift operation? a) > c) & d) ~ a 11. What is the output of the expression `3 ^ 3`? a) 0 b) 1 c) 3 d) 6 a 12. What does the expression `7 >> 2` evaluate to? a) 1 b) 2 c) 3 d) 0 b 13. Which of the following is the correct way to check if both conditions `a` and `b` are True? a) a & b b) a && b c) a | b d) a || b a 14. Given the binary value 1100, what is the result of the right shift operation by 2 positions? a) 11 b) 110 c) 1100 d) 0011 d 15. What is the output of the expression `~True`? a) False b) True c) None d) Error d 16. Which of the following expressions is equivalent to the expression `(a & b) == 0`? a) a && b b) a | b c) a || b d) not a and not b d 17. What does the expression `10 c) & d) ~ b 24. What does the expression `6 ^ 3` evaluate to? a) 9 b) 2 c) 5 d) 0 a 25. What is the result of the expression `True or False`? a) True b) False c) None d) Error a 1. What will be the output of the following Python statement? "a"+"bc" a) a b) bc c) bca d) abc d "2. What will be the output of the following Python statement? "abcd"[2:]" a) a b) ab c) cd d) dc c 3. The output of executing string.ascii_letters can also be achieved by: a) string.ascii_lowercase_string.digits b) string.ascii_lowercase+string.ascii_uppercase c) string.letters d) string.lowercase_string.uppercase b 4. What will be the output of the following Python code? str1 = 'hello' 2. str2 = ','3. str3 = 'world'4. str1[-1:] " a) olleh b) hello c) h d) o d 5. What arithmetic operators cannot be used with strings? a) + b) * c) – d) All of the mentioned c 6. What will be the output of the following Python code? print (r"\nhello") a) a new line and hello b) \nhello c) the letter r and then hello d) error b 7. What will be the output of the following Python statement?1. print('new' 'line') a) Error b) Output equivalent to print ‘new\nline’ c) newline d) new line c 8. What will be the output of the following Python statement?1. print('x\97\x98') a) Error b)97 98 c) x\97 d) \x97\x98 c 9. What will be the output of the following Python code?1. str1="helloworld" str1[::-1] a) dlrowolleh b) hello c) world d) helloworld a 10. What will be the output of the following Python code? print(0xA + 0xB + 0xC) a) 0xA0xB0xC b) Error c) 0x22 d) 33 d 11. What will be the output of the following Python code? class tester: def __init__(self, id): self.id = str(id) id=""224"" temp = tester(12) print(temp.id) a) 224 b) Error c) 12 d) None c 12. What will be the output of the following Python code? example = ""snow world"" print(""%s"" % example[4:7]) a) wo b) world c) sn d) rl a 13. What will be the output of the following Python code? example = ""snow world"" example = 's' print example a) snow b) snow world c) Error d) snos world c 14. What will be the output of the following Python code? max(""what are you"") a) error b) u c) t d) y d 15. Given a string example=”hello” what is the output of example.count(‘l’)? a) 2 b) 1 c) None d) 0 a 16. What will be the output of the following Python code? example = ""helle"" example.find(""e"") a) Error b) -1 c) 1 d) 0 c 17. What will be the output of the following Python code? example = ""helle"" example.rfind(""e"") a) -1 b) 4 c) 3 d) 1 b 18. What will be the output of the following Python code? example=""helloworld"" example[::-1].startswith(""d"") a) dlrowolleh b) True c) -1 d) None b 19. To concatenate two strings to a third what statements are applicable? a) s3 = s1. s2 b) s3 = s1.add(s2) c) s3 = s1.__add__(s2) d) s3 = s1 * s2 c 20. What will be the output of the following Python statement? chr(ord('A')) a) A b) B c) a d) Error a 21. What will be the output of the following Python statement? print(chr(ord('b')+1)) a) a b) b c) c d) A c 22. Which of the following statement prints hello\example\test.txt? a) print(“hello\example\test.txt”) b) print(“hello\\example\\test.txt”) c) print(“hello\”example\”test.txt”) d) print(“hello”\example”\test.txt”) b 23. Suppose s is “\t\tWorld\n”, what is s.strip()? a) \t\tWorld\n b) \t\tWorld\n c) \t\tWORLD\n d) World d 24. The format function, when applied on a string returns ___________ a) Error b) int c) bool d) str d 25. What will be the output of the “hello” +1+2+3? a) hello123 b) hello c) Error d) hello6 c 26. What will be the output of the following Python code?print(""D"", end = ' ') print(""C"", end = ' ') print(""B"", end = ' ') print(""A"", end = ' ') a) DCBA b) A, B, C, D c) D C B A d) D, C, B, A will be displayed on four lines c 27. What will be the output of the following Python statement?(python 3.xx) print(format(""Welcome"", ""10s""), end = '#') print(format(111, ""4d""), end = '#') print(format(924.656, ""3.2f"")) a) Welcome# 111#924.66 b) Welcome#111#924.66 c) Welcome#111#.66 d) Welcome # 111#924.66 d 28. What will be displayed by print(ord(‘b’) – ord(‘a’))? a) 0 b) 1 c) -1 d) 2 b 29.Say s=”hello” what will be the return value of type(s)? a) int b) bool c) str d) String c 30. What is “Hello”.replace(“l”, “e”)? a) Heeeo b) Heelo c) Heleo d) None a 31. To retrieve the character at index 3 from string s=”Hello” what command do we execute (m a) s[] b) s.getitem(3) c) s.__getitem__(3) d) s.getItem(3) c 32. To return the length of string s what command do we execute? a) s.__len__() b) len(s) c) size(s) d) s.size() a 33. If a class defines the __str__(self) method, for an object obj for the class, you can us a) obj.__str__() b) str(obj) c) print obj d) all of the mentioned d 34. To check whether string s1 contains another string s2, use ________ a) s1.__contains__(s2) b) s2 in s1 c) s1.contains(s2) d) si.in(s2) a 35. Suppose i is 5 and j is 4, i + j is same as ________ a) i.__add(j) b) i.__add__(j) c) i.__Add(j) d) i.__ADD(j) b 36. What will be the output of the following Python code? class Count: def __init__(self, count = 0): self.__count = count c1 = Count(2) c2 = Count(2) print(id(c1) == id(c2), end = "" "") s1 = ""Good"" s2 = ""Good"" print(id(s1) == id(s2)) a) True False b) True True c) False True d) False False c 37. What function do you use to read a string? a) input(“Enter a string”) b) eval(input(“Enter a string”)) c) enter(“Enter a string”) d) eval(enter(“Enter a string”)) a 38. Suppose x is 345.3546, what is format(x, “10.3f”) (_ indicates space). a) __345.355 b) ___345.355 c) ____345.355 d) _____345.354 b 39. What will be the output of the following Python code? print(""abc DEF"".capitalize()) a) abc def b) ABC DEF c) Abc def d) Abc Def c 40. What will be the output of the following Python code? print(""abcdef"".center()) a) cd b) abcdef c) error d) none of the mentioned c 57 1. Which of the following functions is a built-in function in python? a) seed() b) sqrt() c) factorial() d) print() d 2. What will be the output of the following Python expression? round(4.576)" a) 4.5 b) 5 c) 4 d) 4.6 b 3. The function pow(x,y,z) is evaluated as: a) (x*y)*z b) (x**y) / z c) (x**y) % z d) (x**y)*z c 4. What will be the output of the following Python function? all([2,4,0,6]) a) Error b) True c) False d) 0 c 5. What will be the output of the following Python function? sum(2,4,6) sum([1,2,3]) a) Error, 6 b) 12, Error c) 12, 6 d) Error, Error a 6. What is called when a function is defined inside a class? A. class B. function C. method D. module C 7. If return statement is not used inside the function, the function will return: A. None B. 0 C. Null D. Arbitary value A 8. What is a recursive function? A. A function that calls other function. B. A function which calls itself. C. Both A and B D. None of the above B 9. Which of the following is the use of id() function in python? A. Id() returns the size of object. B. Id() returns the identity of the object. C. Both A and B D. None of the above B 10. Which of the following function headers is correct? A. def fun(a = 2, b = 3, c) B. def fun(a = 2, b, c = 3) C. def fun(a, b = 2, c = 3) D. def fun(a, b, c = 3, d) C 11. In which part of memory does the system stores the parameter and local variables of funt A. heap B. stack C. Uninitialized data segment D. None of the above B 12. Which of the following will print the pi value defined in math module? A. print(pi) B. print(math.pi) C. "from math import pi print(pi)" D. "from math import pi print(math.pi)" C 13. Which operator is used in Python to import modules from packages? A.. B. * C. -> D. & A 14. Where is function defined? A. Module B. class C. Another Function D. All of the above D 15. Lambda is a function in python? A. True B. False C. Lambda is a function in python but user can not use it. D. None of the above A 16. What is a variable defined outside a function referred to as? A. local variable B. global variable C. static Variable D. automatic variable B "17. What is the output of the following program? z = lambda x : x * x print(z(6))" A. 6 B. 36 C. 0 D. error B "18. What is the output of the following program? print(chr(ord(chr(97))))" A. a B. A C. 97 D. error A 19. How is a function declared in Python? A. def function function_name(): B. declare function function_name(): C. def function_name(): D. declare function_name(): C 20. Which one of the following is the correct way of calling a function? A. function_name() B. call function_name() C. ret function_name() D. function function_name() A "21. Choose the correct option with reference to below Python code? def fn(a): print(a) x=90 fn(x)" A. x is the formal argument. B. a is the actual argument. C. fn(x) is the function signature. D. x is the actual argument. D 22. Which one of the following is incorrect? A. The variables used inside function are called local variables. B. The local variables of a particular function can be used inside other functions, but thes C. The variables used outside function are called global variables D. In order to change the value of global variable inside function, keyword global is used. B 23. You can also create your own functions, these functions are called? A. built-in functions B. user-defined functions C. py function D. None of the above B 24. Which keyword is use for function? A. define B. fun C. def D. function C 25. Which of the following items are present in the function header? A. function name B. parameter list C. return value D. Both A and B D

Use Quizgecko on...
Browser
Browser