HOTSPOT
You find errors while evaluating the following code. Line numbers are included for reference only.
You need to correct the code at line 03 and line 06.
How should you correct the code? Use the drop-down menus to select the answer choice that answers each question based
on the information presented in the code segment.
NOTE: Each correct selection is worth one point.
Hot Area:
Explanation:
References:
https://www.w3resource.com/python/python-while-loop.php
HOTSPOT
The ABC company is building a basketball court for its employees to improve company morale.
You are creating a Python program that employees can use to keep track of their average score.
The program must allow users to enter their name and current scores. The program will output the user name and the users
average score. The output must meet the following requirements: The user name must be left-aligned.
If the user name has fewer than 20 characters, additional space must be added to the right.
The average score must have three places to the left of the decimal point and one place to the right of the decimal
(XXX.X).
How should you complete the code? To answer, select the appropriate code segments in the answer area.
NOTE: Each correct selection is worth one point.
Hot Area:
Explanation:
References:
https://www.python-course.eu/python3_formatted_output.php
You are creating a Python program that shows a congratulation message to employees on their service anniversary.
You need to calculate the number of years of service and print a congratulatory message.
You have written the following code. Line numbers are included for reference only.
You need to complete the program.
Which code should you use at line 03?
B
Explanation:
int must be converted to string
You develop a Python application for your school.
You need to read and write data to a text file. If the file does not exist, it must be created. If the file has content, the content
must be removed.
Which code should you use?
C
Explanation:
Modes 'r+', 'w+' and 'a+' open the file for updating (reading and writing). Mode 'w+' truncates the file.
References:
https://docs.python.org/2/library/functions.html https://pythontips.com/2014/01/15/the-open-function-explained/
DRAG DROP
You are writing a Python program to perform arithmetic operations.
You create the following code:
What is the result of each arithmetic expression? To answer, drag the appropriate expression from the column on the left to
its result on the right. Each expression may be used once, more than once, or not at all.
Select and Place:
Explanation:
References:
https://www.w3resource.com/python/python-operators.php
HOTSPOT
You create a function to calculate the power of a number by using Python.
You need to ensure that the function is documented with comments.
You create the following code. Line numbers are included for reference only.
For each of the following statements, select Yes if the statement is true. Otherwise, select No.
Hot Area:
Explanation:
References:
http://www.pythonforbeginners.com/comments/comments-in-python
https://www.w3resource.com/python/python-string.php
You develop a Python application for your company.
You need to accept input from the user and print that information to the user screen.
You have started with the following code. Line numbers are included for reference only.
Which code should you write at line 02?
B
HOTSPOT
You are developing a Python application for your company.
You write the following code:
Use the drop-down menus to select the answer choice that answers each question based on the information presented in
the code segment.
Hot Area:
Explanation:
References:
https://www.w3resource.com/python/python-list.php
HOTSPOT
You create the following program to locate a conference room and display the room name. Line numbers are included for
reference only.
Colleagues report that the program sometimes produces incorrect results.
You need to troubleshoot the program. Use the drop-down menus to select the answer choice that answers each question
based on the information presented in the code segment.
Hot Area:
Explanation:
References:
https://www.w3resource.com/python/python-data-type.php https://www.w3resource.com/python/python-if-else-
statements.php
You are creating a function that manipulates a number. The function has the following requirements:
A float is passed into the function
The function must take the absolute value of the float
Any decimal points after the integer must be removed
Which two math functions should you use? Each correct answer is part of the solution. (Choose two.)
C E
Explanation:
C: math.floor(x) returns the largest integer less than or equal to x. E: math.fabs(x) returns the absolute value of x.
Incorrect Answers:
A: math.fmod() takes two variables
B: math.frexp(x) returns the mantissa and exponent of x as the pair (m, e). m is a float and e is an integer D: math.ceil(x)
returns the smallest integer greater than or equal to x
References:
https://docs.python.org/2/library/math.html#number-theoretic-and-representation-functions
https://docs.python.org/3/library/math.html