microsoft 98-381 practice test

Exam Title: Introduction to Programming Using Python

Last update: Dec 10 ,2025
Question 1

HOTSPOT
You work for a company that distributes media for all ages.
You are writing a function that assigns a rating based on a users 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:

Answer:


Explanation:
References:
https://www.w3resource.com/python/python-if-else-statements.php

Comments
Question 2

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:

Answer:


Explanation:
References:
http://www.mathcs.emory.edu/~valerie/courses/fall10/155/resources/op_precedence.html
http://interactivepython.org/runestone/static/pythonds/BasicDS/InfixPrefixandPostfixExpressions.html

Comments
Question 3

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:

Answer:


Explanation:
References:
https://www.w3resource.com/python/python-data-type.php

Comments
Question 4

HOTSPOT
During school holidays, you volunteer to explain some basic programming concepts to younger siblings.
You want to introduce the concept of data types in Python. You create the following three code segments:

You need to evaluate the code segments.
For each of the following statements, select Yes if the statement is true. Otherwise, select No.
NOTE: Each correct selection is worth one point.
Hot Area:

Answer:


Explanation:
Code Segment 1: You cannot convert str to int. x1 = 2 is a string. Therefore code will produce an error. Code Segment


2: b = 1.5, which is a float.
Code Segment 3: c = 2.5, which is a float, not an int.

References:
https://www.w3resource.com/python/python-data-type.php

Comments
Question 5

You are writing an application that uses the sqrt function. The program must reference the function using the name
squareRoot.
You need to import the function.
Which code segment should you use?

  • A. import math.sqrt as squareRoot
  • B. import sqrt from math as squareRoot
  • C. from math import sqrt as squareRoot
  • D. from math.sqrt as squareRoot
Answer:

C


Explanation:
References:
https://infohost.nmt.edu/tcc/help/pubs/python/web/import-statement.html

vote your answer:
A
B
C
D
A 0 B 0 C 0 D 0
Comments
Question 6

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. B. OptionB
  • C. C. Option C
  • D. Option D
Answer:

A


Explanation:
https://www.dotnetperls.com/readline-python

vote your answer:
A
B
C
D
A 0 B 0 C 0 D 0
Comments
Question 7

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):
Answer:

A F


Explanation:
References:
https://www.w3resource.com/python/python-user-defined-functions.php

vote your answer:
A
B
C
D
E
F
A 0 B 0 C 0 D 0 E 0 F 0
Comments
Question 8

HOTSPOT
For each of the following statements, select Yes if the statement is true. Otherwise, select No.
Hot Area:

Answer:


Explanation:
References:
https://docs.python.org/2.0/ref/try.html

Comments
Question 9

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:

Answer:


Explanation:
References:
https://www.w3resource.com/python/python-data-type.php

Comments
Question 10

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
Answer:

A


Explanation:
References:
https://docs.python.org/2/library/exceptions.html

vote your answer:
A
B
C
D
A 0 B 0 C 0 D 0
Comments
Page 1 out of 4
Viewing questions 1-10 out of 43
Go To
page 2