1 def rest_time(miles_driven, brake_count): count = 0 3 count = round (miles_driven/brake_count) 4 counter Glo 5 while (count % 2) == 0: re: 6 count = (count/2) 7 if counter >= 0: 8 counter = counter + 1 9 if count <= 1: 1 H "hour" 2 else: 3 H = "hours" 4 5 return str(counter) +" + H %3D 7 print (rest_time(24,3)) #fix me
1 def rest_time(miles_driven, brake_count): count = 0 3 count = round (miles_driven/brake_count) 4 counter Glo 5 while (count % 2) == 0: re: 6 count = (count/2) 7 if counter >= 0: 8 counter = counter + 1 9 if count <= 1: 1 H "hour" 2 else: 3 H = "hours" 4 5 return str(counter) +" + H %3D 7 print (rest_time(24,3)) #fix me
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
Related questions
Question
I am working on a block of code and cannot figure out how to count the number of times a loop is proccessed within the stated parameters, but when the output is 0 that value is not counted in the iteration.
Here is the problem and my code

Transcribed Image Text:(known limitations)
3 hour
1 def rest_time(miles_driven, brake_count):
2
count = O
Fra
3
count
round (miles_driven/brake_count)
%D
4
counter
= 0
Global fra
5
while (count % 2)
0:
==
rest_time
count =
(count/2)
if counter >= 0:
8.
counter = counter + 1
9
10
if count <= 1:
11
H
"hour"
12
else:
13
H = "hours"
14
15
return str (counter) +"
+ H
16
► 17 print (rest_time (24,3)) #fix me
67

Transcribed Image Text:def rest_time (miles_driven, brake_count):
Backstory: In the city of Slotham, Slothman is the silent guardian and savior of the people. He has
his own Slothmobile, which is no less impressive than the Batmobile. However, Slothmobile gets
tired after running for some time and recovers when it is turned off! It other words, it needs to
rest before it turns on again. The number of hours it needs to rest depends on how many miles it
was driven and how many times the brakes were applied after the last time it was switched on.
Description: You can figure out the number of hours the Slothmobile needs to rest by counting
the number of times you get an even number (excluding 0) when you integer divide the number of
miles driven by the number of times the brakes are applied.
For example, if miles driven is 13 and brakes applied is 2, 13 divided by 2 is 6.5, which rounds
down to 6, which is even. Next, we will consider 6 to see if we get any more even integers. 6
integer divided by 2 is 3, since 3 is odd, we stop here. So, the rest time for Slothmobile is 1 hour
because we only calculated 1 even number in these integer divisions.
Parameters: miles_driven (int, indicating the number of miles driven)
brake_count (int, indicating the number of times brakes applied)
Assumptions: Both parameters are positive integers (> 0)
Return value: An integer, which represents Slothmobile rest time in hours
Examples:
rest_time(13, 2) → 1
rest_time(9, 3)
rest_time(24, 3)
# 13 → 6 → 3; 6 is even → 1 hour
# 9 → 3; no even number → 0 hour
→ 2
# 24 → 8 → 2 → 0; 8, 2 are even (we exclude 0)
→ 2 hours
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images

Recommended textbooks for you

Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON

Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science

Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning

Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON

Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science

Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning

Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning

Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education

Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY