-
Notifications
You must be signed in to change notification settings - Fork 0
/
Tool Box.py
122 lines (113 loc) · 3.76 KB
/
Tool Box.py
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
__author__ = 'BenDiegel'
#open programs
#save text
#play game
#dice roller (up to 3 dice at a time!)
import random
import pickle
import subprocess
#lists for saving text data
global saveList
global saveEntry
saveList = ['save 1.txt', 'save 2.txt', 'save 3.txt']
saveEntry = ["", "", ""]
#text reader data that reads 3 seperate text files that were made from the text editor
def textReader():
userChoice = input("What save would you like to open: 1, 2, or 3?\n")
if userChoice == "1":
file = open(saveList[0], 'rb')
text = pickle.load(file)
print(text)
input("Press ENTER to leave\n")
mainProgram()
elif userChoice == "2":
file = open(saveList[1], 'rb')
text = pickle.load(file)
print(text)
input("Press ENTER to leave\n")
mainProgram()
elif userChoice == "3":
file = open(saveList[2], 'rb')
text = pickle.load(file)
print(text)
input("Press ENTER to leave\n")
mainProgram()
#text editor that can save 3 seperate text files
def textEditor():
print("What would you like to write?")
userEntry = input()
if input("Would you like to save?\n") == "yes":
saveChoice = input("Save 1, 2, or 3?\n")
if saveChoice == "1":
saveEntry[0] = userEntry
file = open(saveList[0], 'wb')
pickle.dump(saveEntry[0], file)
file.close()
elif saveChoice == "2":
saveEntry[1] = userEntry
file = open(saveList[1], 'wb')
pickle.dump(saveEntry[1], file)
file.close()
elif saveChoice == "3":
saveEntry[2] = userEntry
file = open(saveList[2], 'wb')
pickle.dump(saveEntry[2], file)
file.close()
else:
input("Deleting text...\n")
mainProgram()
mainProgram()
#rolls 1-4 dice and then outputs the answer
def diceRoller():
diceAmount = input("How many dice would you like to roll (limit 4)?\n")
if diceAmount == "1":
diceFinal = random.randint(1,6)
print("You rolled " + str(diceAmount) + " die and got " + str(diceFinal))
userChoice = input("Would you like to roll again?\n")
if userChoice == "yes":
diceRoller()
else:
mainProgram()
elif diceAmount == "2":
diceFinal = random.randint(2,12)
print("You rolled " + str(diceAmount) + " dice and got " + str(diceFinal))
userChoice = input("Would you like to roll again?\n")
if userChoice == "yes":
diceRoller()
else:
mainProgram()
elif diceAmount == "3":
diceFinal = random.randint(3,18)
print("You rolled " + str(diceAmount) + " dice and got " + str(diceFinal))
userChoice = input("Would you like to roll again?\n")
if userChoice == "yes":
diceRoller()
else:
mainProgram()
elif diceAmount == "4":
diceFinal = random.randint(4,24)
print("You rolled " + str(diceAmount) + " dice and got " + str(diceFinal))
userChoice = input("Would you like to roll again?\n")
if userChoice == "yes":
diceRoller()
else:
mainProgram()
#this is the main menu that lists all of the avalible programs
def mainProgram():
userChoice = input("What would you like to run?\n"
"1. Text Editor\n"
"2. Text Reader\n"
"3. Dice\n"
"4. Exit\n")
if userChoice == "1":
textEditor()
elif userChoice == "2":
textReader()
elif userChoice == "3":
diceRoller()
elif userChoice == "4":
exit()
else:
print("You did not make a known selection.")
mainProgram()
mainProgram()