Python

Trying out in AI.

fork
loading
Files
  • main.py
  • females.txt
  • Gabe.txt
  • Garret.txt
  • gr.txt
  • males.txt
  • mark.txt
main.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
print("Hello. Please answer some questions.");
print();
name = input("Enter your name: ");
fnames = open("females.txt","r");
femaleNames = fnames.read();


mnames = open("males.txt","r");
maleNames = mnames.read();

if name.lower() in femaleNames:
  print("You're a girl!");
if name.lower() in maleNames:
  print("You're a boy!");
else:
  print("We could not reveal your gender. Sorry!")
  print()
  gen = input('Please tell us what gender you are (male/female): ')
  if gen == 'male':
    genderAdd = open("males.txt","a");
    genderAdd.write(name.lower());
    genderAdd.close();
  if gen == 'female':
    genderAdd = open("females.txt","a");
    genderAdd.write(name.lower());
    genderAdd.close();

q1 = input("Would you rather eat meat or seeds? ");
if q1 == "meat":
  data = open(name + ".txt", "a");
  data.write(name + " eats meat.\n");
  data.close();
if q1 == "seeds":
  data = open(name + ".txt", "a");
  data.write(name + " eats seeds.\n");  
  data.close();

def checkHumanity(name):
  data = open(name + ".txt",'r')
  line1 = data.readline();
  startingPoint = line1.index('eat')
  endingPoint = line1.index('.')
  if line1[startingPoint:endingPoint] == 'eats meat':
    print("He is a human!")
  else:
    print("He is not a human!")