Write a program in Python using the following scenario:
Your customer is a restaurant owner that wants to be able to advertise online in chat rooms, but they have an ever-changing menu. Write a program in Python that will prompt the user for the name of a restaurant, three menu items, and their prices. See example input and output below.
This is the solution to the assignment which you can download here.
Example:
Input:
Output:
Python code:
Terminal output and input:
Explanation:
There are many ways to solve this problem but we can use string formatting in python to do this task accurately.
Example:
These
are normal examples of string formatting.
printing output:
This print ‘*’ 33 times in the first row.
Here “{:^25}”.format(restaurant) formats string and create 25 length string with restaurant name in the center-aligned of the string.
3)
Here “{:<23}”.format(item1) formats string and create 23 length string with item1 value left-aligned.
and Here “{:>6}”.format(item1_price) formats string and create 6 length string with item1_price value right-aligned.
Repeat this step for item 2 and 3:
4)
This is the end of the display.
These are python articles you like...:
Image of code:
0 Comments
If you have any doubt let me know.