100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached
logo-home
WMU CS2 Final Ques &ANSW $9.99   Add to cart

Exam (elaborations)

WMU CS2 Final Ques &ANSW

 0 view  0 purchase
  • Course
  • Institution

WMU CS2 Final Ques &ANSW Which would be the base case in a recursive solution to the problem of finding the factorial of a number. Recall that the factorial of a non-negative whole number is defined as n! where:

Preview 2 out of 8  pages

  • November 14, 2023
  • 8
  • 2023/2024
  • Exam (elaborations)
  • Questions & answers
avatar-seller
WMU CS2 Final Ques &ANSW

Which would be the base case in a recursive solution to the problem of finding the
factorial of a number. Recall that the factorial of a non-negative whole number is defined
as n! where:
If n = 0, then n! = 1
If n > 0, then n! = 1 x 2 x 3 x ... x n - ANSW n = 0

The os Module's remove and rename functions delete a file and specify a new name for
a file, respectively. - ANSW True

__________ has the ability to define a method in a subclass and then define a method
with the same name in a superclass. - ANSW Polymorphism

What will the following program display?
def main():my_string = 'One, two, three, four'
word_list = my_string.split()
print(word_list)
main() - ANSW ['One,', 'two,', 'three,', 'four']

Which would you use to delete an existing key-value pair from a dictionary? - ANSW
del

A function is called from the main function for the first time and then calls itself seven
times. What is the depth of recursion? - ANSW 7

What will the following program display?
def main():print(test2(18, 5))def test2(x, y):if x < y:return -5else:return (test2(x-y, y+5) +
6)main() - ANSW 7

The base case is the case in which the problem can be solved without - ANSW
recursion

What is the number of the first index in a dictionary? - ANSW Dictionaries are not
indexed by number.

Converting objects to JSON text format known as serializing - ANSW True

If you try to retrieve a value from a dictionary using a nonexistent key, a KeyError
exception is raised. - ANSW True

What will the following program display?
class Test:
def __init__(self):

, self.num1 = 0class
Derived_Test(Test):
def __init__(self):
self.num2 = 1def
main():
show = Derived_Test()
print(show.num1,show.num2)
main() - ANSW Error because class Derived_Test inherits Test but variable num1 isn't
inherited

Combining data and code in a single object is known as - ANSW encapsulation

Which of the following will create an object, worker_joey, of the Worker class? - ANSW
worker_joey = Worker()

Invalid indexes do not cause slicing expressions to raise an exception - ANSW
Question options:
True

A mutator method has no control over the way that a class's data attributes are
modified. - ANSW False

In a UML diagram the first section holds the list of the class's methods. - ANSW False

What will be displayed after the following code executes?
mystr = 'yes'
yourstr = 'no'
mystr += yourstr * 2
print(mystr) - ANSW yesnono

If the start index is __________ the end index, the slicing expression will return an
empty string. - ANSW greater than

What type of method provides a safe way for code outside a class to retrieve the values
of attributes, without exposing the attributes in a way that could allow them to be
changed by code outside the method? - ANSW accessor

When an object is passed as an argument, __________ is passed into the parameter
variable. - ANSW a reference to the object

Which section in the UML holds the list of the class's methods? - ANSW third section

What is the correct structure to create a dictionary of months where each month will be
accessed by its month number (for example, January is month 1, April is month 4)? -
ANSW { 1 : 'January', 2 : 'February', ... 12 : 'December' }

The benefits of buying summaries with Stuvia:

Guaranteed quality through customer reviews

Guaranteed quality through customer reviews

Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.

Quick and easy check-out

Quick and easy check-out

You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.

Focus on what matters

Focus on what matters

Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!

Frequently asked questions

What do I get when I buy this document?

You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.

Satisfaction guarantee: how does it work?

Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.

Who am I buying these notes from?

Stuvia is a marketplace, so you are not buying this document from us, but from seller Certifiedacademics. Stuvia facilitates payment to the seller.

Will I be stuck with a subscription?

No, you only buy these notes for $9.99. You're not tied to anything after your purchase.

Can Stuvia be trusted?

4.6 stars on Google & Trustpilot (+1000 reviews)

75057 documents were sold in the last 30 days

Founded in 2010, the go-to place to buy study notes for 14 years now

Start selling
$9.99
  • (0)
  Add to cart