[Q18-Q37] Pass 98-381 Exam in First Attempt Guaranteed 100% Cover Real Exam Questions [Jan-2022]

Share

Pass 98-381 Exam in First Attempt Guaranteed 100% Cover Real Exam Questions [Jan-2022]

Valid 98-381 test answers & Microsoft 98-381 exam pdf


What is the duration of the 98-381 Exam

  • Passing Score: 70%
  • Format: Multiple choices, multiple answers, drag & drop, selection from drop-down list
  • Number of Questions: 40
  • Length of Examination: 45 minutes

 

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

Answer: A

Explanation:
References: https://pythontips.com/2014/01/15/the-open-function-explained/

 

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

Answer:

Explanation:

Explanation/Reference:
Explanation:
References: http://effbot.org/zone/python-with-statement.htm

 

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

Answer: D

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

 

NEW QUESTION 21
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 06
  • B. Line 03
  • C. Line 01
  • D. Line 04
  • E. Line 08
  • F. Line 05
  • G. Line 07
  • H. Line 02

Answer: A

Explanation:
Explanation:

 

NEW QUESTION 22
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 23
Evaluate the following Python arithmetic expression:

What is the result?

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

Answer: A

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

 

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

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

 

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

Answer: C,F

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

 

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

Answer: D

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 28
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.sqrt as squareRoot
  • D. from math import sqrt as squareRoot

Answer: D

 

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

Answer:

Explanation:

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

 

NEW QUESTION 30
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 D
  • B. Option A
  • C. Option C
  • D. Option B

Answer: D

 

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

Explanation:

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

 

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

Answer:

Explanation:

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

 

NEW QUESTION 33
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 D
  • B. Option A
  • C. Option C
  • D. Option B

Answer: D

 

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

Answer:

Explanation:

Explanation/Reference:
References:
http://www.pythonforbeginners.com/comments/comments-in-python
https://www.w3resource.com/python/python-string.php

 

NEW QUESTION 35
HOTSPOT
The ABC organics company needs a simple program that their call center will use to enter survey data for a new coffee variety.
The program must accept input and return the average rating based on a five-star scale. The output must be rounded to two decimal places.
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.
NOTE: Each correct selection is worth one point.
Hot Area:

Answer:

Explanation:

Explanation/Reference:
References: https://www.w3resource.com/python/python-format.php#num

 

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

Answer:

Explanation:

Section: (none)
Explanation/Reference:
Explanation:
References: http://effbot.org/zone/python-with-statement.htm

 

NEW QUESTION 37
......

98-381 Exam Questions – Valid 98-381 Dumps Pdf: https://www.practicedump.com/98-381_actualtests.html