[2021] Pass 98-381 Exam - Real Questions & Answers [Q18-Q36]

Share

[2021] Pass 98-381 Exam - Real Questions & Answers

98-381 Exam Questions Get Updated [2021] with Correct Answers

NEW QUESTION 18
The ABC company has hired you as an intern on the coding team that creates e-commerce applications.
You must write a script that asks the user for a value. The value must be used as a whole number in a calculation, even if the user enters a decimal value.
You need to write the code to meet the requirements.
Which code segment should you use?

  • A. totalItems = str(input("How many items would you like?"))
  • B. totalItems = input("How many items would you like?")
  • C. totalItems = float(input("How many items would you like?"))
  • D. totalItems = int(input("How many items would you like?"))

Answer: B

Explanation:
Explanation/Reference:
References: http://www.informit.com/articles/article.aspx?p=2150451&seqNum=6

 

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

Answer:

Explanation:

Explanation/Reference:
References:
https://docs.python.org/3.1/tutorial/inputoutput.html
https://stackoverflow.com/questions/11619942/print-series-of-prime-numbers-in-python
https://www.programiz.com/python-programming/examples/prime-number-intervals

 

NEW QUESTION 20
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. No change is needed
  • D. The code will generate a runtime error

Answer: C

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

 

NEW QUESTION 21
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" + int(end - start) + "years of service!")
  • B. print("Congratulations on" + (int(end)-int(start)) + "years of service!")
  • C. print("Congratulations on" + str(end - start)) + "years of service!")
  • D. print("Congratulations on" + str(int(end)-int(start)) + "years of service!")

Answer: D

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

 

NEW QUESTION 22
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.randrange(5, 11, 1)
  • B. random.randint(5, 12)
  • C. random.randint(5, 11)
  • D. random.randrange(5, 12, 1)

Answer: A,C

Explanation:
Section: (none)
Explanation/Reference:
References: https://docs.python.org/3/library/random.html#

 

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

Explanation/Reference:
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 24
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 25
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 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. 04 def calc_calories():
  • C. 01 def get_name(name):
  • D. 01 def get_name(biker):
  • E. 04 def calc_calories(miles, calories_per_mile):
  • F. 01 def get_name():

Answer: A,D

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

 

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

Answer:

Explanation:

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

 

NEW QUESTION 28
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" + int(end - start) + "years of service!")
  • B. print("Congratulations on" + (int(end)-int(start)) + "years of service!")
  • C. print("Congratulations on" + str(end - start)) + "years of service!")
  • D. print("Congratulations on" + str(int(end)-int(start)) + "years of service!")

Answer: D

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

 

NEW QUESTION 29
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 30
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.

Answer:

Explanation:

Explanation:

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

 

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

Answer:

Explanation:

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

 

NEW QUESTION 32
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.
Select and Place:

Answer:

Explanation:

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

 

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

Answer:

Explanation:

Explanation/Reference:
References:
https://docs.python.org/3.1/tutorial/inputoutput.html
https://stackoverflow.com/questions/11619942/print-series-of-prime-numbers-in-python
https://www.programiz.com/python-programming/examples/prime-number-intervals

 

NEW QUESTION 34
DRAG DROP
You are creating a Python script to evaluate input and check for upper and lower case.
Which four code segments should you use to develop the solution? To answer, move the appropriate code
segment from the list of code segments to the answer area and arrange them in the correct order.
Select and Place:

Answer:

Explanation:

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

 

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

Answer:

Explanation:

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

 

NEW QUESTION 36
......


Exam Domains

The entire Microsoft 98-381 syllabus can be divided into six sections that are disclosed below in detail.

Practice 98-381 Questions With Certification guide Q&A from Training Expert Exam-Killer: https://www.exam-killer.com/98-381-valid-questions.html