forked from DigiLabBarking/AI-using-Python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.py
More file actions
86 lines (83 loc) · 1.86 KB
/
Main.py
File metadata and controls
86 lines (83 loc) · 1.86 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
"""
Python AI
By Captain Pi & EBz
Version 0.0.1
"""
#imports
from time import strftime
#variables
ID = 0
#functions
def Update():
global Names
Names = []
file = open('Names.txt','r')
line = file.readline()
line = line.split(',')
for name in line:
if name != '':
Names.append(name)
print(Names)
file.close()
def Question():
X = str(input("Ask me a question\n: "))
file = open('Symbols.txt','r')
for symbol in file:
X.replace(symbol,'')
X.lower().split(" ")
for x in X:
if x == 'time':
Time()
elif x == 'date':
Date()
elif x == 'name':
Name(1)
def Name(option):
global Names,ID
if option == 0: #start
name = str(input("What is your name?\n: "))
name = name.lower()
User = False
counter = 0
for user in Names:
if name == user:
User = True
ID = counter
print('Welcome back '+name)
break
else:
counter += 1
if User == False:
Names.append(name)
file = open('Names.txt','w')
for user in Names:
file.write(user+',')
file.close()
ID = len(Names) - 1
Update()
elif option == 1: #AI
name = Names[ID]
name.title()
print('Your name is',name)
def Time():
print(strftime('%H:%M:%S'))
def Date():
print(strftime('%d/%m/%Y'))
def Exit():
x = str(input('Do you want to exit?\n: '))
x = x.lower()
if x == 'yes' or x == 'y' or x == 'yep' or x == 'yeah':
quit()
elif x == 'no' or x == 'n':
return True
#main
while True:
try:
Update()
Name(0)
while True:
Question()
except KeyboardInterrupt:
Exit()
#end
quit()