DRAG DROP
You are building a Python program that displays all of the prime numbers from 2 to 100.
How should you complete the code? To answer, drag the appropriate code segments to the correct location. Each code segment may be used once, more than once, or not at all. You may need to drag the split bar between panes or scroll to
view content.
NOTE: Each correct selection is worth one point.
Select and Place:
DRAG DROP
Match the data type to the type operations.
To answer, drag the appropriate data type to the correct type operation. Each data type may be used once, more than once, or not at all.
Select and Place:
DRAG DROP
You are writing a function that works with files.
You need to ensure that the function returns None if the file does not exist. If the file does exist, the function must return the first line.
You write the following code:
In which order should you arrange the code segments to complete the function? To answer, move all code segments from the list of code segments to the answer area and arrange them in the correct order.
Select and Place:
HOTSPOT
You work for a company that distributes media for all ages.
You are writing a function that assigns a rating based on a user's age. The function must meet the following requirements:
Anyone 18 years old or older receives a rating of “A”
Anyone 13 or older, but younger than 18, receives a rating of “T”
Anyone 12 years old or younger receives a rating of “C”
If the age is unknown, the rating is set to “C”
You need to complete the code to meet the requirements.
How should you complete the code? To answer, select the appropriate code segments in the answer area.
Hot Area:
HOTSPOT
The ABC company needs a way to find the count of particular letters in their publications to ensure that there is a good balance. It seems that there have been complaints about overuse of the letter e. You need to create a function to meet the
requirements.
How should you complete this code? To answer, select the appropriate code segments in the answer area.
NOTE: Each correct selection is worth one point.
Hot Area:
HOTSPOT
The ABC Video company needs a way to determine the cost that a customer will pay for renting a DVD. The cost is dependent on the time of day the DVD is returned. However, there are also special rates on Thursdays and Sundays. The fee
structure is shown in the following list:
The cost is $1.59 per night.
If the DVD is returned after 8 PM, the customer will be charged an extra day.
If the video is rented on a Sunday, the customer gets 30% off for as long as they keep the video.
If the video is rented on a Thursday, the customer gets 50% off for as long as they keep the video.
You need to write code to meet the requirements.
How should you complete the code? To answer, select the appropriate code segments in the answer area.
Hot Area:
HOTSPOT
You are developing a Python application for an online game.
You need to create a function that meets the following criteria: The function is named update_score The function receives the current score and a value The function adds the value to the current score The function returns the new score
How should you complete the code? To answer, select the appropriate code segments in the answer area.
Hot Area:
Evaluate the following Python arithmetic expression:
What is the result?
A. 3
B. 13
C. 15
D. 69
You are writing a Python program to automate inventory. Your first task is to read a file of inventory transactions. The file contains sales from the previous day, including the item id, price, and quantity. The following shows a sample of data from the file:
The code must meet the following requirements: Each line of the file must be read and printed If a blank line is encountered, it must be ignored When all lines have been read, the file must be closed
You create the following code. Line numbers are included for reference only.
Which code should you write for line 05 and line 06?
A. Option A
B. Option B
C. Option C
D. Option D
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?
A. name = input
B. input("name")
C. input(name)
D. name = input()