Advertisement
Guest User

Untitled

a guest
Dec 6th, 2019
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.48 KB | None | 0 0
  1. '''
  2. totalHeight = 0
  3. loop for each height in heightInFt:
  4.    totalHeight = totalHeight + height
  5. averageHeight = totalHeight/numberOfHills
  6. write out 'Average height of the 214 Wainwright hills is ' + averageHeight
  7. smallestHill = minimum height in heightInFt
  8. write out 'The smallest hill is ' + smallestHill
  9. highestHill = maximum height in heightInFt
  10. write out 'The highest hill is ' + highestHill
  11.  
  12. identifier          description                 type
  13. heightInFt  heights of hills                   list of integer
  14. height      loop control variable               integer
  15. averageHeight   average height of hills         real
  16. smallestHill    smallest hill                   integer
  17. highestHill    highest hill                     integer
  18. '''
  19.  
  20. import math
  21.  
  22. heightInFt = [2575, 1860, 1906, 1572, 1421, 1745, 2208, 2241, 1535, 1493, 2119,1670,1467,2356,2041,1060,1880,
  23.               1775, 1936, 2848, 1719, 2959, 2303, 1923, 2346, 2339, 2612, 1841,1677,1378,1558,1762,2448,2165,
  24.               951, 1480, 2920, 2503, 2090, 2264, 2382, 2300, 2635, 1716, 2818,2470,1647,2815,2598,2552,1706,
  25.               2753, 2904, 2864, 1365, 2126, 2362, 1726, 1378, 2569, 1450, 1578,1345,2795,2293,1496,2021,2264,
  26.               2559, 1726, 1444, 2812, 2986, 2949, 1762, 1762, 2136, 1604, 2628,2093,2526,2287,1601,2595,1273,
  27.               1801, 2415, 2697, 2480, 2142, 2552,1903,2028,2615,1959,1329,3117,1670,2008,2441,1703,2159,
  28.               2152, 2500, 2631, 1161, 1995, 2142,2648,2717,1690,2385,1040,2526,2484,1998,2395,2559,2631,
  29.               2329, 1824, 2425, 1775, 1207, 1224,2625,1539,2090,1657,2201,2231,2408,1585,2346,1811,1099,
  30.               1388, 1667, 1890, 2493, 1804, 1680,2146,1909,2077,1444,1890,2923,1864,2297,2313,2326,2927,
  31.               2156, 2897, 2598, 1165, 1512, 2477,2710,2546,2283,2418,2133,1807,2536,2759,1178,1693,3163,
  32.               3209, 2205, 2759, 2415, 2270, 2073,2149,2395,1873,2215,1926,1293,3054,2838,2500,1585,1713,
  33.               2077, 1814, 1417, 2687, 1640, 2766,2631,1804,2178,2572,2372,1194,2231,2382,1243,2533,1598,
  34.               2589, 2198, 2500, 1755, 1722, 2831, 2165, 2320, 2060, 2316]
  35. totalHeight = 0
  36. for height in heightInFt:
  37.     totalHeight += height
  38. averageHeight = totalHeight/len(heightInFt)
  39. averageHeight = math.floor(averageHeight)
  40. print('Average height of the 214 Wainwright hills is ' + str(averageHeight))
  41. smallestHill = min(heightInFt)
  42. print('The smallest hill is ' + str(smallestHill))
  43. highestHill = max(heightInFt)
  44. print('The highest hill is ' + str(highestHill))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement