Advertisement
Guest User

kok 4e+4f

a guest
Nov 11th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. 4e
  2. #skriv koden din her
  3. def print_db(weather):
  4. print("")
  5. print("DAY | temp | rain | humidity | wind ")
  6. print("====+======+======+==========+======")
  7. for day in weather:
  8. temp = weather[day][0]
  9. rain = weather[day][1]
  10. humidity = weather[day][2]
  11. wind = weather[day][3]
  12. print(format(day,'4d'),format(temp,'6d'),
  13. format(rain,'6d'),format(humidity,'10d'),
  14. format(wind,'6d'))
  15. print_db(weather)
  16.  
  17. -----------------------------------
  18. 4f:
  19. #skriv koden din her
  20. def strange_weather(temp,rain):
  21. counter = 0
  22. record = 0
  23. start = 0
  24. stop = 0
  25. tempstart = 0
  26. N = len(temp)
  27. for i in range(0,N-1):
  28. if (temp[i]<0 and (temp[i]>temp[i+1]) and (rain[i]<rain[i+1])):
  29. counter = counter + 1
  30. if (counter==1):
  31. tempstart = i
  32. if (counter>record):
  33. record = counter
  34. start = tempstart
  35. stop = i+1 # Stops at the next item in the table
  36. else:
  37. counter = 0
  38. if (record == 0):
  39. return (0,0)
  40. else:
  41. return (start+1,stop+1)
  42. temp=[1,3, 4,-5,-6,-7,-8,-9,3,0]
  43. rain=[0,20,30,0,10,30,50,0,5,2]
  44. print(strange_weather(temp,rain))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement