python-hard-way/Apol-Topics/apol-choice.py

95 lines
2.0 KiB
Python
Raw Permalink Normal View History

2019-04-02 21:57:49 +00:00
import random
import linecache
def topics():
category = random.randrange(1, 5, 1)
#print(category)
if category == 1:
#topic_file = open("topics1.txt")
topic1 = random.randrange(1, 23, 1)
#return topic1
print(linecache.getline("topics1.txt", topic1))
topic2 = random.randrange(1, 18, 1)
if topic2 == topic1:
topic2 = random.randrange(1, 18, 1)
if topic2 != topic1:
#return topic2
print(linecache.getline("topics1.txt", topic2))
if category == 2:
#topic_file = open("topics2.txt")
topic1 = random.randrange(1, 19, 1)
#return topic1
print(linecache.getline("topics2.txt", topic1))
topic2 = random.randrange(1, 18, 1)
if topic2 == topic1:
topic2 = random.randrange(1, 18, 1)
if topic2 != topic1:
#return topic2
print(linecache.getline("topics2.txt", topic2))
if category == 3:
#topic_file = open("topics3.txt")
topic1 = random.randrange(1, 22, 1)
#return topic1
print(linecache.getline("topics3.txt", topic1))
topic2 = random.randrange(1, 18, 1)
if topic2 == topic1:
topic2 = random.randrange(1, 18, 1)
if topic2 != topic1:
#return topic2
print(linecache.getline("topics3.txt", topic2))
if category == 4:
#topic_file = open("topics4.txt")
topic1 = random.randrange(1, 18, 1)
#return topic1
print(linecache.getline("topics4.txt", topic1))
topic2 = random.randrange(1, 18, 1)
if topic2 == topic1:
topic2 = random.randrange(1, 18, 1)
if topic2 != topic1:
#return topic2
print(linecache.getline("topics4.txt", topic2))
if category == 5:
#topic_file = open("topics5.txt")
topic1 = random.randrange(1, 18, 1)
#return topic1
print(linecache.getline("topics5.txt", topic1))
topic2 = random.randrange(1, 18, 1)
if topic2 == topic1:
topic2 = random.randrange(1, 18, 1)
if topic2 != topic1:
#return topic2
print(linecache.getline("topics5.txt", topic2))
topics()