Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Exam (elaborations)

WMU CS2 Final Ques &ANSW

Rating
-
Sold
-
Pages
8
Uploaded on
14-11-2023
Written in
2023/2024

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:The os Module's remove and rename functions delete a file and specify a new name for a file, respectively

Show more Read less
Institution
Course

Content preview

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' }

Written for

Course

Document information

Uploaded on
November 14, 2023
Number of pages
8
Written in
2023/2024
Type
Exam (elaborations)
Contains
Unknown

Subjects

$10.79
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
smartchoices Chamberlain College Of Nursing
Follow You need to be logged in order to follow users or courses
Sold
36
Member since
5 year
Number of followers
5
Documents
4499
Last sold
2 weeks ago

4.8

9 reviews

5
7
4
2
3
0
2
0
1
0

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions