Advertisement
Guest User

Untitled

a guest
Jan 19th, 2020
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.01 KB | None | 0 0
  1. # Akvaariokalat vaativat vedeltä  6.0 - 8.0 pH:n tason.
  2.  
  3. def main():
  4.     syote = input("Enter the number of the measurements: ")
  5.     mittausten_lkm = int(syote)
  6.     i = 0
  7.  
  8.     if mittausten_lkm < 1:
  9.         print("Error: the number must be expressed as a positive integer.")
  10.     else:
  11.         summa = 0
  12.         while i < mittausten_lkm:
  13.             syote = input("Enter the measurement result %s: " % (i + 1))
  14.             mittaustulos = float(syote)
  15.             i += 1
  16.             summa = summa + mittaustulos
  17.             keskiarvo = summa / mittausten_lkm
  18.  
  19.             try:
  20.                 if mittaustulos < 6.0 or mittaustulos > 8.0 or abs(mittaustulos - temp) > 1:
  21.                     print("The conditions are not suitable for zebra fishes.")
  22.                     break
  23.             except NameError:
  24.                 temp = mittaustulos
  25.                 continue
  26.  
  27.         if 6.0 < keskiarvo < 8.0:
  28.             print("Conditions are suitable for zebra fishes. The average pH is %.2f." % keskiarvo)
  29.  
  30.  
  31. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement