Skip to content

Commit c25489c

Browse files
authored
Add files via upload
1 parent 632c176 commit c25489c

File tree

1 file changed

+121
-0
lines changed

1 file changed

+121
-0
lines changed

Graham 1.0.py

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
# Graham the Text Interpreter
2+
3+
# Libraries
4+
import time
5+
6+
7+
# Functions
8+
def wordCounter(text):
9+
print(" + Has " + str(len(text.split())) + " words.")
10+
11+
12+
def charCounter(text):
13+
print(" + Has " + str(len(list(text))) + " characters.")
14+
15+
16+
def lineCounter(dir):
17+
with open(dir, "r") as fp:
18+
num_lines = sum(1 for line in fp)
19+
print(" + Has", num_lines, "lines.")
20+
21+
22+
def analysis(text):
23+
wordCounter(text)
24+
charCounter(text)
25+
26+
27+
# Welcome and Menu
28+
def welcome():
29+
print(
30+
"""
31+
____________________________________________________________________
32+
/\_/\ | Hello there! I am Graham! I love reading texts and analyzing them. |
33+
((@v@)) < What would you like me to do? |
34+
():::() |____________________________________________________________________|
35+
_____VV_VV__/__
36+
\\
37+
"""
38+
)
39+
40+
41+
def menu():
42+
print(
43+
"""
44+
#1 - Listen to my story.
45+
#2 - Read my story.
46+
#3 - Tell me about yourself.
47+
#4 - How to use?
48+
#0 - Exit.
49+
"""
50+
)
51+
52+
53+
def prompt():
54+
select = input("@v@? ")
55+
56+
if select == "1":
57+
story = input("Alright, let's hear it! \n")
58+
print("\n--- Wow, such a story! Your story...")
59+
analysis(story)
60+
print("\n--- What else would you like me to do? \n")
61+
62+
elif select == "2":
63+
print("\nOkay. Where is your text file?\n")
64+
dir = input("@v@? ")
65+
with open(dir) as file:
66+
contents = file.read()
67+
print("\n--- Wow, such a story! Your story...")
68+
69+
analysis(contents)
70+
lineCounter(dir)
71+
72+
print("\n--- What else would you like me to do? \n")
73+
74+
elif select == "3":
75+
print(
76+
"""
77+
____________________________________________________________________________________________
78+
< Of course! |
79+
| I am Graham the Text Interpreter. Developed by Pouya. I'm currently at version 1.0. |
80+
| I take ".txt" files and analize them for you; or you can copy and paste the text here. |
81+
|____________________________________________________________________________________________|
82+
"""
83+
)
84+
print("\n--- What else would you like me to do? \n")
85+
menu()
86+
prompt()
87+
88+
elif select == "4":
89+
print(
90+
"""
91+
92+
"""
93+
)
94+
elif select == "0":
95+
print(
96+
"""
97+
___________________________
98+
< See you later, adventurer.|
99+
|___________________________|
100+
"""
101+
)
102+
time.sleep(3)
103+
quit()
104+
105+
else:
106+
print(
107+
"""
108+
_____________________________
109+
< Sorry, I did not catch that.|
110+
|_____________________________|
111+
"""
112+
)
113+
114+
115+
# Main program struct
116+
117+
welcome()
118+
119+
while True:
120+
menu()
121+
prompt()

0 commit comments

Comments
 (0)