exam questions

Exam 98-381 All Questions

View all questions & answers for the 98-381 exam

Exam 98-381 topic 1 question 39 discussion

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

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. 01 def get_name():
  • B. 01 def get_name(biker):
  • C. 01 def get_name(name):
  • D. 04 def calc_calories():
  • E. 04 def calc_calories(miles, burn_rate):
  • F. 04 def calc_calories(miles, calories_per_mile):
Show Suggested Answer Hide Answer
Suggested Answer: AF 🗳️
References: https://www.w3resource.com/python/python-user-defined-functions.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
atxsu
Highly Voted 5 years, 3 months ago
The answer is A and F, if you choose B or C you get an error: Traceback (most recent call last): File "main.py", line 11, in <module> biker = get_name() TypeError: get_name() missing 1 required positional argument: 'biker' Therefore A and F are the correct option.
upvoted 9 times
...
SherazM
Most Recent 3 years, 8 months ago
It is A & F.. I tested out the code.. def get_name(): name = input("What is your name? ") return name def calc_calories(miles,calories_per_mile): calories = miles * calories_per_mile return calories distance = int(input("How many miles did you bike this week? ")) burn_rate = 50 biker = get_name() calories_burned = calc_calories(distance, burn_rate) print(biker, ", you burned about" ,calories_burned, "calories.")
upvoted 1 times
...
gargaditya
4 years, 7 months ago
Be careful between E/F--We need to use the variables defined in 1st line of function definition inside for further computation, what variable name is passed to the function at the time of function call is not important
upvoted 1 times
...
s_balla_in
5 years, 6 months ago
I think the answer is B and F. def get_name(biker):
upvoted 2 times
mecham
5 years, 2 months ago
no. you arent passing the name of biker into the def. you are getting the name From the def.
upvoted 4 times
gargaditya
4 years, 7 months ago
Correct,see the function call,there is no argument passed there
upvoted 2 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 ...