Summer Special Flat 65% Limited Time Discount offer - Ends in 0d 00h 00m 00s - Coupon code: suredis

Microsoft 98-381 Introduction to Programming Using Python Exam Practice Test

Demo: 6 questions
Total 40 questions

Introduction to Programming Using Python Questions and Answers

Question 1

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?

Options:

A.

Option A

B.

Option B

C.

Option C

D.

Option D

Question 2

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

Options:

A.

Line 01

B.

Line 02

C.

Line 03

D.

Line 04

E.

Line 05

F.

Line 06

G.

Line 07

Question 3

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

Options:

A.

math.fmod(x)

B.

math.frexp(x)

C.

math.floor(x)

D.

math.ceil(x)

E.

math.fabs(x)

Question 4

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.

Options:

Question 5

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.

Options:

Question 6

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.

Options:

Demo: 6 questions
Total 40 questions