Valid 98-381 Exam Q&A PDF 98-381 Dump is Ready (Updated 42 Questions)
Exam Questions and Answers for 98-381 Study Guide
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" + 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 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
NEW QUESTION 23
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.randint(5, 12)
- B. random.randrange(5, 12, 1)
- C. random.randrange(5, 11, 1)
- D. random.randint(5, 11)
Answer: B,D
Explanation:
Explanation/Reference:
References: https://docs.python.org/3/library/random.html#
NEW QUESTION 24
HOTSPOT
You work for a company that distributes media for all ages.
You are writing a function that assigns a rating based on a user's 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.
Answer:
Explanation:
References:
https://www.w3resource.com/python/python-if-else-statements.php
NEW QUESTION 25
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 26
You are writing an application that uses the sqrtfunction. 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:
Section: (none)
Explanation/Reference:
References: https://infohost.nmt.edu/tcc/help/pubs/python/web/import-statement.html
NEW QUESTION 27
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.
Answer:
Explanation:
Explanation:
References: https://www.w3resource.com/python/python-user-defined-functions.php
NEW QUESTION 28
HOTSPOT
The ABC company needs a way to find the count of particular letters in their publications to ensure that there is a good balance. It seems that there have been complaints about overuse of the letter e. You need to create a function to meet the requirements.
How should you complete this 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-for-loop.php
NEW QUESTION 29
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:
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 30
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:
References:
https://www.w3resource.com/python/python-data-type.php
https://www.w3resource.com/python/python-if-else-statements.php
NEW QUESTION 31
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 32
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.
Hot Area:
Answer:
Explanation:
Explanation/Reference:
References: https://www.w3resource.com/python/python-while-loop.php
NEW QUESTION 33
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.)
- A. math.fabs(x)
- B. math.fmod(x)
- C. math.floor(x)
- D. math.frexp(x)
- E. math.ceil(x)
Answer: A,E
Explanation:
References: https://docs.python.org/2/library/math.html#number-theoretic-and- representation-functions
NEW QUESTION 34
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 35
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 07
- B. Line 05
- C. Line 02
- D. Line 06
- E. Line 01
- F. Line 04
- G. Line 03
- H. Line 08
Answer: D
NEW QUESTION 36
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 = input("How many items would you like?")
- B. totalItems = float(input("How many items would you like?"))
- C. totalItems = int(input("How many items would you like?"))
- D. totalItems = str(input("How many items would you like?"))
Answer: A
Explanation:
Explanation/Reference:
References: http://www.informit.com/articles/article.aspx?p=2150451&seqNum=6
NEW QUESTION 37
......
Certification dumps - Microsoft Python 98-381 guides - 100% valid: https://www.guidetorrent.com/98-381-pdf-free-download.html