- 28th Jun 2024
- 17:23 pm
In this assignment our expert will guide you how to write codes that automatically match Uber/Lyft drivers and riders.
1. Setting: You are an Uber driver. There are currently 100 riders requesting a ride. You want to pick up riders that meet the following two conditions:
Condition 1: Ride time that each rider requests spans 5-50 mins (the ride time is random)
Condition 2: I prefer riders with the rider time between 5 and 15 mins.
Condition 3: after all the matches, print a statement counting the total number of matched rides.
2. Output statement example:
[O] No. 1 rider (ride time: 8 mins)
[ ] No. 2 rider (ride time: 16 mins)
[ ] No. 3 rider (ride time: 38 mins)
...
[ ] No. 99 rider (ride time: 21 mins)
[O] No. 100 rider (ride time: 10 mins)
Total riders matched: 2
Suggestions
- Use "from random import *" and "if" statement
- First, you will create 100 riders.
- Second, you will create the rider time (5-50 mins) for each rider (random function).
- Third, if the rider time matches my conditions, print statement and increase the count. Otherwise ("else") print another statement indicating not matched.
- Make sure that you write codes in detail so that anyone without Python background can run your codes by copying and pasting onto Visual Studio Codes. For example, if a package is required to run your code, you are to include the codes that import necessary packages. If directions/instructions are required when running your codes, include the directions/instructions hashed out.
Write Codes That Match Uber/Lyft Drivers And Riders - Free Assignment Solution
Please note that this is a sample assignment solved by our Python Programmers. These solutions are intended to be used for research and reference purposes only. If you can learn any concepts by going through the reports and code, then our Python Tutors would be very happy.
- Option 1 - To download the complete solution along with Code, Report and screenshots - Please visit our Python Assignment Sample Solution page
- Option 2 - Reach out to our Python Tutors to get online tutoring related to this assignment and get your doubts cleared
- Option 3 - You can check the partial solution for this assignment in this blog below
Free Assignment Solution - Write Codes That Match Uber/Lyft Drivers And Riders
#importing neceessary files
from random import *
#create 100 rider and store it in list
rider_list = [0] * 100
#genraton rider time for every rider and store in list
for i in range(len(rider_list)):
rider_list[i] = randint(5, 50)
#create a counter variable to store the rider that passes the condition
counter = 0
#print all the riders
for i in range(len(rider_list)):
if rider_list[i] >= 5 and rider_list[i]<=15:
print("[0] ",end="")
counter += 1
else:
print("[ ] ",end="")
print("No. %d rider (ride time: %d mins)"%(i+1,rider_list[i]) )
print("Total riders matched: %d"%(counter))
Get the best Python assignment help and tutoring services from our experts now!
About The Author - Jamie Smith
Jamie Smith, an experienced Python Developer with a strong background in automation and algorithm design, will guide you through this assignment. Jamie's expertise lies in developing efficient and user-friendly code solutions. In this project, Jamie will help you write a Python program to automatically match Uber/Lyft drivers with riders based on specified conditions. You will learn to generate random ride times, apply conditional statements, and output results clearly and effectively, making your code accessible even to those without a Python background.