-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGraham 1.0.py
More file actions
121 lines (94 loc) · 3.09 KB
/
Graham 1.0.py
File metadata and controls
121 lines (94 loc) · 3.09 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
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
# Graham the Text Interpreter
# Libraries
import time
# Functions
def wordCounter(text):
print(" + Has " + str(len(text.split())) + " words.")
def charCounter(text):
print(" + Has " + str(len(list(text))) + " characters.")
def lineCounter(dir):
with open(dir, "r") as fp:
num_lines = sum(1 for line in fp)
print(" + Has", num_lines, "lines.")
def analysis(text):
wordCounter(text)
charCounter(text)
# Welcome and Menu
def welcome():
print(
"""
____________________________________________________________________
/\_/\ | Hello there! I am Graham! I love reading texts and analyzing them. |
((@v@)) < What would you like me to do? |
():::() |____________________________________________________________________|
_____VV_VV__/__
\\
"""
)
def menu():
print(
"""
#1 - Listen to my story.
#2 - Read my story.
#3 - Tell me about yourself.
#4 - How to use?
#0 - Exit.
"""
)
def prompt():
select = input("@v@? ")
if select == "1":
story = input("Alright, let's hear it! \n")
print("\n--- Wow, such a story! Your story...")
analysis(story)
print("\n--- What else would you like me to do? \n")
elif select == "2":
print("\nOkay. Where is your text file?\n")
dir = input("@v@? ")
with open(dir) as file:
contents = file.read()
print("\n--- Wow, such a story! Your story...")
analysis(contents)
lineCounter(dir)
print("\n--- What else would you like me to do? \n")
elif select == "3":
print(
"""
____________________________________________________________________________________________
< Of course! |
| I am Graham the Text Interpreter. Developed by Pouya. I'm currently at version 1.0. |
| I take ".txt" files and analize them for you; or you can copy and paste the text here. |
|____________________________________________________________________________________________|
"""
)
print("\n--- What else would you like me to do? \n")
menu()
prompt()
elif select == "4":
print(
"""
"""
)
elif select == "0":
print(
"""
___________________________
< See you later, adventurer.|
|___________________________|
"""
)
time.sleep(3)
quit()
else:
print(
"""
_____________________________
< Sorry, I did not catch that.|
|_____________________________|
"""
)
# Main program struct
welcome()
while True:
menu()
prompt()