forked from SalamanderKrajza/ai_devs2_python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathC01L05_liar.py
36 lines (28 loc) · 1.16 KB
/
C01L05_liar.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
import sys
sys.path.append(r'..')
from task_handler import get_task_token, get_task_info_from_token, send_answer_by_task_token, apikey
# --------------------------------------------------------------
# Get task data
# --------------------------------------------------------------
# NOTE - this is different than previous because this time /get_task_info requires additional context
import requests
task_token = get_task_token(taskname='liar', apikey=apikey)
url = f'https://tasks.aidevs.pl/task/{task_token}'
data = {
"question": "Odpowiedz jednym słowem używając małych liter: Jaki kolor ma trawa?"
}
response = requests.post(url, data=data)
print(response.status_code, response.json())
# --------------------------------------------------------------
# Prepare answer
# --------------------------------------------------------------
response.json()['answer']
if response.json()['answer'] == "zielony":
answer = 'YES'
else:
answer = 'NO'
data = {"answer": answer}
# --------------------------------------------------------------
# send answer
# --------------------------------------------------------------
response = send_answer_by_task_token(task_token, data)