exam questions

Exam 98-381 All Questions

View all questions & answers for the 98-381 exam

Exam 98-381 topic 1 question 17 discussion

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

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)-int(start)) + "years of service!")
  • B. print("Congratulations on" + str(int(end)-int(start)) + "years of service!")
  • C. print("Congratulations on" + int(end - start) + "years of service!")
  • D. print("Congratulations on" + str(end - start)) + "years of service!")
Show Suggested Answer Hide Answer
Suggested Answer: B 🗳️
int must be converted to string

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
Neelz
Highly Voted 4 years, 9 months ago
Correct answer is - print("Congratulations on" + str(int(end)-int(start)) + "years of service!" with a + sign before str
upvoted 6 times
Fappy
4 years, 9 months ago
Correct
upvoted 2 times
...
...
print_HelloWorld
Most Recent 3 years, 1 month ago
CORRECT
upvoted 1 times
...
PavanKumpatlaAccountTwo
3 years, 5 months ago
Correct answer is B. -------------------------------------------------------------------------------------------------------------------------------- print("Congratulations on" + str(int(end)-int(start)) + "years of service!") -------------------------------------------------------------------------------------------------------------------------------- Also, imagine if the guy worked for 0 years..... -------------------------------------------------------------------------------------------------------------------------------- Congratulations on 0 years of service!
upvoted 2 times
...
gargaditya
4 years, 8 months ago
CONCEPT BEING: 1.INPUT FN ALWAYS TAKES INPUT AS A STRING,WE NEED TO CONVERT TO INTEGER OR FLOAT IN ORDER TO PERFORM MATHEMATICAL OPERATIONS 2.CONCATENATION-->AGAIN STRING CAN BE CONCATENATED WITH A STRING,WHICH MEANS THAT THE INT VALUE NEEDS TO BE RECONVERTED TO A STRING BEFORE PERFORMING CONCATENATION
upvoted 2 times
PavanKumpatlaAccountTwo
3 years, 5 months ago
Why are you using caps.
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 ...