Find solutions for your homework or get textbooks
home / study / engineering / computer science / computer science questions and answers / brutus the labrador retriever loves to chase tennis balls all day long. you can calculate how ...
Question: Brutus the labrador retriever loves to chase tennis balls all day long. You can calculate how far...
Brutus the labrador retriever loves to chase tennis balls all day long. You can calculate how far he has run using this formula:
distance = speed * time
As an example, Brutus ran for two hours and ran 15 kilometers per hour. So, (15 kph) * (2 hours) = 30 kilometers.
Write a program that Brutus's owner can use to track his distance. It should:
Allow Brutus's owner to input the speed of his dog
Allow Brutus's owner to input the hours Brutus was playing fetch
Loop to display the distance Brutus ran for each hour like this:
How long did Brutus play fetch? 3
How fast did Brutus run? 12
==========================================
Hour Brutus's Distance
==========================================
1 12 km
2 24 km
3 36 km
Helpful Hint: you've already ready about escape sequences in Lesson 1, but it is useful to really see them in practice. You can make your outputs prettier and more precise by using tabs to seperate your text. To add a tab to a string in Python, you use what's called an escape sequence to represent the tab: \t. An escape sequence tells the program not to literally print \t but to treat it as a tab. To create the the output header for Brutus, you would type something like this:
print('Hour\tBrutus\'s Distance')
please us python. please write a simple script I can understand. thanks
Feel free to ask any doubts and give feedback!
(Be careful about indentation when you copy and paste the code, therefore I have pasted screenhot of output as well as code)
Output:

CODE(python 3):
#take 2 inputs
time=int(input('How long did Brutus play fetch? '))
speed=int(input('How fast did Brutus run? '))
#print as specified in the question
print('===============================')
print('Hour\tBrutus\'s Distance')
print('===============================')
# for every hour between 1 to 'time', find the distance travelled using formula d=t*v,
# where t is time, v is velocity
for i in range(1,time+1):
distance=i*speed
print(str(i)+'\t'+str(distance)+' km')
Find solutions for your homework or get textbooks home / study / engineering / computer science...
Health and Science Medical Mathamatics course. For Vetrinary
Nursing /Technicians course. We are learning Constant Rate
Infusion. I need help. Thanks in advance.
"Pica," is a 43 lb. Labrador Retriever puppy weighing 42 lb. He is post-operative for a foreign body but continues to vomit despite receiving several different drugs to decrease vomiting. At 8 AM rounds, the veterinarian orders you to begin a CRI of metoclopramide at a dosage of 2 mg/kg/day after administering a loading dose of 0.4...
What are the Solutions to Part B of Chapter 2 of Tillery Physics 9th edition.......kinda pointless for you guys to only have the solutions that the book has already. 1. What was the average speed in km/h of a car that travels 400.0 km in 4.5 h? 2. What was the average speed in km/h of a boat that moves 15.0 km across a lake in 45 min? 3. How much would a 80.0 kg person weigh (a) on Mars,...
NUR 254 Pediatric Case Study-Asthma-Student L.S. is a 7-year-old who has been brought to the emergency department (ED) by his mother. She immediately tells you he has a history of ED visits for his asthma. He uses an inhaler when he wheezes, but it ran out a month ago. She is a single parent and has 2 other children at home with a babysitter. Your assessment finds L.S. alert, oriented, and extremely anxious. His color is pale, and his nail...
Read about Cokes strategy in Africa in the article below and discuss the ethics of selling soft drinks to very poor people. Is this an issue that a company like Coke should consider? Africa: Coke's Last Frontier Sales are flat in developed countries. For Coke to keep growing, Africa is it By Duane Stanford Piles of trash are burning outside the Mamakamau Shop in Uthiru, a suburb of Nairobi, Kenya. Sewage trickles by in an open trench. Across the street,...