-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmenu_example.py
More file actions
66 lines (54 loc) · 1.27 KB
/
menu_example.py
File metadata and controls
66 lines (54 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/python3
'''Keystone Learning | Author: Paul Lack
Demonstrating a method to present a menu on the command line using
a while loop.'''
import time
OPTION_1 = '1. Walk the dog.'
OPTION_2 = '2. Eat lunch.'
OPTION_3 = '3. Launch all the missiles.'
OPTION_4 = '4. Quit.'
lines = '*'*50
title = 'Welcome to THE PROGRAM!'
def show_menu():
print(lines)
print(title)
print(lines)
print(OPTION_1)
print(OPTION_2)
print(OPTION_3)
print(OPTION_4)
print(lines)
def walk_dog():
print('Dog successfully walked.')
print('\n'*3)
def eat_lunch():
print('Bon Appetit!')
print('\n'*3)
def launch_missiles():
print('You monster...')
print('\n'*3)
def exit_program():
print('Thank you for using menu-bot 300!')
print('Exiting gracefully in...')
time.sleep(1)
print('3')
time.sleep(1)
print('2')
time.sleep(1)
print('1')
time.sleep(1)
print('Goodbye!')
def main():
choice = ''
while choice != 4:
show_menu()
choice = int(input('Please type your selection. >>> '))
if choice == 1:
walk_dog()
elif choice == 2:
eat_lunch()
elif choice == 3:
launch_missiles()
exit_program()
if __name__ == "__main__":
main()