1302 Exam 2

Ace your homework & exams now with Quizwiz!

2) Class Healthcare has the methods Pharmacy() and Labs(). Class Hospitals is derivedfrom Healthcare and has the methods Doctor(), Patients(), and Nurses(). Afterh =Hospitals()executes, how many different methods can object h call, ignoringconstructors?a. 7b. 5c. 3d. 4

5

58) Select the format string used to style the lines as shown in the image.

....

74) Which code block generates the following output?a. theta1 = np.linspace(0, 2*np.pi, 100)r = 1plt.subplot(1)plt.plot(r*np.cos(theta1), r*np.sin(theta1))plt.subplot(2)plt.plot(r*np.cos(theta1), r*np.sin(theta1))plt.subplot(3)plt.plot(r*np.cos(theta1), r*np.sin(theta1))plt.subplot(4)plt.plot(r*np.cos(theta1), r*np.sin(theta1))plt.show()b. theta1 = np.linspace(0, 2*np.pi, 100)r = 1plt.subplot(2, 2, 1)plt.plot(r*np.cos(theta1), r*np.sin(theta1))plt.subplot(2, 2, 2) plt.plot(r*np.cos(theta1), r*np.sin(theta1))plt.subplot(2, 2, 3)plt.plot(r*np.cos(theta1), r*np.sin(theta1))plt.subplot(2, 2, 4)plt.plot(r*np.cos(theta1), r*np.sin(theta1))plt.show()c. theta1 = np.linspace(0, np.pi, 100)r = 1plt.subplot(2, 2, 1)plt.plot(r*np.cos(theta1), r*np.sin(theta1))plt.subplot(2, 2, 2)plt.plot(r*np.cos(theta1), r*np.sin(theta1))plt.subplot(2, 2, 3)plt.plot(r*np.cos(theta1), r*np.sin(theta1))plt.subplot(2, 2, 4)plt.plot(r*np.cos(theta1), r*np.sin(theta1))plt.show()d. theta1 = np.linspace(0, 2*np.pi, 100)r = 1plt.subplot(4, 1)plt.plot(r*np.cos(theta1), r*np.sin(theta1))plt.subplot(4, 2)plt.plot(r*np.cos(theta1), r*np.sin(theta1))plt.subplot(4, 3)plt.plot(r*np.cos(theta1), r*np.sin(theta1))plt.subplot(4, 4)plt.plot(r*np.cos(theta1), r*np.sin(theta1))plt.show()

.....

65) Identify the correct syntax to annotate the data point at (5,2) placing the text 'Peak' at(5,3).a. plt.annotate('Peak', xy=(5, 2), xytext=(5, 3))b. plt.annotate('Peak', xy=(5, 3), xytext=(5, 2)) c. plt.annotate(xy=(5, 2), xytext=(5, 3))d. plt.annotate(xy=(5, 3), xytext=(5, 2))

a. plt.annotate('Peak', xy=(5, 2), xytext=(5, 3))

22) Select an assertion method that checks if a string is not a substring of another string.a. assertIsNotb. assertFalsec. assertNotInd. assertNotEqual

c. assertNotIn

25) If the base condition is not defined in the recursive function, _____.a. the program runs only once b. the program runs as many times as the number passed as its argumentc. the program terminates giving an errord. the program gets into an infinite loop

d. the program gets into an infinite loop

55) What is output?import matplotlib.pyplot as pltSalary=[x*x for x in range(-70,70,1)]Grade=[x for x in range(-70,70,1)]plt.plot(Grade,Salary,'c-') plt.title('X vs Y')plt.xlabel('X')plt.ylabel('Y')plt.show()

a

54) Identify the (x[2], y[2]) coordinate in the following code.import matplotlib.pyplot as pltSalary=[10,20,30,40,50]Grade=[1,2,3,4,5]plt.plot(Salary,Grade)plt.title('Salary vs Grade')plt.xlabel('Salary')plt.ylabel('Grade')plt.show()a. (30, 3)b. (20, 2)c. (10, 1)d. (40, 4)

a. (30, 3)

71) The pyplot.axis() function is used to define the _____.a. range of the axesb. position of the axesc. scale of the axesd. rotation of the axes

a. range of the axes

35) Which is the best way to debug recursive functions?a. Adding print statement of what that line of code does.b. Adding output statements by keeping all the statements left aligned.c. Adding output statements with an indent to print statements at every iteration.d. Adding output statements by keeping all the statements equally indented.

a. Adding print statement of what that line of code does.

15) Identify which relationship of the everyday items is an is-a relationship.a. Basketball/Sportb. Car/Transmissionc. Calculator/Displayd. Pizza/Topping

a. Basketball/Sport

24) A programmer is testing individual components of a program, including methods,class interfaces, data structures, and inherited attributes. What type of testing is theprogrammer performing?a. Component testingb. Suite testingc. Unit testingd. Functionality testing

a. Component testing

45) What is the role of sys.getrecursionlimit()?a. It measures the maximum depth of the function.b. It changes the depth of the function.c. It isolates the defined function. d. It finds the error of the function.

a. It measures the maximum depth of the function.

19) Identify the concept used in the following code.class Coach:def __init__ (self, cname):self.coach_name = cnameclass Player:def __init__ (self, pname):self.player_name = pnameclass Game (Player, Coach):def __init__ (self, gname, pname, cname):Player.__init__ (self,pname)Coach.__init__ (self,cname)self.game = gnamedef get_game (self):print (self.game, self.player_name, self.coach_name)a. Multiple inheritanceb. Multilevel inheritancec. Inheritance using mixinsd. Inheritance using derived class

a. Multiple inheritance

12) What is output?class Item:def __init__(self):self.name = 'None'self.quantity = 0def dsp_item(self):print(f'Name: {self.name}, Quantity: {self.quantity}')class Produce(Item): # Derived from Itemdef __init__(self):Item.__init__(self) # Call base class constructorself.expiration = '01-01-2000'def dsp_item(self):Item.dsp_item(self)print(f'Expiration: {self.expiration}')n = Produce()n.dsp_item()a. Name: None, Quantity: 0Expiration: 01-01-2000 b. Expiration: 01-01-2000c. dsp_item() returns a AttributeErrord. Expiration: 01-01-2000Expiration: 01-01-200013) Identify which relationship of the everyday items is a has-a relationship.a. Baseball/Sportb. Truck/Vehiclec. University/Libraryd. Aspirin/Medicine

a. Name: None, Quantity: 0Expiration: 01-01-2000

46) Which of the following is a good candidate for using recursive functions?a. To solve the greatest common divisor (GCD) problemb. To solve problems that have a true and false solutionc. To solve problems that require excessive memory allocationd. To solve logarithmic problems

a. To solve the greatest common divisor (GCD) problem

20) Select an assertion that checks if the string contains 'war' for the given code block.def test_eq(self):self.[XXX]a. assertIn( 'war', 'In war, events of importance are the resultof trivial causes.')b. assertIs( 'war', 'In war, events of importance are the resultof trivial causes.')c. assertAlmostEqual( 'war', 'In war, events of importance arethe result of trivial causes.')d. assertIn( 'In war, events of importance are the result oftrivial causes.', 'war')

a. assertIn( 'war', 'In war, events of importance are the resultof trivial causes.')

38) A base case is a _____.a. case that returns a value without performing a recursive callb. function method that calls itselfc. function execution instance that calls another execution instance of the same functiond. case that calls another function method

a. case that returns a value without performing a recursive call

47) Which code calculates the power of a number raised to another (a^b)?a. def power(a,b):if b == 1:return aelse:return a**power(a,b-1)b. def power(a,b):if b == 1:return aelse:return a*power(b-1,a)c. def power(a,b):if b == 1:return aelse:return a**power(b-1,a)d. def power(a,b):if b == 1:return aelse:return a*power(a,b-1)

a. def power(a,b):if b == 1:return aelse:return a**power(a,b-1)

51) A traveller starts his journey from Chicago and travels to Los Angeles, New York,California, and Florida. Which XXX is the best recursive exploration method to find thedistance the traveller travelled?def distance_travel(curr_path, need_to_visit):if len(curr_path) == num_cities:total_distance = 0for i in range(len(curr_path)):print(f'{city_names[curr_path[i]]} ', end=' ')if i > 0:total_distance += distances[curr_path[i-1]][curr_path[i]]print(f'= {total_distance}')else:for i in range(len(need_to_visit)):city = need_to_visit[i]XXXneed_to_visit.insert(i, city)curr_path.pop()a. distance_travel(curr_path, need_to_visit)need_to_visit.pop(i)curr_path.append(city)b. distance_travel(curr_path, need_to_visit)need_to_visit.append(city)curr_path.pop(i)c. need_to_visit.append(city)curr_path.pop(i)distance_travel(curr_path, need_to_visit)d. need_to_visit.pop(i)curr_path.append(city)distance_travel(curr_path, need_to_visit)

a. distance_travel(curr_path, need_to_visit)need_to_visit.pop(i)curr_path.append(city)

31) Assume that there is a recursive binary search function find(). If a sorted list has adata structure with indices 0 to 50 and the item being searched for happens to be atlocation 6, write each call of find() that would occur while searching for that item. Thefirst is find(0,50).a. find(0, 25) find(0, 12) find(0, 6)b. find(0, 25) find(0, 12)c. find(0, 25)d. find(0, 25) find(0, 12) find(0, 6) find(0, 3)

a. find(0, 25) find(0, 12) find(0, 6)

11) Complete the code to generate the following output.168class Rect():def __init__(self,length,breadth):self.length = lengthself.breadth = breadthdef getArea(self):print(self.length*self.breadth)class Sqr(Rect):def __init__(self,side):self.side = sideRect.__init__(self,side,side)def getArea(self):print(self.side*self.side) if __name__ == '__main__':XXXa. square = Sqr(4)rectangle = Rect(2,4)square.getArea()rectangle.getArea()b. rectangle = Rect(2,4)square = Sqr(4)rectangle.getArea()square.getArea()c. Sqr().getArea(4)Rect().getArea(2,4)d. Rect(4).getArea()Sqr(2,4).getArea()

a. square = Sqr(4)rectangle = Rect(2,4)square.getArea()rectangle.getArea()

30) How many times is the recursive function find() called when searching for themissing letter 'A' in the below code?def find(lst, item, low, high):range_size = (high - low) + 1mid = (high + low) // 2if item == lst[mid]:pos = midelif range_size == 1:pos = -1else:if item < lst[mid]:pos = find(lst, item, low, mid)else:pos = find(lst, item, mid+1, high)return poslistOfLetters = ['B', 'C', 'D', 'E', 'F', 'G', 'H']print(find(listOfLetters, 'A', 0, 6))a. 4b. 3c. 5d. program gets into an infinite loop

b. 3

27) How many times is the function count_down() called in the below code?def count_down(count):if count == 1:print('Terminated..!')else:print(count) count_down(count-1)count_down(5)a. 5b. 6c. 4d. 3

b. 6

4) Which statement is true about inheritance?a. A derived class cannot serve as a base class for another class.b. A class can serve as a base class for multiple derived classes.c. A class can be derived from only one class.d. A class can serve as a base class for only one class.

b. A class can serve as a base class for multiple derived classes.

1) _____ is a concept where the derived class acquires the attributes of its base class.a. Encapsulationb. Inheritancec. Abstractiond. Polymorphism

b. Inheritance

17) _____ are classes that provide additional behavior to methods and are notthemselves meant to be instantiated. a. Derived classesb. Mixin classesc. Base classesd. Inheritance classes

b. Mixin classes

72) What needs to be provided for the pyplot.subplot() function arguments?a. Plot location and figure nameb. Rows, columns, and active subplotc. Plot number and figure named. Total number of plots and active subplot

b. Rows, columns, and active subplot

23) Select the non-existent assertion method.a. assertNotInb. assertNonec. assertFalsed. assertTrue

b. assertNone

50) Identify the error in the code that scrambles a word's letters in all the possible ways..def scramble(r_letters, s_letters):if len(r_letters) == 0:print(s_letters)else:for i in range(len(r_letters)):scramble_letter = r_letters[i]remaining_letters = r_letters[:i] + r_letters[i-1:]scramble(remaining_letters, s_letters +scramble_letter)scramble('abc','')a. scramble_letter = r_letters[i]b. remaining_letters = r_letters[:i] + r_letters[i-1:] c. scramble(remaining_letters, s_letters + scramble_letter)d. if len(r_letters) == 0

b. remaining_letters = r_letters[:i] + r_letters[i-1:]

57) Which function takes an optional format string argument to specify the color andstyle of the plotted line?a. plt.show()b. plt.imshow()c. plt.legend()d. plt.plot()

d. plt.plot()

3) Which of the following is an example of a derived class?a. class item:def _init_(self):self.name = ''self.quantity = 0self.expiration = ''b. class Item:def __init__(self):self.name = ''self.quantity = 0class Produce(Item):def __init__(self):Item.__init__(self)self.expiration = '' c. Class item():def __init__(self):self.name = ''self.quantity = 0Produce(Item):def __init__(self):Item.__init__(self)self.expiration = ''d. class Item:def __init__(self):self.name = ''self.quantity = 0class Produce(Item):def __init__(self):Item.__init__(self)self.expiration = ''

b. class Item:def __init__(self):self.name = ''self.quantity = 0class Produce(Item):def __init__(self):Item.__init__(self)self.expiration = ''

36) While adding output statements to debug recursive functions, _____ the printstatements to show the current depth of recursion.a. left alignb. indent c. right alignd. center align

b. indent

70) Identify the code used for matrix multiplication of two arrays.a. np.mat(array1, array2)b. np.dot(array1, array2)c. np.malmul(array1, array2)d. np.cross(array1, array2)

b. np.dot(array1, array2)

66) Which package provides tools for scientific and mathematical computations inPython?a. pandasb. numpyc. sklearnd. matplotlib

b. numpy

10) Complete the code to generate the following output.Inside the child classclass ParentClass:def action(self):print('Method is not overridden')class ChildClass(ParentClass):def action(self):print('Inside the child class')if __name__ == '__main__':XXXa. ParentClass(self).action()b. r = ChildClass()r.action()c. ChildClass(self).action()d. r = ParentClass()r.action()

b. r = ChildClass()r.action()

39) Which condition is the recursive case for sum of the first n natural numbers?def nsum(n):if n == 0:sum = 0elif n == 1:sum = 1else:sum = n + nsum(n-1)return suma. if n == 0b. sum = n + nsum(n-1)c. elif n == 1d. sum = 1

b. sum = n + nsum(n-1)

7) How many different methods can Medicine object item2 call?class Product:def __init__(self):self.name = 'None'self.quantity = 0def set_item(self, nm, qty):self.name = nmself.quantity = qtydef get_item(self):return self.name, self.quantitydef get_name(self):return self.namedef get_quantity(self):return self.quantityclass Medicine(Product):def __init__(self):Product.__init__(self)self.expiration = 2000def set_expiration(self, exp):self.expiration = exp def get_medicine(self):return self.name, self.quantity, self.expirationitem1 = Product()item2 = Medicine()a. 2b. 6c. 4d. 8

b.6

34) How many iterations are needed for the function to find 12?def Find(list, ele, low, high):if high >= low:mid = (high + low)//2if list[mid] == ele:return midelif list[mid] > ele:return Find(list, ele, low, mid-1)else:return Find(list, ele, mid + 1, high)else:return -1listOfNumbers = [11, 12, 13, 15, 18]result = Find(listOfNumbers,12,0,(len(listOfNumbers)-1))print(result)a. 4b. 3c. 2d. 1

c. 2

44) What does the following function print for n1=12 and n2=15?def div(n1, n2):if n1 % n2 == 0:return n2else:return div(n2,n1%n2)print(div(12,15))a. 12b. 15c. 3d. 9

c. 3

8) def get_medicine(self):return self.name, self.quantity, self.expirationitem1 = Product()item2 = Medicine()a. 2b. 6c. 4d. 88) What is the output of the following code if the user enters '1' and '9'?class Players:def __init__(self, name, age):self.name = nameself.age = agedef info(self):print(f'Info for player {self.name}')class SoccerPlayers(Players):def __init__(self, name, age, league):Players.__init__(self, name, age)self.league = leaguedef teamNum(self, num1):if num1 == 0:print('Cannot be this number')else:print(f'\n{self.name} plays at {num1}')class ArcadePlayer(SoccerPlayers):def __init__(self, name, age, league, city):SoccerPlayers.__init__(self, name, age, league) def professional(self):print('Too good!')choice = input('Select the number 1 or 2: ')num = int(input('Enter which number do you play: '))player1 = ArcadePlayer('Timothy', 55, 'MyLeague', 'Chicago')player2 = ArcadePlayer('Sally', 20, 'L', 'New York')player1.info()player2.info()play = player1 if (choice == 1) else player2play.teamNum(num)a. Info for player SallySally plays at 9b. Info for player TimothyInfo for player SallySally plays at 9c. Info for player TimothyInfo for player SallySally plays at 9Timothy plays at 9d. Timothy plays at 1Sally plays at 9

c. Info for player TimothyInfo for player SallySally plays at 9Timothy plays at 9

18) What is output?class Residence:def __init__ (self, addr):self.address = addrdef get_residence (self):print (f'Address: {self.address}')class Identity:def __init__ (self, name, age):self.name = nameself.age = agedef get_Identity (self):print (f'Name: {self.name}, Age: {self.age}')class DrivingLicense (Identity, Residence):def __init__ (self, Id_num, name, age, addr):Identity.__init__ (self,name, age)Residence.__init__ (self,addr)self.License_Id = Id_numdef get_details (self):print (f'License No. {self.License_Id}, Name:{self.name}, Age: {self.age}, Address: {self.address}')license = DrivingLicense(180892,'Bob',21,'California')license.get_details()license.get_Identity()a. License No. 180892Name: Bob, Age: 21b. License No. 180892, Address: CaliforniaName: Bob, Age: 21c. License No. 180892, Name: Bob, Age: 21, Address: Californiad. License No. 180892, Name: Bob, Age: 21, Address: CaliforniaName: Bob, Age: 21

c. License No. 180892, Name: Bob, Age: 21, Address: California

42) What is the output of the following code if the user enters -1 and 6?def Greater(num1, num2):if (num1 >= num2):print('Number 1 is greater')else:print('Number 2 is greater')def Info(num1, num2):if (num1 < = 0):print('Number 1 cannot be less than or equal to 0...Enterthe number again')arg1 = int(input())arg2 = num2Info(arg1, arg2)elif (num2 <= 0):print('Number 2 cannot be less than or equal to 0...Enterthe number again')arg2 = int(input())arg1 = num1Info(arg1, arg2)else:Greater(num1, num2)print('Enter any 2 numbers')user_val1 = int(input())user_val2 = int(input())Info(user_val1, user_val2)a. The programs asks the user to enter the second number again.b. The programs asks the user to enter both numbers againc. The programs asks the user to enter the first number againd. Infinite loop

c. The program asks the user to enter the first number again.

63) Identify the correct syntax for text() function to display 'X Y Plot' at the coordinates(x,y) in grey color and font size 12.a. plt.text('X Y Plot', [x,y], color='grey', fontsize=12)b. plt.text((x,y), 'X Y Plot',color='grey', fontsize=12)c. plt.text(x,y, 'X Y Plot', color='grey', fontsize=12)d. plt.text([x,y], 'X Y Plot', color='grey', fontsize=12)

c. plt.text(x,y, 'X Y Plot', color='grey', fontsize=12)

29) Complete the code to get a factorial of a number.def factorial(number):if number == 0:return 1else:XXXprint(factorial(4))a. return number*(number-1)b. return factorial(number)*factorial(number-1)c. return number*factorial(number-1)d. return (number-1)*(number-2)

c. return number*factorial(number-1

73) The _____ function is used to create a second axis on a plot.a. xaxis()b. axisr() c. twinx()d. axhline()

c. twinx()

32) What is output if the code is executed to search for the letter 'A'?def Find(list, ele, low, high):if high >= low:mid = (high + low)//2if list[mid] == ele:return midelif list[mid] > ele:return Find(list, ele, low, mid-1)else:return Find(list, ele, mid + 1, high)else:return -1listOfLetters = ['B', 'C', 'D', 'E', 'F', 'G', 'H']result = Find(listOfLetters,'A',0,(len(listOfLetters)-1))print(result)a. 3b. Error: The program gets into an infinite loopc. 0d. -1

d. -1

43) What is output? def test(n): if n == 0: return 0 elif n == 1: return 1 else: return test(n-1)+test(n-2) for i in range(0,4): print(test(i),end=' ') a. 0 1 2 3 b. 1 2 3 4 c. 0 1 1 2 3 d. 0 1 1 2

d. 0 1 1 2

26) What is output?def divide_by_two(count):if count == 1:print('Terminated..!')else:print(count)divide_by_two(count/2)divide_by_two(9)a. 94.52.251.125Terminated..!b. 94.52.25Terminated..!c. Infinite loopd. 94.52.251.1250.5625Terminated..!

d. 94.52.251.1250.5625Terminated..!

13) Identify which relationship of the everyday items is a has-a relationship.a. Baseball/Sportb. Truck/Vehiclec. University/Libraryd. Aspirin/Medicine

d. Aspirin/Medicine

5) Identify the base class for the other classes in the given statement.Planet is derived from SolarSystem; SolarSystem is derived from Galaxy; Galaxy isderived from Universe.a. SolarSystemb. Planetc. Galaxyd. Universe

d. Universe

6) Which statement is not true?a. Inheritance tree describes the hierarchy between base and derived classes.b. A derived class can access the attributes of all of its base classes via normal attributereference operations.c. A derived class inherits the attributes of the base class, and then adds additionalattributes.d. When adding a new derived class, a programmer has to change the base class aswell.

d. When adding a new derived class, a programmer has to change the base class aswell

37) An indent variable _____ number of spaces on each iteration.a. adds unequalb. removes unequalc. removes equald. adds equal

d. adds equal

21) Select the assertion method that checks if a number is greater than or equal toanother number. a. assertNotLessb. assertGreaterc. assertAlmostEquald. assertGreaterEqual

d. assertGreaterEqual

16) Which is an example of inheritance?a. class Library:def __init__(self):self.name = ''class Books:def __init__(self):self.number = '' class Pages:def __init__(self):self.number = ''self.words = ''self.paragraphs = ''b. class Car:def __init__(self):self.type = ''class Boat:def __init__(self):self.model = ''class Engine:def __init__(self):self.model = ''self.type = ''self.power =''c. class Garden:def __init__(self):self.name = ''class Trees:def __init__(self):self.name = ''self.type = ''self.number = ''d. class Elements:def __init__(self):self.name = ''class Metal(Elements):def __init__(self):Elements.__init__(self)self.mass = ''self.atomicNumber = ''class NonMetal(Elements):def __init__(self):Elements.__init__(self)self.mass = ''self.atomicNumber = ''

d. class Elements:def __init__(self):self.name = ''class Metal(Elements):def __init__(self):Elements.__init__(self)self.mass = ''self.atomicNumber = ''class NonMetal(Elements):def __init__(self):Elements.__init__(self)self.mass = ''self.atomicNumber = ''

14) Which is an example of composition?a. class Continent:def __init__(self):self.name = ''class Europe(Continent):def __init__(self):Continent.__init__(self)self.area = ''self.population = ''class Africa(Continent):def __init__(self):Continent.__init__(self)self.area = ''self.population = ''b. class Cars:def __init__(self):self.type = ''self.Make = ''class Toyota(Cars):def __init__(self):Cars.__init__(self)self.cost = ''self.features =''class Bikes:def __init__(self): self.Make = ''class Kawasaki(Bikes):def __init__(self):Bikes.__init__(self)self.cost = ''self.features =''self.type = ''c. class Fruit:def __init__(self):self.name = ''class Apple:def __init__(self):self.type = ''self.nutrition = ''d. class Laptop:def __init__(self):self.brand = ''self.processor = ''class Processor:def __init__(self):self.brand = ''self.cores = ''self.speed = ''

d. class Laptop:def __init__(self):self.brand = ''self.processor = ''class Processor:def __init__(self):self.brand = ''self.cores = ''self.speed = ''

61) Which property is required for plt.legend()?a. alpha b. datac. visibled. label

d. label

40) How many times is the function Info() called if the user enters 0 and 1 in the first attempt? def Info(num1, num2): if (num1 == 0) or (num1 == 1): print('Passed round 1.') if (num2 == 1) or (num2 == 0): print('Passed round 2.') print('Good. You know your binary digits!') else: print('Numbers can be only 0s or 1s...Enter again') arg1 = int(input()) arg2 = int(input()) Info(arg1, arg2) else: print('Numbers can be only 0s or 1s...Enter again') arg1 = int(input()) arg2 = int(input()) Info(arg1, arg2) print('Enter 2 numbers used in binary notation') user_val1 = int(input()) user_val2 = int(input()) Info(user_val1, user_val2) a. 1 b. 2 c. 0 d. none

a. 1

9) A derived class may define a method having the same name as the base class meansthat:a. a derived class method overrides the method of the base class.b. a base class method overrides the method of the derived class.c. the functionality of the method is the same in both derived and base class.d. a derived class method overloads the method of the base class.

a. a derived class method overrides the method of the base class.

49) What is the output ofscramble('ab', '')in the following code?def scramble(r_letters, s_letters):if len(r_letters) == 0:print(s_letters)else:for i in range(len(r_letters)):scramble_letter = r_letters[i]remaining_letters = r_letters[:i] + r_letters[i+1:]scramble(remaining_letters, s_letters +scramble_letter)scramble('ab','')a. abbab. nullc. abnulld. Nullab

a. abba

28) Define a base condition to find the sum of arithmetic progression of the function.def arith_sum(a1, diff, nth):XXXreturn 0else:return a1 + arith_sum(a1 + diff, diff, nth-1)a. if nth == 0:b. if nth >= 0:c. if a1 >= 0:d. if a1 == 0:

a. if nth == 0:

69) Which numpy function creates the sequence [0.4,0.5,0.6,0.7]? a. np.linspace(0.4,0.7,4)b. np.range(0.4,0.7,4)c. np.arange(0.4,0.7,4)d. np.array(0.4,0.7,4)

a. np.linspace(0.4,0.7,4)

64) Which is incorrect syntax for axvline() function?a. plt.axvline('Text')b. plt.axvline(x, ymin, ymax, 'Text')c. plt.axvline(y, xmin, xmax, linewidth=1, color='r')d. plt.axvline('Text', color='blue', fontsize=10)

a. plt.axvline('Text')

60) Which statement defines a red X marker of size 5 and line width 10 for a line plot?a. plt.plot(X, Y, 'r-', marker='x', linewidth=10, markersize=5)b. plt.plot(X, Y, 'r-X', line_width=10, marker_size=5)c. plt.plot(X, Y, 'rX', linewidth=10, markersize=5)d. plt.plot(X, Y, 'r', marker='X', linewidth=10, markersize=5)

a. plt.plot(X, Y, 'r-', marker='x', linewidth=10, markersize=5)

59) Inplt.plot(X, Y, color='ro-', linewidth=5, markersize=5,alpha=0.35), which property is defined by alpha?a. transparencyb. anti-aliasingc. color contrastd. animation

a. transparency

41) What is output?def sub(i,j):if(i==0):return jelse:return sub(i-1,j-i)print(sub(4,10))a. 20b. -3 c. 0d. Infinite loop

b. -3

68) What doesnp.ones((3, 2))create?a. [[1. 1. 1.][1. 1. 1.]]b. [(1. 1.)(1. 1.)(1. 1.)]c. [[1. 1.][1. 1.][1. 1.]]d. [(1. 1. 1.)(1. 1. 1.)]

c. [[1. 1.][1. 1.][1. 1.]]

56) Complete the code to plot Salary=[5,6,7,8] and Grade=[100,200,300,400].import numpy as npimport matplotlib.pyplot as pltXXXa. plt.plot()plt.show(Salary,Grade)b. plt.plot(Salary,Grade).show()c. plt.plot(Salary,Grade)plt.show()d. plt.show([5,6,7,8],[100,200,300,400])plt.plot()

c. plt.plot(Salary,Grade)plt.show()

67) Select the line of code which is a 2-D array.a. np.array([1, 2, 3, 4, 5])b. np.array([1, 2, 3, 4, 5],[6, 7, 8, 9, 10])c. np.array((1, 2, 3, 4, 5),(6, 7, 8, 9, 10))d. np.array([(1, 2, 3, 4, 5),(6, 7, 8, 9, 10)])

d. np.array([(1, 2, 3, 4, 5),(6, 7, 8, 9, 10)])

52) Which package is used for plotting in Python?a. matlabb. ggplotc. matplotlibd. matlablib

d. matlablib

33) Which XXX completes the find function?def Find(list, ele, low, high):if high >= low:XXXif list[mid] == ele:return midelif list[mid] > ele:return Find(list, ele, low, mid-1)else:return Find(list, ele, mid + 1, high)else:return -1a. mid = low - (high - low) // 2b. mid = (high - low) // 2c. mid = (high - low) / 2 d. mid = low + (high - low) // 2

d. mid = low + (high - low) // 2

48) Recursive exploration does not explore _____.a. all possible reorderings of a word's lettersb. all the subsets of items c. all possible paths between citiesd. only one possible choice

d. only one possible choice

53) Which function plots data onto the graph?a. plt.show()b. plt.imshow()c. plt.legend()d. plt.plot()

d. plt.plot()

62) Which function is used to add text labels to a plot?a. plt.title()b. plt.xlabel()c. plt.legend()d. plt.text()

d. plt.text()


Related study sets

Management of Information Security Chapter 4

View Set

Chapter 2 - NUR 240 Review Questions

View Set

Endocrine and Metabolic Disorders EXAM I

View Set

Introduction to Cloud and Software Oriented Architectures (SOA)

View Set

POST HOC COMPARISONS & TESTING ASSUMPTIONS

View Set

Exam 1: audition/vestibular senses, olfaction, gestation

View Set

Cryptography and PKI (Security+ 501)

View Set

Chapter 8 test your understanding

View Set

BLAW 3201 - Test #1: Ch. 3 (Duplechain)

View Set