Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- temperatures = input("temperature data: ").split(",")
- value_min = float("inf")
- time_min = 0
- value_max = float("-inf")
- time_max = 0
- faulty_count = 0
- good_count = 0
- sum = 0
- i = 0
- while(i<len(temperatures)):
- if(temperatures[i] == "-"):
- faulty_count = faulty_count + 1
- else:
- aktuell = float(temperatures[i])
- if(aktuell>value_max):
- value_max = aktuell
- time_max = i
- if(aktuell<value_min):
- value_min = aktuell
- time_min = i
- if(aktuell > 60):
- faulty_count = faulty_count + 1
- else:
- good_count = good_count + 1
- if(aktuell < -60):
- faulty_count = faulty_count + 1
- else:
- good_count = good_count + 1
- sum = sum + aktuell
- i = i + 1
- if(good_count >= 1):
- print("maximum temperature: " + str(value_max) + "°C um " + str(time_max) + " Uhr")
- print("minimal temperature: " + str(value_min) + "°C um " + str(time_min) + " Uhr")
- print("difference: " + str(value_max-value_min) + "°C")
- print("average temperature: " + str( sum / (good_count) ) + "°C")
- print("unreal temperatures: " + str(faulty_count))
- else:
- print("only unreal temperatures")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement