Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- w_data = [{'date': ['may','mon',2],'temp': [20,10,12],'cover':[90,30,'N',15]},
- {'date': ['june','tues',21],'temp': [28,14,17],'cover':[30,2,'W',5]},
- {'date': ['july','wednes',20],'temp': [32,21,24],'cover':[0,0,'S',2]},
- {'date': ['august','thurs',25],'temp': [36,24,26],'cover':[0,0,'W',1]}]
- greetings = ["G'Day all. ", "Hello Campers! ", "Hello you lucky people! ", "Good Day fellow sufferers. "]
- midlist = ["It's rather a cool day, only reaching %s degrees. \n",
- "It'll be warm and humid today, reaching %s degrees! \n",
- "Here comes the sun! Expect temperatures up to %s degrees. \n",
- "It's a belter today! Better cover up as the temperatures could reach %s degrees! \n"]
- for adict in w_data:
- month, day, daynum = adict['date']
- tempmax, tempmin, tempmid = adict['temp']
- cloudmax, cloudmin, windir, winspeed = adict['cover']
- suffix = "th"
- if daynum in [1, 21, 31]:
- suffix = "st"
- if daynum in [2, 22]:
- suffix = "nd"
- if daynum in [3, 23]:
- suffix = "rd"
- idx1 = 0
- if tempmax > 33:
- idx1 = 3
- elif tempmax > 30:
- idx1 = 2
- elif tempmax > 25:
- idx1 = 1
- daydict = {"mon": "back-to-work Monday,", "tue": "Tuesday,", "wed": "Wednesday, yep, mid-week,",
- "thu": "Thursday, weekend is coming!",
- "fri": "Friday,", "sat": "Saturday. Enjoy your weekend!", "sun": "stay-in-bed Sunday,"}
- daykey = day[:3].lower()
- dayfull = daydict[daykey]
- msgcloud = "Expect a large amount of cloud cover. \n"
- if cloudmax < 50:
- msgcloud = "But there will be a few clouds around. \n"
- if cloudmax < 25:
- msgcloud = "There may be the odd cloud to be seen.\n"
- if cloudmax < 10:
- msgcloud = "And not a cloud in the sky! \n"
- msgwind = "It will be breezy, with winds from the %s.\n"
- if winspeed < 15:
- msgwind = "Winds will be very light, coming from the %s.\n"
- if winspeed < 5:
- msgwind = "It will be very still, with hardly a breeze to refresh us from the %s. \n"
- windict = {"N": "north", "E": "east", "S": "south", "W": "west"}
- wind = windict[windir]
- msg = greetings[idx1]
- msg += "Today is " + dayfull + " " + month.title() + " " + str(daynum) + suffix + ",\n"
- msg += midlist[idx1]
- msg += msgcloud
- msg += msgwind
- print(msg % (tempmax, wind))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement