[Sep-2021] Microsoft Python 98-381 Exam Practice Dumps [Q14-Q39]

Share

[Sep-2021] Microsoft Python 98-381 Exam Practice Dumps

2021 98-381 Premium Files Test pdf - Free Dumps Collection

NEW QUESTION 14
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.

Answer:

Explanation:

Explanation:

References: https://www.w3resource.com/python/python-list.php

 

NEW QUESTION 15
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.

Answer:

Explanation:

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

 

NEW QUESTION 16
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.

Answer:

Explanation:

Explanation:

References: https://www.w3resource.com/python/python-while-loop.php

 

NEW QUESTION 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. The code runs, but generates a logic error
  • B. The code will generate a syntax error
  • C. The code will generate a runtime error
  • D. No change is needed

Answer: D

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

 

NEW QUESTION 18
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?

  • A. print("Congratulations on" + str(int(end)-int(start)) + "years of service!"
  • B. print("Congratulations on" + int(end - start) + "years of service!"
  • C. print("Congratulations on" + str(end - start)) + "years of service!"
  • D. print("Congratulations on" + (int(end)-int(start)) + "years of service!"

Answer: D

 

NEW QUESTION 19
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:

Answer:

Explanation:

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

 

NEW QUESTION 20
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:

Section: (none)
Explanation/Reference:
References: https://www.w3resource.com/python/python-data-type.php

 

NEW QUESTION 21
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. 04 def calc_calories(miles, calories_per_mile):
  • B. 01 def get_name():
  • C. 04 def calc_calories():
  • D. 01 def get_name(name):
  • E. 01 def get_name(biker):
  • F. 04 def calc_calories(miles, burn_rate):

Answer: A,B

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

 

NEW QUESTION 22
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?

  • A. print("Congratulations on" + str(int(end)-int(start)) + "years of service!"
  • B. print("Congratulations on" + int(end - start) + "years of service!"
  • C. print("Congratulations on" + str(end - start)) + "years of service!"
  • D. print("Congratulations on" + (int(end)-int(start)) + "years of service!"

Answer: D

Explanation:
Explanation:

 

NEW QUESTION 23
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?
print("Congratulations on" + (int(end)-int(start)) +

  • A. "years of service!")
    print("Congratulations on" + str(int(end)-int(start)) +
  • B. "years of service!")
    print("Congratulations on" + int(end - start) +
  • C. "years of service!")
  • D. "years of service!")
    print("Congratulations on" + str(end - start)) +

Answer: B

Explanation:
Explanation/Reference:
int must be converted to string

 

NEW QUESTION 24
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:

Answer:

Explanation:

Section: (none)
Explanation/Reference:
References: https://www.w3resource.com/python/python-operators.php

 

NEW QUESTION 25
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.

Answer:

Explanation:

b = (-a)**2

 

NEW QUESTION 26
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.

Answer:

Explanation:

Explanation:

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

 

NEW QUESTION 27
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:

Answer:

Explanation:

Section: (none)
Explanation/Reference:
References: https://www.w3resource.com/python/python-list.php

 

NEW QUESTION 28
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", "w+")
  • B. open("local_data", "w")
  • C. open("local_data", "r")
  • D. open("local_data", "r+")

Answer: A

Explanation:
Explanation/Reference:
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/

 

NEW QUESTION 29
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:

B:

C:

D:

  • A. Option A
  • B. Option D
  • C. Option B
  • D. Option C

Answer: A

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

 

NEW QUESTION 30
Evaluate the following Python arithmetic expression:

What is the result?

  • A. 0
  • B. 1
  • C. 2
  • D. 3

Answer: C

Explanation:
Explanation/Reference:
References: http://www.mathcs.emory.edu/~valerie/courses/fall10/155/resources/op_precedence.html

 

NEW QUESTION 31
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. 04 def calc_calories(miles, calories_per_mile):
  • B. 01 def get_name():
  • C. 04 def calc_calories():
  • D. 01 def get_name(name):
  • E. 01 def get_name(biker):
  • F. 04 def calc_calories(miles, burn_rate):

Answer: A,B

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

 

NEW QUESTION 32
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", "w+")
  • B. open("local_data", "w")
  • C. open("local_data", "r+")
  • D. open("local_data", "r")

Answer: C

Explanation:
Section: (none)
Explanation/Reference:
References: https://pythontips.com/2014/01/15/the-open-function-explained/

 

NEW QUESTION 33
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.

Answer:

Explanation:

References:
https://www.w3resource.com/python/python-while-loop.php

 

NEW QUESTION 34
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:

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

 

NEW QUESTION 35
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 sqrt from math as squareRoot
  • B. from math import sqrt as squareRoot
  • C. from math.sqrt as squareRoot
  • D. import math.sqrt as squareRoot

Answer: B

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

 

NEW QUESTION 36
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?

  • A. print("Congratulations on" + str(int(end)-int(start)) + "years of service!"
  • B. print("Congratulations on" + int(end - start) + "years of service!"
  • C. print("Congratulations on" + str(end - start)) + "years of service!"
  • D. print("Congratulations on" + (int(end)-int(start)) + "years of service!"

Answer: D

Explanation:
Section: (none)

 

NEW QUESTION 37
You develop a Python application for your company.
A list named employees contains 200 employee names, the last five being company management. You need to slice the list to display all employees excluding management.
Which two code segments should you use? Each correct answer presents a complete solution. (Choose two.)

  • A. employees [1:-4]
  • B. employees [:-5]
  • C. employees [1:-5]
  • D. employees [0:-5]
  • E. employees [0:-4]

Answer: D

Explanation:
Section: (none)
Explanation/Reference:
References: https://www.w3resource.com/python/python-list.php#slice

 

NEW QUESTION 38
DRAG DROP
You are writing a Python program. The program collects customer data and stores it in a database.
The program handles a wide variety of data.
You need to ensure that the program handles the data correctly so that it can be stored in the database correctly.
Match the data type to the code segment. To answer, drag the appropriate data type from the column on the left to its code segment on the right. Each data type may be used once, more than once, or not at all.

Answer:

Explanation:

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

 

NEW QUESTION 39
......

Get ready to pass the 98-381 Exam right now using our Microsoft Python  Exam Package: https://www.itexamsimulator.com/98-381-brain-dumps.html