Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 4e
- #skriv koden din her
- def print_db(weather):
- print("")
- print("DAY | temp | rain | humidity | wind ")
- print("====+======+======+==========+======")
- for day in weather:
- temp = weather[day][0]
- rain = weather[day][1]
- humidity = weather[day][2]
- wind = weather[day][3]
- print(format(day,'4d'),format(temp,'6d'),
- format(rain,'6d'),format(humidity,'10d'),
- format(wind,'6d'))
- print_db(weather)
- -----------------------------------
- 4f:
- #skriv koden din her
- def strange_weather(temp,rain):
- counter = 0
- record = 0
- start = 0
- stop = 0
- tempstart = 0
- N = len(temp)
- for i in range(0,N-1):
- if (temp[i]<0 and (temp[i]>temp[i+1]) and (rain[i]<rain[i+1])):
- counter = counter + 1
- if (counter==1):
- tempstart = i
- if (counter>record):
- record = counter
- start = tempstart
- stop = i+1 # Stops at the next item in the table
- else:
- counter = 0
- if (record == 0):
- return (0,0)
- else:
- return (start+1,stop+1)
- temp=[1,3, 4,-5,-6,-7,-8,-9,3,0]
- rain=[0,20,30,0,10,30,50,0,5,2]
- print(strange_weather(temp,rain))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement