COP4814 Final Review

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

False

Defensive coding principles suggest that your code should not fail on invalid input.

False

Good testing requires modular and decoupled code, which is a hallmark of good system design. The whole practice of unit testing is made much easier by code that is loosely coupled (code that exposes its internal data or functions and does not make use of the internal data or functions of other code).

def if for == True

Replace [python#] with the appropriate code tokens to make the following snippet correct: [python1] is_prime(number): if number < 2: return False [python2] number == 2: return True [python3] i in range(2, number): if number % i [python4] 0: return False return [python5]

str try else return

Replace [python#] with the appropriate code tokens to make the following snippet correct: def BalancedAB(str): if "A" not in [python1]: return True else: indexA = str.rindex("A") [python2]: indexB = str.rindex("B") if indexA < indexB: return True [python3]: return False except ValueError: [python4] False

point1 point2 return

Replace [python#] with the appropriate code tokens to make the following snippet correct: def calc_euclidean_distance([python1],[python2]): dif1 = (point1[0] - point2[0]) dif2 = (point1[1] - point2[1]) dif1sq = dif1 ** 2 dif2sq = dif2 ** 2 sq_root = (dif1sq+dif2sq)**(1/2) [python3] sq_root

False

Some of the advantages of the component-based software development are the efficiency through easier catalog lookup of components and the fact that we cannot recycle components.

True

System Testing is used to evaluate the software's compliance with the specified requirements.

Integrate Acceptance

The steps of testing in software development are (from bottom to top levels): unit testing, _____ testing, system testing and _____ testing.

True

UTF-8 is compatible with ASCII.

False

UTF-8 is not byte oriented.

True

Unit Testing is actually "automated testing" - tests are run by the machine. On the other hand, "Manual testing", where a human runs the program and interacts with it to find bugs, is a separate subject.

True

Unit Testing is an optional part of software development used to evaluate each code component; find out how well it performs and determine how well it reacts to valid or invalid input.

False

Unit Testing per se is the practice of writing code (separate from your actual application code) that invokes the code it tests to help determine if there are any errors. It also proves that code is correct.

3

What is the expected output? #Remember that ** is the exponentiation operator a = 1 b = a ** 0 if b < (a+1): c = 1 elif b == 1: c = 2 else: c = 3 print(a + b +c)

h

What is the expected output? v = 'hello' def x(a): z = a[0] return z print(x(v))

Strategy Pattern

What is the name of the design pattern that defines a family of algorithms, encapsulates each one, and makes them interchangeable? It also lets the algorithm vary independently from the clients that use it. Moreover, it captures the abstraction in an interface and buries implementation details in derived classes.

Observer Pattern

What is the name of the design pattern that defines a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically?

Integration Testing

What is the name of the test in software development that checks the robustness of the interaction between integrated units and exposes defects in the interfaces and components?

0

What is the result of the following comparison? #Remember that XOR is a logic gate that returns true when both values are different. #The operator ^ is one of the ways that you compute XOR in Python XOR(0,0) = 0 XOR(0,1) = 1 XOR(1,0) = 1 XOR(1,1) = 0 Val = 1 Val2 = 0 Val = Val ^ Val2 Va2 = Val ^ Val2 Val = Val ^ Val2 print(val)

[ 0, 1 ] [ 3, 2, 1, 0, 1, 4 ]

What will the function calls output? def f(x, l= [ ] ): for i in range(x): l.append(i*i) print(l) f(2) f(3, [3, 2, 1])

SPAMMAPS

What will the output be? s = 'SPAM' def f(x): return s + 'MAPS' print(f(s))

37 33

What would this print? Class Elf(): def __init__(self, level, ability_scores=None): self.level = level self.ability_scores = { ........ "cha":13 } if ability_scores is None else ability_scores self.hp=20 + self.ability_scores["cha"] gregelf = Elf('first_level', {....."cha" :17} ) print(gregelf.hp) zelda = Elf('second_level) print(zelda.hp)

a b c

What would this print? dict = { 'a': 1, 'b': 2, 'c': 3} for item in dict.keys(): print(item)

list1[1]: artificial intelligence list2[1:5]: [2, 3, 4, 5]

What would this print? list1 = ['robotics', 'artificial intelligence', 2015, 2010] list2 = [ 1, 2, 3, 4, 5, 6, 7] print("list1: ", list1[1]) print("list2: ", list2[1:5])

def : == == else

[pyhton0] fibonacci(x)[python1] if x[python2] 0: return 0 elif x [python3] 1: return 1 [python4] return fibonacci(x-1) + fibonacci(x-2) print(fibonacci(5))

< elif 1 n * factorial(n-1)

def factorial (n): if n [python1] 0: return 0 [python2] n == 0 return [python3] else: return [python4]


संबंधित स्टडी सेट्स

Chapter 4 - Life Policy Provisions and Options

View Set

Ethnocentrism Vs. Cultural Relativism

View Set

Lesson 1 : Introduction to Web Development

View Set

FIN 310 CHAPTER 10, Fin 310 Chapter 9, Fin 310 Chapter 8, FIN 310 Chapter 6, Fin 310 Chapter 7

View Set

ATI Parenteral (IV) Medications Test

View Set