diff --git a/en/index.html b/en/index.html index 1368e8a..2298f69 100644 --- a/en/index.html +++ b/en/index.html @@ -44,12 +44,14 @@
Written by Laryn Qi
+With the onset of COVID-19, online ordering has become even more prevalent. As software engineers, a program that could take our order from the comfort of our own terminal/command prompt would be especially convenient. Well, if we're truly programmers, why don't we try programming this program ourselves!
+The main menu will consist of:
+The secret menu will consist of:
+Write a program that prints out a short welcome message and the main menu. Then, it should continually read in menu items from the user, keeping track of how many items they've added so far. Misspelled items should result in an error message (this should not count as an additional item). During this ordering phase, the user can also ask to see the secret menu by typing in the key phrase "Secret Menu Please!" (this should not count as an additional item). If the user types nothing and just hits enter, the order phase should end. Lastly, it will print out the total price of the user's order and a farewell. Here is an example execution of the program:
+Welcome to Programmer's Paradise! +---------- +Here's our menu: + +Boolean Burger: $4.99 +Function Fries: $2.99 +String Soda: $1.99 + +What can I get for you? +1. Boolean Burger +2. Function Fries +3. fries +Please enter a valid item. +3. Function Fries +4. String Soda +5. + +Your total is... +$12.96 + +Thank you for choosing Programmer's Paradise. +We hope you loop by again! + ++
Here is another example execution of the program with secret menu items:
+Welcome to Programmer's Paradise! +---------- +Here's our menu: + +Boolean Burger: $4.99 +Function Fries: $2.99 +String Soda: $1.99 + +What can I get for you? +1. String Soda +2. String Soda +3. Secret Menu Please! +---------- +Here's our secret menu: + +Piech Perfection: $3.14 +Sahami Special: $1.62-$2.72 + +3. Piech Perfection +4. Sahami Special +5. + +Your total is... +$8.92 + +Thank you for choosing Programmer's Paradise. +We hope you loop by again! ++
Here are some tips for common issues:
+print()
can be used to print out a blank line\'
can be used to display an apostropherandom
libraryrandom.uniform
and the Python built-in function round
)Optional Extensions
+time
library to delay printed outputs of your program so it feels like your terminal/command prompt is talking to you1. 5 Boolean Burger
)+
import random +import time + +P_BURGER = 4.99 +P_FRIES = 2.99 +P_SODA = 1.99 +P_PIECH = 3.14 +MIN_SAHAMI = 1.62 +MAX_SAHAMI = 2.72 + +def main(): + welcome() + menu() + order() + +def welcome(): + print('Welcome to Programmer\'s Paradise!') + print('----------') + time.sleep(1) + +def menu(): + print('Here\'s our menu:') + print() + time.sleep(1) + print('Boolean Burger: $' + str(P_BURGER)) + time.sleep(1) + print('Function Fries: $' + str(P_FRIES)) + time.sleep(1) + print('String Soda: $' + str(P_SODA)) + time.sleep(1) + print() + + +def secret_menu(): + print('----------') + print('Here\'s our secret menu:') + time.sleep(1) + print() + print('Piech Perfection: $' + str(P_PIECH)) + time.sleep(1) + print('Sahami Special: $' + str(MIN_SAHAMI) + '-$' + str(MAX_SAHAMI)) + time.sleep(1) + print() + +def order(): + print('What can I get for you?') + count = 1 + total = 0 + item = input('1. ') + while item != '': + if item == 'Boolean Burger': + total += P_BURGER + elif item == 'Function Fries': + total += P_FRIES + elif item == 'String Soda': + total += P_SODA + elif item == 'Secret Menu Please!': + secret_menu() + count -= 1 + elif item == 'Piech Perfection': + total += P_PIECH + elif item == 'Sahami Special': + total += random.uniform(MIN_SAHAMI, MAX_SAHAMI) + else: + print('Please enter a valid item.') + count -= 1 + count += 1 + item = input(str(count) + '. ') + + print() + print('Your total is...') + time.sleep(1) + print('$' + "%.2f" % round(total, 2)) + time.sleep(1) + print() + print('Thank you for choosing Programmer\'s Paradise.') + time.sleep(1) + print('We hope you loop by again!') + time.sleep(1) + print() + exit() + +if __name__ == '__main__': + main()+
With the onset of COVID-19, online ordering has become even more prevalent. As software engineers, a program that could take our order from the comfort of our own terminal/command prompt would be especially convenient. Well, if we're truly programmers, why don't we try programming this program ourselves!
+The main menu will consist of:
+The secret menu will consist of:
+Write a program that prints out a short welcome message and the main menu. Then, it should continually read in menu items from the user, keeping track of how many items they've added so far. Misspelled items should result in an error message (this should not count as an additional item). During this ordering phase, the user can also ask to see the secret menu by typing in the key phrase "Secret Menu Please!" (this should not count as an additional item). If the user types nothing and just hits enter, the order phase should end. Lastly, it will print out the total price of the user's order and a farewell. Here is an example execution of the program:
+Welcome to Programmer's Paradise! +---------- +Here's our menu: + +Boolean Burger: $4.99 +Function Fries: $2.99 +String Soda: $1.99 + +What can I get for you? +1. Boolean Burger +2. Function Fries +3. fries +Please enter a valid item. +3. Function Fries +4. String Soda +5. + +Your total is... +$12.96 + +Thank you for choosing Programmer's Paradise. +We hope you loop by again! + ++
Here is another example execution of the program with secret menu items:
+Welcome to Programmer's Paradise! +---------- +Here's our menu: + +Boolean Burger: $4.99 +Function Fries: $2.99 +String Soda: $1.99 + +What can I get for you? +1. String Soda +2. String Soda +3. Secret Menu Please! +---------- +Here's our secret menu: + +Piech Perfection: $3.14 +Sahami Special: $1.62-$2.72 + +3. Piech Perfection +4. Sahami Special +5. + +Your total is... +$8.92 + +Thank you for choosing Programmer's Paradise. +We hope you loop by again! ++
Here are some tips for common issues:
+print()
can be used to print out a blank line\'
can be used to display an apostropherandom
libraryrandom.uniform
and the Python built-in function round
)Optional Extensions
+time
library to delay printed outputs of your program so it feels like your terminal/command prompt is talking to you1. 5 Boolean Burger
)\ No newline at end of file diff --git a/examples/paradise/soln.py b/examples/paradise/soln.py new file mode 100644 index 0000000..c8dc068 --- /dev/null +++ b/examples/paradise/soln.py @@ -0,0 +1,84 @@ +import random +import time + +P_BURGER = 4.99 +P_FRIES = 2.99 +P_SODA = 1.99 +P_PIECH = 3.14 +MIN_SAHAMI = 1.62 +MAX_SAHAMI = 2.72 + +def main(): + welcome() + menu() + order() + +def welcome(): + print('Welcome to Programmer\'s Paradise!') + print('----------') + time.sleep(1) + +def menu(): + print('Here\'s our menu:') + print() + time.sleep(1) + print('Boolean Burger: $' + str(P_BURGER)) + time.sleep(1) + print('Function Fries: $' + str(P_FRIES)) + time.sleep(1) + print('String Soda: $' + str(P_SODA)) + time.sleep(1) + print() + + +def secret_menu(): + print('----------') + print('Here\'s our secret menu:') + time.sleep(1) + print() + print('Piech Perfection: $' + str(P_PIECH)) + time.sleep(1) + print('Sahami Special: $' + str(MIN_SAHAMI) + '-$' + str(MAX_SAHAMI)) + time.sleep(1) + print() + +def order(): + print('What can I get for you?') + count = 1 + total = 0 + item = input('1. ') + while item != '': + if item == 'Boolean Burger': + total += P_BURGER + elif item == 'Function Fries': + total += P_FRIES + elif item == 'String Soda': + total += P_SODA + elif item == 'Secret Menu Please!': + secret_menu() + count -= 1 + elif item == 'Piech Perfection': + total += P_PIECH + elif item == 'Sahami Special': + total += random.uniform(MIN_SAHAMI, MAX_SAHAMI) + else: + print('Please enter a valid item.') + count -= 1 + count += 1 + item = input(str(count) + '. ') + + print() + print('Your total is...') + time.sleep(1) + print('$' + "%.2f" % round(total, 2)) + time.sleep(1) + print() + print('Thank you for choosing Programmer\'s Paradise.') + time.sleep(1) + print('We hope you loop by again!') + time.sleep(1) + print() + exit() + +if __name__ == '__main__': + main() \ No newline at end of file diff --git a/examples/paradise/tags.txt b/examples/paradise/tags.txt new file mode 100644 index 0000000..a88aa0c --- /dev/null +++ b/examples/paradise/tags.txt @@ -0,0 +1,9 @@ +week2 +Python +functions +decomposition +constants +input +random +user +fun \ No newline at end of file diff --git a/examples/paradise/title.txt b/examples/paradise/title.txt new file mode 100644 index 0000000..43dfc46 --- /dev/null +++ b/examples/paradise/title.txt @@ -0,0 +1 @@ +Programmer's Paradise \ No newline at end of file diff --git a/plugins/__pycache__/__init__.cpython-37.pyc b/plugins/__pycache__/__init__.cpython-37.pyc index 578955e..33a6691 100644 Binary files a/plugins/__pycache__/__init__.cpython-37.pyc and b/plugins/__pycache__/__init__.cpython-37.pyc differ diff --git a/plugins/bottle/__pycache__/__init__.cpython-37.pyc b/plugins/bottle/__pycache__/__init__.cpython-37.pyc index f91f539..325cdc2 100644 Binary files a/plugins/bottle/__pycache__/__init__.cpython-37.pyc and b/plugins/bottle/__pycache__/__init__.cpython-37.pyc differ diff --git a/plugins/bottle/__pycache__/bottle.cpython-37.pyc b/plugins/bottle/__pycache__/bottle.cpython-37.pyc index 59e2f3a..a0c718d 100644 Binary files a/plugins/bottle/__pycache__/bottle.cpython-37.pyc and b/plugins/bottle/__pycache__/bottle.cpython-37.pyc differ