Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
def factfunction():
loopCounter = 0
'''This function will give different facts to the user from the input of either A,B,C,D,E'''
import random
replyList1 = ["The time is always right to do what is right. – Martin Luther King Jr.",
"You never fail until you stop trying. – Albert Einstein",
"Pain is temporary. Quitting lasts forever. – Lance Armstrong",
"Only surround yourself with people who will lift you higher. – Oprah Winfrey"]
replyList2 = ["good", "Good", "Great", "Awesome", "awesome", "Amazing", "amazing"]
replyList3 = ["bad", "not good", "not great", "sad", "Sad"]
replyList4 = ["That's great", "That's Wonderfull", "That's very good to hear"]
decisionC = input("How are you feeling today ")
for i in replyList2:
if i == decisionC:
print(random.choice(replyList4))
for ii in replyList3:
if ii == decisionC:
print(random.choice(replyList1))
historyList = ["About one third of Ancient Greeks were slaves",
"Ancient Egyptiants used mouldy bread to heal wounds quickly and a lot of the time, it worked!",
"Leonardo Da Vinci was born near Florence in Italy in 1452."]
sportsList = ["Olympic Gold Medals are Predominantly Made from Sterling Silver",
"The First Recorded Diving Championship in the UK Took Place in 1889",
"Ski Ballet Used to be a Competitive Sport"]
scienceList = ["Some metals are so reactive that they explode on contact with water",
"In 2.3 billion years it will be too hot for life to exist on Earth",
"It takes 8 minutes, 19 seconds for light to travel from the Sun to the Earth"]
geographyList = ["Hawaii moves 7.5cm closer to Alaska every year",
"20% of Earth's oxygen is produced by the Amazon rainforest",
"Ninety percent of the Earth's population lives in the Northern Hemisphere"]
print("Which subject would you like to learn facts about?")
while True:
print("Pick a letter: A)History, B)Sports, C)Science, D)Geography,E)Random Fact ")
decisionA = input()
if (decisionA == 'A'):
print(random.choice(historyList))
elif (decisionA == 'B'):
print(random.choice(sportsList))
elif (decisionA == 'C'):
print(random.choice(scienceList))
elif (decisionA == 'D'):
print(random.choice(geographyList))
elif (decisionA == 'E'):
import requests
url = "https://facts-by-api-ninjas.p.rapidapi.com/v1/facts"
headers = {
'x-rapidapi-host': "facts-by-api-ninjas.p.rapidapi.com",
'x-rapidapi-key': "f07e1a114fmshd50bd4cab97dab2p14d6e6jsnf28475c2608a"
}
response = requests.request("GET", url, headers=headers)
print(response.text)
else:
print("Invalid Input")
decisionB = input("Do you want to start over to learn another fact? ")
if (decisionB == 'yes'):
loopCounter = loopCounter + 1
else:
print("Bye")
exit()
return False
factfunction()