exam questions

Exam 98-381 All Questions

View all questions & answers for the 98-381 exam

Exam 98-381 topic 1 question 32 discussion

Actual exam question from Microsoft's 98-381
Question #: 32
Topic #: 1
[All 98-381 Questions]

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

Show Suggested Answer Hide Answer
Suggested Answer:
References: https://www.python-course.eu/python3_formatted_output.php

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
dynamicbalaji
Highly Voted 4 years, 11 months ago
For name it should be '%-20s' because '%-20d' is for integer value
upvoted 15 times
gargaditya
4 years, 6 months ago
Correct,also 'd' and 'i' are same in the older method of printing strings(interpolation using %)which makes two answer choices just the same
upvoted 1 times
...
...
SP_RSA
Most Recent 2 years, 6 months ago
Sum was not declared, therefore we will have an error
upvoted 2 times
...
SP_RSA
2 years, 6 months ago
score = 23.4 name = "Robert" print("%-20s, your score is: %4.1f"%(name, score)) #Ouptup Robert , your score is: 23.4
upvoted 1 times
...
Mist3
3 years, 11 months ago
Without declaration of sum variable this code will produce TypeError: unsupported operand type(s) for +=: 'builtin_function_or_method' and 'int' Answer shoud be "%-20s" and "%4.1f
upvoted 4 times
...
Viki2405
4 years, 6 months ago
Answer should be D and B as its name which is string
upvoted 3 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...
exam
Someone Bought Contributor Access for:
SY0-701
London, 1 minute ago