← 2023 questions

2023 / GRAB / QUESTION 20

Driver confirmation

Try the question in your own editor, then check your output below.

THE QUESTION

Tristan wants to book a Grab driver. He inputs all his details, and the system finds a driver for him. The app now needs to output a message to inform Tristan about his driver and the details. It should include:

A success message

Driver’s name

Rating in stars (eg. * * * *)

Car number plate

Car model

Print all this information with centre alignment.

Question by Amanda. Source: Girls In Code SEA — Behind the Screens, 2023, slide 37.

PRACTICE CHECK

Try your answer.

New driver details; checking the message content does not verify screen alignment.

Run your program in your own editor, then paste its output below. This checks the stated output or checkpoint; it does not assess your full program. Practice attempts do not affect competition scores.

Practice driver: Aisha, 4 stars, ABC1234, Toyota Prius. Enter five lines: Booking successful, name, stars separated by spaces, plate and model. Centring spaces are ignored.

Reveal worked answer

Driver confirmation

Booking successful
Aisha
* * * *
ABC1234
Toyota Prius

Format the supplied fields and repeat “*” four times. Use str.center(width) for the complete console exercise.