• Wrong document? Swap it for free
  • Written by students who passed
  • Immediately available after payment
  • Read online or as PDF
Sell
Where do you study
Your language
Document preview thumbnail
Preview 3 out of 19 pages
Exam (elaborations)

D385 Pre-Assessment (All Correct) Questions with Accurate Answers

Document preview thumbnail
Preview 3 out of 19 pages

# unit test case import unittest def multiply_numbers(x, y): #add your code here return x * y # add your code here class TestForNone(unittest.TestCase): def test_when_a_is_null(self): try: tIsNone(multiply_numbers(5, None)) except AssertionError as msg: print(msg) if __name__ == '__main__': () correct answer if x is None: print("x is a null value") return y elif y is None:

Content preview

D385 Pre-Assessment (All
Correct) Questions with Accurate
Answers
# unit test case
import unittest
def multiply_numbers(x, y):
#add your code here
return x * y
# add your code here



class TestForNone(unittest.TestCase):


def test_when_a_is_null(self):
try:
self.assertIsNone(multiply_numbers(5, None))
except AssertionError as msg:
print(msg)
if __name__ == '__main__':
unittest.main() correct answer if x is None:
print("x is a null value")
return y

,elif y is None:
print("y is a null value")
return x
else:
return x * y


# verify we only have digits
def check_numeric_value(wg_int):
return isinstance(wg_int, int)


#return true if numeric value is an integer, else return false.
#Hint: use isinstance function
# verify if the string is null
def check_null_string (wg_string):



# check if wg_string is not null return true else return false


if __name__ == '__main__':


wg_string = "I like dogs." # use keyword None to test
wg_int = 12345

, print(check_null_string (wg_string))
print(check_numeric_value(wg_int)) correct answer return
isinstance(wg_int, int)


return wg_string is not None


#check if the input range is between 1 and 10 for the range validation
check
if __name__ == '__main__':


r = range(1,10)


num = int(input())


# create conditional statement for range check here correct answer r =
range(1,11)


num = int(input())


if num in r:
print("The number input is in the range from 1 and 10.")
else:
print("The number input is not in the range from 1 and 10.")

Document information

Uploaded on
June 26, 2025
Number of pages
19
Written in
2024/2025
Type
Exam (elaborations)
Contains
Questions & answers
$18.99

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

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.
starwid
3.4
(5)
Sold
20
Followers
1
Items
12012
Last sold
3 months ago



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