Computer Science, asked by AnushaNath9379, 8 months ago

Python menu driven program for a restraunt

Answers

Answered by Shinchanboy03
0

Answer:

Flag variables suck, and should be avoided. Moreover, variables should not be named in ALL_CAPS to look like constants. All you need to get out of the loop is a break.

You've hard-coded the parts of the menu in three places:

the prices

the ASCII table

the loop

All of the menu information should be defined in one place. You can programmatically generate the ASCII table using the astropy.io.ascii package, but I've put together a quick-and-dirty implementation below.

The if statements in the loop should be replaced by a dictionary lookup. Furthermore, is is the wrong operator to use; string comparison should be done using ==. In fact, entering "done" doesn't correctly end the loop, because of that.

You used + str(0) as a hack to get a price ending in "0" to display properly. To represent fixed-point numbers, you should use a Decimal instead.

This program is long enough that it would be a good idea to make a main() function.

Statements should generally not be terminated with semicolons in Python. Also, PEP 8, the official style guide, specifies that indentation should be four spaces. This is an important convention in Python, where indentation matters a lot.

Similar questions