forked from 4dsolutions/python_camp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcamper_program.py
More file actions
60 lines (47 loc) · 1.24 KB
/
camper_program.py
File metadata and controls
60 lines (47 loc) · 1.24 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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
PyCamp: a collaborative project
Bugs found:
To fix:
crashes when user types words
"""
import math
import random
import time
def squares():
print("Choose a number 1 through 100.")
number = int(input())
square = number**2
print("The square of", number, "is", square)
def square_roots():
print("Choose a number 1 through 100.")
num = int(input())
root = math.sqrt(num)
print("The square root of", num, "is", root)
# this could come in handy
menu_options = {"1": squares,
"2": square_roots,
"0": "exit"}
def menu():
looping = True
while looping:
# can we make this a loop that keeps asking?
print("""
1. Squares
2. Square roots
0. Exit
Pick one please""")
do_it = input(" >>> ")
# print("You picked", do_it)
if not do_it in menu_options:
print("Please pick 1, 2, 0")
continue
do_it = int(do_it)
if do_it == 0:
looping = False
elif do_it == 1:
squares()
elif do_it == 2:
square_roots()
menu()