forked from mayankchaudhary26/HacktoberFest-Practice-2021
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathactivity_suggestor.py
More file actions
30 lines (28 loc) Β· 1.07 KB
/
activity_suggestor.py
File metadata and controls
30 lines (28 loc) Β· 1.07 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
import requests
import sys
from time import sleep
def getActivity(activityType):
recieve = requests.get(url='http://www.boredapi.com/api/activity?type='+activityType)
# calling an api to get some acitvity
data = recieve.json() #parsing the json file
activity = data['activity'] #getting the activity name
return activity
if __name__=="__main__":
choices = ["education", "recreational", "social", "diy", "charity", "cooking", "relaxation", "music", "busywork"]
wmessage = "Getting bored?\nWan't some suggestions about something interesting?"
for c in wmessage:
sleep(0.1)
sys.stdout.write(c)
sys.stdout.flush()
# used the above loop to get a typing effect
sleep(0.5)
print("\n\nChose a type of activity that might excite you:")
i=1
for choice in choices:
print("\nEnter "+str(i)+" for "+choice)
i+=1
sleep(0.5)
choiceNumber = int(input("\nEnter your choice number: "))
sleep(0.5)
print("\nMay be you can try something like: \n")
print(getActivity(choices[choiceNumber-1]))