myclasss.com

Programming and Problem Solving Through Python Jul 2021

Multiple Choice

1.1 The Diamond symbol represent : (A) Decision (B) Initialization (C) Input/Output (D) None of Mentioned

1.2 When an algorithm is written in the form of a programming language, it becomes a : (A) Flow chart (B) Program (C) Pseudo code (D) Syntax

1.3 Which of the following is not a keyword in Python ? (A) eval (B) assert (C) non-local (D) pass

1.4 Which one of the following has the highest precedence in the expression ? (A) Exponential (B) Addition (C) Multiplication (D) Parentheses

1.5 Which of the following is correct about Python ? (A) It supports automatic garbage collection. (B) It can be easily integrated with C, C++, COM, ActiveX, CORBA and Java. (C) Both of the above (D) None of the above

1.6 Which of the following environment variable for Python tells the Python interpreter where to locate the module files imported into a program ? (A) PYTHONPATH (B) PYTHONSTARTUP (C) PYTHONCASEOK (D) PYTHONHOME

1.7 Which of the following data types is not supported in python ? (A) Numbers (B) String (C) List (D) Slice

1.8 Which of the following function of dictionary gets all the keys from the dictionary ? (A) getkeys() (B) key() (C) keys() (D) none of the mentioned

1.9 Select the reserved keyword in python : (A) else (B) raise (C) import (D) all of the mentioned

1.10 Which statement is correct ? (A) List is mutable and Tuple is immutable. (B) List is immutable and Tuple is mutable. (C) Both List and Tuple are Mutable. (D) Both List and Tuple are Immutable.

True or False

2.1 In computer science, algorithm refers to a special method usable by a computer for the solution to a problem. (A) True (B) False

2.2 Any algorithm is a program. (A) True (B) False

2.3 Python is case sensitive when dealing with identifiers. (A) True (B) False

2.4 Mathematical operations can be performed on a string. (A) True (B) False

2.5 Addition and Subtraction has the same precedence level. (A) True (B) False

2.6 The expression int(x) implies that the variable x is converted to integer. (A) True (B) False

2.7 values () is a function of dictionary gets all the values from the dictionary. (A) True (B) False

2.8 nested if-else are allowed in Python. (A) True (B) False

2.9 unichr(x)function convert an integer to octal string in python. (A) True (B) False

2.10 frozenset(s)function convert a sequence of tuples to dictionary in python. (A) True (B) False

Match in the Column

3.1 filter() (A) It take iterables (can be zero or more), makes iterator that aggregates elements based on the iterables passed, and returns an iterator of tuples. (B) A function convert a string to a list in python. (C) flow chart symbol that is used for processing of data or calculations (D) constructs an iterator from elements of an iterable for which a function returns true. (E) used in flow chart for input and output of data (F) in-built function of Python is used to remove all the leading and trailing spaces from a string. (G) start and end of a flow chart. (H) creates a slice object representing the set of indices specified by range(start, stop, step). (I) method converts a value to Boolean (true or false) using the standard truth testing procedure. (J) converts and returns the binary equivalent string of a given integer. (K) an explicit set of step by step specific instructions that solve a problem with an end or a solution. (L) method returns true if all characters in the string are alphanumeric (either alphabets or numbers). If not, it returns false. (M) Method displays the current working directory

3.2 The Oval (A) It take iterables (can be zero or more), makes iterator that aggregates elements based on the iterables passed, and returns an iterator of tuples. (B) A function convert a string to a list in python. (C) flow chart symbol that is used for processing of data or calculations (D) constructs an iterator from elements of an iterable for which a function returns true. (E) used in flow chart for input and output of data (F) in-built function of Python is used to remove all the leading and trailing spaces from a string. (G) start and end of a flow chart. (H) creates a slice object representing the set of indices specified by range(start, stop, step). (I) method converts a value to Boolean (true or false) using the standard truth testing procedure. (J) converts and returns the binary equivalent string of a given integer. (K) an explicit set of step by step specific instructions that solve a problem with an end or a solution. (L) method returns true if all characters in the string are alphanumeric (either alphabets or numbers). If not, it returns false. (M) Method displays the current working directory

3.3 strip() (A) It take iterables (can be zero or more), makes iterator that aggregates elements based on the iterables passed, and returns an iterator of tuples. (B) A function convert a string to a list in python. (C) flow chart symbol that is used for processing of data or calculations (D) constructs an iterator from elements of an iterable for which a function returns true. (E) used in flow chart for input and output of data (F) in-built function of Python is used to remove all the leading and trailing spaces from a string. (G) start and end of a flow chart. (H) creates a slice object representing the set of indices specified by range(start, stop, step). (I) method converts a value to Boolean (true or false) using the standard truth testing procedure. (J) converts and returns the binary equivalent string of a given integer. (K) an explicit set of step by step specific instructions that solve a problem with an end or a solution. (L) method returns true if all characters in the string are alphanumeric (either alphabets or numbers). If not, it returns false. (M) Method displays the current working directory

3.4 Isalnum() (A) It take iterables (can be zero or more), makes iterator that aggregates elements based on the iterables passed, and returns an iterator of tuples. (B) A function convert a string to a list in python. (C) flow chart symbol that is used for processing of data or calculations (D) constructs an iterator from elements of an iterable for which a function returns true. (E) used in flow chart for input and output of data (F) in-built function of Python is used to remove all the leading and trailing spaces from a string. (G) start and end of a flow chart. (H) creates a slice object representing the set of indices specified by range(start, stop, step). (I) method converts a value to Boolean (true or false) using the standard truth testing procedure. (J) converts and returns the binary equivalent string of a given integer. (K) an explicit set of step by step specific instructions that solve a problem with an end or a solution. (L) method returns true if all characters in the string are alphanumeric (either alphabets or numbers). If not, it returns false. (M) Method displays the current working directory

3.5 list() (A) It take iterables (can be zero or more), makes iterator that aggregates elements based on the iterables passed, and returns an iterator of tuples. (B) A function convert a string to a list in python. (C) flow chart symbol that is used for processing of data or calculations (D) constructs an iterator from elements of an iterable for which a function returns true. (E) used in flow chart for input and output of data (F) in-built function of Python is used to remove all the leading and trailing spaces from a string. (G) start and end of a flow chart. (H) creates a slice object representing the set of indices specified by range(start, stop, step). (I) method converts a value to Boolean (true or false) using the standard truth testing procedure. (J) converts and returns the binary equivalent string of a given integer. (K) an explicit set of step by step specific instructions that solve a problem with an end or a solution. (L) method returns true if all characters in the string are alphanumeric (either alphabets or numbers). If not, it returns false. (M) Method displays the current working directory

3.6 Algorithm (A) It take iterables (can be zero or more), makes iterator that aggregates elements based on the iterables passed, and returns an iterator of tuples. (B) A function convert a string to a list in python. (C) flow chart symbol that is used for processing of data or calculations (D) constructs an iterator from elements of an iterable for which a function returns true. (E) used in flow chart for input and output of data (F) in-built function of Python is used to remove all the leading and trailing spaces from a string. (G) start and end of a flow chart. (H) creates a slice object representing the set of indices specified by range(start, stop, step). (I) method converts a value to Boolean (true or false) using the standard truth testing procedure. (J) converts and returns the binary equivalent string of a given integer. (K) an explicit set of step by step specific instructions that solve a problem with an end or a solution. (L) method returns true if all characters in the string are alphanumeric (either alphabets or numbers). If not, it returns false. (M) Method displays the current working directory

3.7 bin() (A) It take iterables (can be zero or more), makes iterator that aggregates elements based on the iterables passed, and returns an iterator of tuples. (B) A function convert a string to a list in python. (C) flow chart symbol that is used for processing of data or calculations (D) constructs an iterator from elements of an iterable for which a function returns true. (E) used in flow chart for input and output of data (F) in-built function of Python is used to remove all the leading and trailing spaces from a string. (G) start and end of a flow chart. (H) creates a slice object representing the set of indices specified by range(start, stop, step). (I) method converts a value to Boolean (true or false) using the standard truth testing procedure. (J) converts and returns the binary equivalent string of a given integer. (K) an explicit set of step by step specific instructions that solve a problem with an end or a solution. (L) method returns true if all characters in the string are alphanumeric (either alphabets or numbers). If not, it returns false. (M) Method displays the current working directory

3.8 getcwd() (A) It take iterables (can be zero or more), makes iterator that aggregates elements based on the iterables passed, and returns an iterator of tuples. (B) A function convert a string to a list in python. (C) flow chart symbol that is used for processing of data or calculations (D) constructs an iterator from elements of an iterable for which a function returns true. (E) used in flow chart for input and output of data (F) in-built function of Python is used to remove all the leading and trailing spaces from a string. (G) start and end of a flow chart. (H) creates a slice object representing the set of indices specified by range(start, stop, step). (I) method converts a value to Boolean (true or false) using the standard truth testing procedure. (J) converts and returns the binary equivalent string of a given integer. (K) an explicit set of step by step specific instructions that solve a problem with an end or a solution. (L) method returns true if all characters in the string are alphanumeric (either alphabets or numbers). If not, it returns false. (M) Method displays the current working directory

3.9 The Rectangle (A) It take iterables (can be zero or more), makes iterator that aggregates elements based on the iterables passed, and returns an iterator of tuples. (B) A function convert a string to a list in python. (C) flow chart symbol that is used for processing of data or calculations (D) constructs an iterator from elements of an iterable for which a function returns true. (E) used in flow chart for input and output of data (F) in-built function of Python is used to remove all the leading and trailing spaces from a string. (G) start and end of a flow chart. (H) creates a slice object representing the set of indices specified by range(start, stop, step). (I) method converts a value to Boolean (true or false) using the standard truth testing procedure. (J) converts and returns the binary equivalent string of a given integer. (K) an explicit set of step by step specific instructions that solve a problem with an end or a solution. (L) method returns true if all characters in the string are alphanumeric (either alphabets or numbers). If not, it returns false. (M) Method displays the current working directory

3.10 zip() (A) It take iterables (can be zero or more), makes iterator that aggregates elements based on the iterables passed, and returns an iterator of tuples. (B) A function convert a string to a list in python. (C) flow chart symbol that is used for processing of data or calculations (D) constructs an iterator from elements of an iterable for which a function returns true. (E) used in flow chart for input and output of data (F) in-built function of Python is used to remove all the leading and trailing spaces from a string. (G) start and end of a flow chart. (H) creates a slice object representing the set of indices specified by range(start, stop, step). (I) method converts a value to Boolean (true or false) using the standard truth testing procedure. (J) converts and returns the binary equivalent string of a given integer. (K) an explicit set of step by step specific instructions that solve a problem with an end or a solution. (L) method returns true if all characters in the string are alphanumeric (either alphabets or numbers). If not, it returns false. (M) Method displays the current working directory

Fill in The Blank Space

4.1 A graphical representation of a computer program in relation to its sequence of functions __________. (A) help() (B) fp.shutdown() (C) flow chart (D) fp.close() (E) tell() (F) unpickling (G) uppertolower() (H) swapcase (I) readline() (J) alias (K) seek (L) scanoneline() (M) arrange

4.2 __________ method calls the built-in Python help system. (A) help() (B) fp.shutdown() (C) flow chart (D) fp.close() (E) tell() (F) unpickling (G) uppertolower() (H) swapcase (I) readline() (J) alias (K) seek (L) scanoneline() (M) arrange

4.3 To create sequences of numbers, NumPy provides a function __________ analogous to range that returns arrays instead of lists. (A) help() (B) fp.shutdown() (C) flow chart (D) fp.close() (E) tell() (F) unpickling (G) uppertolower() (H) swapcase (I) readline() (J) alias (K) seek (L) scanoneline() (M) arrange

4.4 __________ return the current file position after reading the first line. (A) help() (B) fp.shutdown() (C) flow chart (D) fp.close() (E) tell() (F) unpickling (G) uppertolower() (H) swapcase (I) readline() (J) alias (K) seek (L) scanoneline() (M) arrange

4.5 __________ is a method sets the file's current position at the offset. (A) help() (B) fp.shutdown() (C) flow chart (D) fp.close() (E) tell() (F) unpickling (G) uppertolower() (H) swapcase (I) readline() (J) alias (K) seek (L) scanoneline() (M) arrange

4.6 __________ is used for object deserialization. (A) help() (B) fp.shutdown() (C) flow chart (D) fp.close() (E) tell() (F) unpickling (G) uppertolower() (H) swapcase (I) readline() (J) alias (K) seek (L) scanoneline() (M) arrange

4.7 __________ method converts all uppercase characters to lowercase and vice-versa of the given string, and returns it. (A) help() (B) fp.shutdown() (C) flow chart (D) fp.close() (E) tell() (F) unpickling (G) uppertolower() (H) swapcase (I) readline() (J) alias (K) seek (L) scanoneline() (M) arrange

4.8 ndarray is also known as the __________ array. (A) help() (B) fp.shutdown() (C) flow chart (D) fp.close() (E) tell() (F) unpickling (G) uppertolower() (H) swapcase (I) readline() (J) alias (K) seek (L) scanoneline() (M) arrange

4.9 __________ is used to close a file object (fp). (A) help() (B) fp.shutdown() (C) flow chart (D) fp.close() (E) tell() (F) unpickling (G) uppertolower() (H) swapcase (I) readline() (J) alias (K) seek (L) scanoneline() (M) arrange

4.10 __________ reads one entire line from the file. (A) help() (B) fp.shutdown() (C) flow chart (D) fp.close() (E) tell() (F) unpickling (G) uppertolower() (H) swapcase (I) readline() (J) alias (K) seek (L) scanoneline() (M) arrange

Programming and Problem Solving Through Python Jan 2021

Multiple Choice

1.1 Find the output of following Python Programs a = "Meetmeafterparty" b = 13 print a + b (A) 29 (B) 14 (C) error in code (D) 15

1.2 Find the output of the following Python programs. class Acc: def_init_(self, id): self.id = id id = 555 acc = Acc(lll) print acc.id (A) 111 (B) 555 (C) 666 (D) error in code

1.3 Which of the following is an invalid variable ? (A) my_string_l (B) foo (C) _ (D) 1st_string

1.4 Find the output of the following Python programs. x = ['ab','cd'] for i in x: i.upper() print(x) (A) ab (B) cd (C) ['ab', 'cd'] (D) ['cd', 'ab']

1.5 What is the output of the following program ? a = 2 b = '3.77' c = -8 strl = '{0:4f[ [0:3d] [2] [1]'. format (a, b, c) print(strl) (A) 2.0000 2 -8 3.77 (B) 2 3.77 -8 3.77 (C) 2.000 3 -8 3.77 (D) 2.000 2 8 3.77

1.6 Find out the output of the following Python programs : def gfg(x,l=[]): for i in range (x): l.append(i*i) print(l) gfg(2) (A) [3, 2, 1, 0, 1, 4] (B) [0, 1] (C) [0, 1, 0, 1, 4] (D) error in code

1.7 Suppose t = (1, 2, 4, 3), which of the following is incorrect ? (A) print (t[3]) (B) t[3] = 45 (C) print(max(t)) (D) print (Len(t))

1.8 What will be the output of the following Python code ? »>tl=(l, 2, 4, 3) »>t2=(l, 2, 3, 4) »>tl<t2 (A) True (B) False (C) Error (D) (1,2, 4, 3)

1.9 Which of the following statements is false about recursion ? (A) Every recursive function must have a base case (B) Infinite recursion can occur if the base case isn't properly mentioned (C) A recursive function makes the code easier to understand (D) Every recursive function must have a return value

1.10 What will be the output of the following Python code ? import functools 1=[1, 2, 3, 4, 5] m=functools.reduce(lambda x, y:x if x>y else y, 1) print(m) (A) Error (B) Address of m (C) 1 (D) 5

True or False

2.1 Python is a high-level, interpreted, interactive and object-oriented scripting language. It is designed to be highly unreadable. (A) True (B) False

2.2 Python is derived from many other languages, including ABC, Modula-3, C, C++, Algol-68, SmallTalk, and Unix shell and other scripting languages. (A) True (B) False

2.3 In Python assignment of more than one behaviour to a particular function and the operation performed varies by the types of objects or arguments involved are known as operator overloading. (A) True (B) False

2.4 To access values in tuple, use the square brackets for slicing along with the index or indices to obtain value available at that index. (A) True (B) False

2.5 The Python standard for database interfaces is the Python SB-API. Most Python database interfaces adhere to this standard. (A) True (B) False

2.6 If a connection is established with the datasource, then a Connection Object is returned and saved into db for further use, otherwise db is set to None. (A) True (B) False

2.7 The tell() method tells you the current position within the file. (A) True (B) False

2.8 Removing individual tuple elements is possible. (A) True (B) False

2.9 The first method_init_() is a special method, which is called class constructor or initialization method that Python calls when you create a new instance of this class. (A) True (B) False

2.10 When a Python script raises an exception, it must either handle the exception immediately otherwise it terminates and quits. (A) True (B) False

Match in the Column

3.1 Error does not fall into any category (A) time.altzone (B) tuple(seq) (C) teU() (D) Value Error (E) rb+ (F) Runtime Error (G) L[-2] (H) def (I) del (J) getcwd() (K) Syntax Error (L) Rb- (M) L[-l]

3.2 The arguments have invalid values specified (A) time.altzone (B) tuple(seq) (C) teU() (D) Value Error (E) rb+ (F) Runtime Error (G) L[-2] (H) def (I) del (J) getcwd() (K) Syntax Error (L) Rb- (M) L[-l]

3.3 Opens a file for both reading and writing in binary format (A) time.altzone (B) tuple(seq) (C) teU() (D) Value Error (E) rb+ (F) Runtime Error (G) L[-2] (H) def (I) del (J) getcwd() (K) Syntax Error (L) Rb- (M) L[-l]

3.4 Function blocks begin with the keyword (A) time.altzone (B) tuple(seq) (C) teU() (D) Value Error (E) rb+ (F) Runtime Error (G) L[-2] (H) def (I) del (J) getcwd() (K) Syntax Error (L) Rb- (M) L[-l]

3.5 Negative count from the right (A) time.altzone (B) tuple(seq) (C) teU() (D) Value Error (E) rb+ (F) Runtime Error (G) L[-2] (H) def (I) del (J) getcwd() (K) Syntax Error (L) Rb- (M) L[-1]

3.6 Method displays the current working directory (A) time.altzone (B) tuple(seq) (C) teU() (D) Value Error (E) rb+ (F) Runtime Error (G) L[-2] (H) def (I) del (J) getcwd() (K) Syntax Error (L) Rb- (M) L[-l]

3.7 The offset of the local DST time zone (A) time.altzone (B) tuple(seq) (C) teU() (D) Value Error (E) rb+ (F) Runtime Error (G) L[-2] (H) def (I) del (J) getcwd() (K) Syntax Error (L) Rb- (M) L[-l]

3.8 Converts a list into tuple (A) time.altzone (B) tuple(seq) (C) teU() (D) Value Error (E) rb+ (F) Runtime Error (G) L[-2] (H) def (I) del (J) getcwd() (K) Syntax Error (L) Rb- (M) L[-l]

3.9 Shows current position within the file (A) time.altzone (B) tuple(seq) (C) tell() (D) Value Error (E) rb+ (F) Runtime Error (G) L[-2] (H) def (I) del (J) getcwd() (K) Syntax Error (L) Rb- (M) L[-l]

3.10 Explicitly remove an entire tuple (A) time.altzone (B) tuple(seq) (C) teU() (D) Value Error (E) rb+ (F) Runtime Error (G) L[-2] (H) def (I) del (J) getcwd() (K) Syntax Error (L) Rb- (M) L[-l]

Fill in The Blank Space

4.1 The output of following Python program is. r = lambda q: q * 2 s = lambda q: q * 3 x = 2 x = r(x) x = s(x) x = r(x) print x (A) time.time() (B) 24 (C) parentheses (D) reference (E) more (F) local variables (G) TRUE (H) Guido van Rossum (I) function (J) objects (K) less (L) FALSE (M) Tim Berner

4.2 Let consider the following Python code a = True b = False c = False if a or b and c: print "TRUE" else: print "FALSE" the output of this code is. (A) time.time() (B) 24 (C) parentheses (D) reference (E) more (F) local variables (G) TRUE (H) Guido van Rossum (I) function (J) objects (K) less (L) FALSE (M) Tim Berner

4.3 Recursive functions usually takememory space than non-recursive function. (A) time.time() (B) 24 (C) parentheses (D) reference (E) more (F) local variables (G) TRUE (H) Guido van Rossum (I) function (J) objects (K) less (L) FALSE (M) Tim Berner

4.4 Python programming language was created by. (A) time.time() (B) 24 (C) parentheses (D) reference (E) more (F) local variables (G) TRUE (H) Guido van Rossum (I) function (J) objects (K) less (L) FALSE (M) Tim Berner

4.5 Python supports Object-Oriented style or technique of programming that encapsulates code within. (A) time.time() (B) 24 (C) parentheses (D) reference (E) more (F) local variables (G) TRUE (H) Guido van Rossum (I) function (J) objects (K) less (L) FALSE (M) Tim Berner

4.6 returns the current time instant, a floating-point number of seconds since the epoch. (A) time.time() (B) 24 (C) parentheses (D) reference (E) more (F) local variables (G) TRUE (H) Guido van Rossum (I) function (J) objects (K) less (L) FALSE (M) Tim Berner

4.7 All parameters (arguments) in the Python language are passed by. (A) time.time() (B) 24 (C) parentheses (D) reference (E) more (F) local variables (G) TRUE (H) Guido van Rossum (I) function (J) objects (K) less (L) FALSE (M) Tim Berner

4.8 The can be accessed only inside the function in which they are declared, whereas global variables can be accessed throughout the program body by all functions. (A) time.time() (B) 24 (C) parentheses (D) reference (E) more (F) local variables (G) TRUE (H) Guido van Rossum (I) function (J) objects (K) less (L) FALSE (M) Tim Berner

4.9 The differences between tuples and lists are, the tuples cannot be changed unlike lists and tuples use, whereas lists use square brackets. (A) time.time() (B) 24 (C) parentheses (D) reference (E) more (F) local variables (G) TRUE (H) Guido van Rossum (I) function (J) objects (K) less (L) FALSE (M) Tim Berner

4.10 Python converts numbers internally in an expression containing mixed types to a Common type for evaluation. But sometimes, coerce a number explicitly from one type to another to satisfy the requirements of parameter. (A) time.time() (B) 24 (C) parentheses (D) reference (E) more (F) local variables (G) TRUE (H) Guido van Rossum (I) function (J) objects (K) less (L) FALSE (M) Tim Berner