Certbus > Microsoft > Microsoft Certifications > 98-381 > 98-381 Online Practice Questions and Answers

98-381 Online Practice Questions and Answers

Questions 4

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:

Browse 40 Q&As
Questions 5

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:

Browse 40 Q&As
Questions 6

DRAG DROP

You are writing a Python program that evaluates an arithmetic formula.

The formula is described as b equals a multiplied by negative one, then raised to the second power, where a is the value that will be input and b is the result.

You create the following code segment. Line numbers are included for reference only.

You need to ensure that the result is correct.

How should you complete the code on line 02? To answer, drag the appropriate code segment 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:

Browse 40 Q&As
Questions 7

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:

Browse 40 Q&As
Questions 8

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:

Browse 40 Q&As
Questions 9

HOTSPOT

You are developing a Python application for an online product distribution company.

You need the program to iterate through a list of products and escape when a target product ID is found.

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:

Browse 40 Q&As
Questions 10

HOTSPOT

You develop a Python application for your company.

You have the following code. Line numbers are included for reference only.

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:

Browse 40 Q&As
Questions 11

HOTSPOT

You are an intern for ABC electric cars company. You must create a function that calculates the average velocity of their vehicles on a 1320 foot (1/4 mile) track. The output must be as precise as possible.

How should you complete the code? To answer, select the appropriate code segments in the answer area.

Hot Area:

Browse 40 Q&As
Questions 12

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:

Browse 40 Q&As
Questions 13

You are writing code that generates a random integer with a minimum value of 5 and a maximum value of 11. Which two functions should you use? Each correct answer presents a complete solution. (Choose two.)

A. random.randint(5, 12)

B. random.randint(5, 11)

C. random.randrange(5, 12, 1)

D. random.randrange(5, 11, 1)

Browse 40 Q&As
Questions 14

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()

Browse 40 Q&As
Questions 15

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?

A. open("local_data", "r")

B. open("local_data", "r+")

C. open("local_data", "w+")

D. open("local_data", "w")

Browse 40 Q&As
Questions 16

You are creating a function that reads a data file and prints each line of the file. You write the following code. Line numbers are included for reference only.

The code attempts to read the file even if the file does not exist.

You need to correct the code.

Which three lines have indentation problems? Each correct answer presents part of the solution. (Choose three.)

A. Line 01

B. Line 02

C. Line 03

D. Line 04

E. Line 05

F. Line 06

G. Line 07

H. Line 08

Browse 40 Q&As
Questions 17

This question requires that you evaluate the underlined text to determine if it is correct.

You write the following code:

The out.txt file does not exist. You run the code. The code will execute without error.

Review the underlined text. If it makes the statement correct, select "No change is needed". If the statement is incorrect, select the answer choice that makes the statement correct.

A. No change is needed

B. The code runs, but generates a logic error

C. The code will generate a runtime error

D. The code will generate a syntax error

Browse 40 Q&As
Questions 18

The ABC company is creating a program that allows customers to log the number of miles biked. The program will send messages based on how many miles the customer logs. You create the following Python code. Line numbers are included for reference only.

You need to define the two required functions.

Which code segments should you use for line 01 and line 04? Each correct answer presents part of the solution? (Choose two.)

A. 01 def get_name():

B. 01 def get_name(biker):

C. 01 def get_name(name):

D. 04 def calc_calories():

E. 04 def calc_calories(miles, burn_rate):

F. 04 def calc_calories(miles, calories_per_mile):

Browse 40 Q&As
Exam Code: 98-381
Exam Name: Introduction to Programming Using Python
Last Update: Mar 17, 2025
Questions: 40 Q&As

PDF

$49.99

VCE

$55.99

PDF + VCE

$65.99