Dump 3
Dump 3
When setting a boolean variable, the value must start with a capital letter.
a=10b=5c=2d=Truex=a+b%dy=d+b**cifx<y:print("we made it")
You are working on the code shown in the answer
ares. You need to evaluate the expressions to decide
on a suitable operator placed between x and y so we a=10b=5c=2d=Truex=a+b+dy=d+b**cifx<y:print("we made it")
made it is printed on the screenWhich operator should
you use? To answer, select the appropriate option from
the drop-down menu.Choose the correct options
a=10b=5c=2d=Truex=a+b/dy=d+b**cifx<y:print("we made it")
print(pieces[-1])
'
//
def division(a, b).return
a/btry:division(4.0)division("3","4")except(ZeroDivisonError,TypeError)
as e:print(f'exception caught "%s" {e}')
You have the code shown in the answer area.You need
to add code to catch multiple exceptions in one
try:division(4.0)division("3","4")except(Error,TypeError) as
exception block.Which line of code should you use? To e:print('exception caught "%s" %e)dof division(a, b).istum a/b
answer, select the appropriate option from the drop-
down menu.Choose the correct options
try:division(4.0)division("3","4")except(ZeroDivisor,TypeError) as
e:print('exception caught "%s" %e)def division(a, b).return a/b
try:division(4.0)division("3","4")except(DivisorError,TypeError) as
e:print('exception caught "%s" %e)
A developer is building a code block to log a current datetime.datetime.today()
date and time for app activity. Which two code snippets
will replace the #current date and time comment with
the correct date and time?import datetimelog_time = datetime.datetime.strptime()
#current date and timeprint("entry time: ",log time)
datetime.datetime.now()
datetime.datetime.strftime()
while x <11print(str()+x+at(X)strin+x))x+=1
You have the following code:n=4x=1You need to print
out a multiplication table for 4 x 1 through 4 x 10, with while x < 11:print(str(n) str()+(x)x+=1
each output on a separate lineThe first output should
be4x10=4The last output should be 4x10=40Chose the
correct Answer while x < 11:print(str(n)+'x'+ str(x)+'='+str(n*x))x+=1
while
31
You are writing code to have activity for every day in a
30-day program. There should be no activity on day continue
15.Using the dropdown arrows, fill in the missing
pieces to the code.
{select} dailyProgram in range(1, {select} ): 30
if dailyProgram == 15:
print("No activity on day 15")
{select} for
print(f"This is day {dailyProgram}")
else
break
Evaluate the following code:def score_adj (score,
rank):new_score = scoreif score > 3000 and rank > score1 = 3300
3:new_score += 300elif score > 2500 and rank >
2:new_score += 250else:new_score += 50return
new_scorescore1 = score_adj (3000, 3)score2 = score3 = 5300
score_adj (2000, 2)score3 = score_adj (5000,
5)print(score1, score2, score3)For each statement
regarding the results of the code, indicate a Yes if the score2 = 2250
statement is true and No if the statement is false.
for x in cities:
A developer is writing code to iterate printing cities and
state, with the end result looking like this:Orange for
FloridaOrange OhioOrange IllinoisSpringfield
FloridaSpringfield OhioSpringfield IllinoisCapitalAuburn for y in states:
FloridaAuburn OhioAuburn IllinoisThe first two lines of
code are as follows:cities = ["Orange", "Springfield",
"Auburn"]states = ["Florida", "Ohio", "Illinois"]Using the if x == "Springfield" and y = "Illinois":
dropdown arrows, complete the code necessary to
generate the above output.
cities = ["Orange", "Springfield", "Auburn"] if x = "Springfield" and "y" = "Illinois":
states = ["Florida", "Ohio", "Illinois"]
{select}
{select} for"x"
print(x, y)
{select}
print("Capital")
if "x "= "Springfield" and "y "= = "Illinois":
for y = in states:
...
A developer wants documentation for a function to
display when called upon in a print statement. Use the
dropdown menus to fill in the remainder of the code ...
necessary to generate the documentation.
def area(width, height):
area._doc_
{select} Generates the area of a rectangle {select}
random.randrange(5, 12, 1)
Review the following code segment:product = 2n =
5while (n!= 0):product *= nprint (product)n = 1if n == 1
3:breakHow many lines of output does the code print?
2
4
A company needs help updating their file system. You
must create a simple file manipulation program that
os.path.isfile(myFile.txt'):
performs the following actionsChecks to see whether a
file existsIf the file exists, displays its contentsComplete
the code by selecting the correct code segment from print(file.read())
each drop-down listNote. You will receive partial credit
for each correct selection
import os os.path.isfile(myFile.txt'):
if {select}
file = open('myfile.txt')
{select} print(file.read())
file.close()
(0:10)
You are writing a function to read a data file and print
the results as a formatted table. You write code to read
(1:5.1f)
a line of data into a list named fields.The printout must
be formatted to meet the following requirementsFruit
name (field [0]): Left-aligned in a column 10 spaces (2:7.2f)
wide.Weight (fields[1]): Right-aligned in a column 5
spaces wide with one digit after the decimal point.Price
(fields[2]): Right aligned in a column 7 spaces wide with {10:0}
two digits after the decimal pointThe following shows a
one-line sample of the output:Oranges 5.6 1.33
print(" {select} {select} {select} ", format(fields[0], {5:1f}
eval(fields[1]), rval(field [2])))
{7:2f}
A company needs help updating its file system. You
must create a simple file-manipulation program that open('myFile.txt', 'a')
performs the following actions:• Creates a file using the
specified name.Appends the phrase "End of listing" to
the file.You need to complete the code to meet the file write
requirements.Complete the code by selecting the
correct code segment from each drop-down list.Note:
You will receive partial credit for each correct selection. open('myFile.txt')
import os
file= {select}
{select} ("End of listing") file read
file.close()
Python will not check the syntax of lines 01 through 04.
You create the following Python function to calculate
the power of a number. Line numbers are included for
reference only.# The calc_power function calculates The pound sign (#) is optional for lines 02 and 03.
exponents# x is the base#y is the exponent# The value
of x raised to the y power is returneddef calc_power(x,
y):comment = "# Return the value"return x ** y # raise x The string in line 06 will be interpreted as a comment.
to the y powerFor each statement, select True or False.
5
A bicycle company is creating a program that allows
customers to log the number of miles biked. The 01 def get_name():
program will send messages based on how many miles
the customer logs.You write the following Python code.
01 def get_name(biker):
Line numbers are included for reference only.02
name=input("What is your name? ") 03 return name
calories= miles * calories_per_milereturn 01 def get_name(name):
caloriesdistance = int(input("How many miles did you
bike this week? "))burn _rate = 50biker=
get_name()calories_burned = calc_calories (distance, 04 def calc_calories():
burn_rate)print(biker, ", you burned about",
calories_burned, " calories.")You need to define the
two required functions.Which two code segments 04 def calc_calories (miles, burn_rate):
should you use for line 01 and line 04? Each correct
answer presents part of the solution. (Choose 2.)
04 def calc_calories (miles, calories_per_mile):
if num>-10 and num
You are writing a Python program to determine if a
number (num) the user inputs is one, two, or more than
two digits (digits).Complete the code by selecting the elif num > -100 and num
correct code segment from each drop-down list.
num = int(input("Enter a number with 1 or 2 digits: "))
digits = "0" else
{select}
digits = "1"
{select}
if num 10.
digits = "2"
{select} elif num 100
digits = "2"
print(digits + " digits.")
if
You build a unit test module as shown belowimport
unittestclass
denoClass(unittest.TestCase):@unittest.skipUnless(25,
"Message 1")def test_number(self):self.assertTrue(2 >
5, "Message 1")def test number4
test_number2(self):self.fail("Message
2")self.skipTest("Message 2")def test_number3(self):if
"demo".isalpha():self.skipTest("Message test number3
3")else:[email protected]("demo".upper() !=
"DEHO", "Message 4")def
test_number4(self):self.assertEqual("DEMO".lower(),
test number2
"DEMO", "Message 4")if ___name__ ==
'__main__':unittext.main()Which two test methods will test number1
be skipped in the test results, without being counted as
a failure orsuccess? Each correct answer presents a
complete solutionChose the correct Answer: