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