31 December, 2019
Introduction To Programming Using Python 98-381 Practice
Want to know Exambible 98-381 Exam practice test features? Want to lear more about Microsoft Introduction to Programming Using Python certification experience? Study Breathing Microsoft 98-381 answers to Regenerate 98-381 questions at Exambible. Gat a success with an absolute guarantee to pass Microsoft 98-381 (Introduction to Programming Using Python) test on your first attempt.
Question 1
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 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.)
Question 2
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?
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?
Question 3
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.
Solution:
References: https://www.w3resource.com/python/python-list.php
Does this meet the goal?
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.
Solution:
References: https://www.w3resource.com/python/python-list.php
Does this meet the goal?
Question 4
HOTSPOT
The ABC company is building a basketball court for its employees to improve company morale.
You are creating a Python program that employees can use to keep track of their average score.
The program must allow users to enter their name and current scores. The program will output the user name and the user’s average score. The output must meet the following requirements:
✑ The user name must be left-aligned.
✑ If the user name has fewer than 20 characters, additional space must be added to the right.
✑ The average score must have three places to the left of the decimal point and one place to the right of the decimal (XXX.X).
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.
Solution:
References: https://www.python-course.eu/python3_formatted_output.php
Does this meet the goal?
The ABC company is building a basketball court for its employees to improve company morale.
You are creating a Python program that employees can use to keep track of their average score.
The program must allow users to enter their name and current scores. The program will output the user name and the user’s average score. The output must meet the following requirements:
✑ The user name must be left-aligned.
✑ If the user name has fewer than 20 characters, additional space must be added to the right.
✑ The average score must have three places to the left of the decimal point and one place to the right of the decimal (XXX.X).
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.
Solution:
References: https://www.python-course.eu/python3_formatted_output.php
Does this meet the goal?
Question 5
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?
You need to import the function. Which code segment should you use?
Question 6
DRAG DROP
Match the data type to the type operations.
To answer, drag the appropriate data type to the correct type operation. Each data type may be used once, more than once, or not at all.
Solution:
References: https://www.w3resource.com/python/python-data-type.php
Does this meet the goal?
Match the data type to the type operations.
To answer, drag the appropriate data type to the correct type operation. Each data type may be used once, more than once, or not at all.
Solution:
References: https://www.w3resource.com/python/python-data-type.php
Does this meet the goal?
Question 7
Evaluate the following Python arithmetic expression:
What is the result?
What is the result?
Question 8
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.
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.
Question 9
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.
Solution:
References: https://www.w3resource.com/python/python-user-defined-functions.php
Does this meet the goal?
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.
Solution:
References: https://www.w3resource.com/python/python-user-defined-functions.php
Does this meet the goal?
Question 10
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 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.)
Question 11
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.)
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.)
Question 12
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.
Solution:
References:
https://www.w3resource.com/python/python-operators.php https://www.w3resource.com/python/python-if-else-statements.php
Does this meet the goal?
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.
Solution:
References:
https://www.w3resource.com/python/python-operators.php https://www.w3resource.com/python/python-if-else-statements.php
Does this meet the goal?
Question 13
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?
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?
Question 14
You develop a Python application for your company.
You want to add notes to your code so other team members will understand it. What should you do?
You want to add notes to your code so other team members will understand it. What should you do?
Question 15
HOTSPOT
For each of the following statements, select Yes if the statement is true. Otherwise, select No.
Solution:
References: https://docs.python.org/2.0/ref/try.html
Does this meet the goal?
For each of the following statements, select Yes if the statement is true. Otherwise, select No.
Solution:
References: https://docs.python.org/2.0/ref/try.html
Does this meet the goal?
Question 16
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?
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?
Question 17
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.
Solution:
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
Does this meet the goal?
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.
Solution:
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
Does this meet the goal?
Question 18
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.)
Which two functions should you use? Each correct answer presents a complete solution. (Choose two.)
Question 19
HOTSPOT
You are coding a math utility by using Python. You are writing a function to compute roots.
The function must meet the following requirements:
How should you complete the code? To answer, select the appropriate code segments in the answer area.
Solution:
References: https://www.w3resource.com/python/python-if-else-statements.php
Does this meet the goal?
You are coding a math utility by using Python. You are writing a function to compute roots.
The function must meet the following requirements:
How should you complete the code? To answer, select the appropriate code segments in the answer area.
Solution:
References: https://www.w3resource.com/python/python-if-else-statements.php
Does this meet the goal?