Question: PYTHON QUESTION In this part of the homework, we will play a word game based on the idea of a racetrack. We have provided you

PYTHON QUESTION

In this part of the homework, we will play a word game based on the idea of a racetrack. We have provided you with a module, track.py in the Course Materials section of Submitty. The module provides two functions, (1) get_number_of_tracks() which takes no parameters and returns the number of tracks it can provide and (2) get_track(track) which takes an integer track number and returns the corresponding track as a string. Tracks are just strings with two different sets of letters. All of the letters in 'bend' ('b', 'e', 'n', 'd') indicate curve segments of the track and all of the letters in 'straight' indicate straight segments. Each track segment represents one-quarter of a mile.

You will need to write two functions. calculate_curve(track, speed) andcalculate_straight(track, speed) each of which takes a string representing the track and re- turns a 2-tuple of the total distance and total time for the car on the appropriate (curved or straight) segments.

In your main program, first find out how many tracks the module provides and then ask the user to pick a track between 1 and the number of tracks available. Also, ask for the cars speed on the curved and straight segments. Be careful here! We will be providing a track module on Submitty that provides a different number and configuration of tracks, so do not assume values. Use the calls we provide.

Call your functions to calculate the distance and time spent on the curved and straight segments repectively, and then calculate average speed as well.

Print out the track (it is just a string) and the information you calculated. Finally, print a critique of the cars performance as follows:

1. if the average speed is less than 60, print "Kind of slow."2. if it is at least 60, but less than 120, print "Getting there."3. If it is at least 120, print "Wow, what a car!"

Here are some examples:

Select a track between 1 and 3 => 1 
1 Speed on curved segments (MPH) => 40 40 Speed on straight segments (MPH) => 120 120 

Track:

E

B n

d

is 1.00 miles long. You raced it in 90.00 seconds at an average speed of 40.00 MPH Kind of slow. 

or

Select a track between 1 and 3 => 2 2 Speed on curved segments (MPH) => 40 40 
Speed on straight segments (MPH) => 120 120 
Track: sTRaight 
is 2.00 miles long. You raced it in 60.00 seconds at an average speed of 120.00 MPH Wow, what a car! 

or

Select a track between 1 and 3 => 3 3 Speed on curved segments (MPH) => 76 76 
Speed on straight segments (MPH) => 131.3324 131.3324 

Track:

sTRaiiGht

D B

n e

e N

b d

thGiartS

is 6.25 miles long. You raced it in 211.24 seconds at an average speed of 106.52 MPH Getting there. 

PYTHON QUESTION In this part of the homework, we will play a

get track 8def get_number_of_tracksO: 9 10 Return the number of different tracks provided by this module. return 3 12 13 14 def get track(number: 15 16 17 18 19 Given an integer between 1 and 3, return a specific race track configuratio For numbers less than 0 or greater than 3, return the empty string. if number -- 1: track ''' 21 22 B n 23 elif number 2: track ''' 27 STRaight 28 29 30 31 32 33 n 34 e elif number 3: track- ''' sTRaiiGht thGiarts else: track'' 39 40 return track get track 8def get_number_of_tracksO: 9 10 Return the number of different tracks provided by this module. return 3 12 13 14 def get track(number: 15 16 17 18 19 Given an integer between 1 and 3, return a specific race track configuratio For numbers less than 0 or greater than 3, return the empty string. if number -- 1: track ''' 21 22 B n 23 elif number 2: track ''' 27 STRaight 28 29 30 31 32 33 n 34 e elif number 3: track- ''' sTRaiiGht thGiarts else: track'' 39 40 return track

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!