Difference between revisions of "CSC111 Homework 8 Solution Programs 2014"
(→Program 2) |
|||
(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
--[[User:Thiebaut|D. Thiebaut]] ([[User talk:Thiebaut|talk]]) 10:41, 12 April 2014 (EDT) | --[[User:Thiebaut|D. Thiebaut]] ([[User talk:Thiebaut|talk]]) 10:41, 12 April 2014 (EDT) | ||
---- | ---- | ||
+ | <onlydft> | ||
+ | |||
=Program 1= | =Program 1= | ||
<br /> | <br /> | ||
Line 333: | Line 335: | ||
#answer to question 1 | #answer to question 1 | ||
coldest = findColdestTemp(tempList) | coldest = findColdestTemp(tempList) | ||
− | print("The coldest temperature recorded is %.1fC in %d/%d, in %s." % (coldest[0], coldest[2], coldest[1], coldest[3])) | + | print("The coldest temperature recorded is %.1fC in %d/%d, in %s." |
+ | % (coldest[0], coldest[2], coldest[1], coldest[3])) | ||
#answer to question 2 | #answer to question 2 | ||
hottest = findHottestTemp(tempList) | hottest = findHottestTemp(tempList) | ||
− | print("The hottest temperature recorded is %.1fC in %d/%d, in %s." % (hottest[0], hottest[2],hottest[1], hottest[3])) | + | print("The hottest temperature recorded is %.1fC in %d/%d, in %s." |
+ | % (hottest[0], hottest[2],hottest[1], hottest[3])) | ||
#answer to question 3 | #answer to question 3 | ||
coldestCity = findColdestCity(tempList, 2011) | coldestCity = findColdestCity(tempList, 2011) | ||
− | print("The coldest city in 12/%d is %s at a temperature of %.1fC." % (coldestCity[1], coldestCity[3], coldestCity[0])) | + | print("The coldest city in 12/%d is %s at a temperature of %.1fC." |
+ | % (coldestCity[1], coldestCity[3], coldestCity[0])) | ||
#answer to question 4 | #answer to question 4 | ||
diff = findLargestSwing(tempList) | diff = findLargestSwing(tempList) | ||
− | print("%s saw the largest temperature difference of %.1fC in %d/%d." % (diff[3], diff[0], diff[2], diff[1])) | + | print("%s saw the largest temperature difference of %.1fC in %d/%d." |
+ | % (diff[3], diff[0], diff[2], diff[1])) | ||
main() | main() | ||
Line 351: | Line 357: | ||
</source> | </source> | ||
+ | </onlydft> | ||
<br /> | <br /> |