Answer the question
In order to leave comments, you need to log in
How to get the names of north, east, south from wind deg in degrees?
I tried it like this
wind = w.wind()
w3 = wind['deg']
w4 = itog
c = range(337,380)
c = range(0,22)
cv = range(22,67)
v = range(67,112)
yv = range(112,157)
y = range(157,202)
yz = range(202,247)
z = range(247,292)
cz = range(292,337)
if w3 == c:
itog = 'С';
elif w3 == cv:
itog = 'СВ';
elif w3 == v:
itog = 'В';
elif w3 == yv:
itog = 'ЮВ';
elif w3 == y:
itog = 'Ю';
elif w3 == yz:
itog == 'ЮЗ';
elif w3 == z:
itog == 'З';
elif w3 == cz:
itog == 'СЗ';
answer = 'В городе '+message.text+' направление ветра ' + w4
if message.text == message.text:
bot.send_message(message.from_user.id, answer);
Answer the question
In order to leave comments, you need to log in
winddirections = ("северный", "северо-восточный", "восточный", "юго-восточный", "южный", "юго-западный", "западный", "северо-западный")
direction = int((degrees + 22.5) // 45 % 8)
print(winddirections[direction])
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question