Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ###########################################################################################
- # Name: Seth O'Quin
- # Date: 1/17/18
- # Description: Casual Statistics
- ###########################################################################################
- # function that prompts the user to enter an integer and returns it
- def getInteger():
- integer = input("Enter an integer: ")
- return integer
- # function that receives three integers as parameters and returns the minimum of the three
- def minofThree( x, y, z):
- minnum = x
- if y < minnum:
- minnum = y
- if z < minnum:
- minnum = z
- print "The minimum value is {}." .format(minnum)
- # function that receives three integers as parameters and returns the maximum of the three
- def maxofThree( x, y, z):
- maxnum = x
- if y > maxnum:
- maxnum = y
- if z > maxnum:
- maxnum = z
- print "The maximum value is {}." .format(maxnum)
- # function that receives three integers as parameters, and calculates and returns the mean
- def meanofThree( x, y, z):
- mean = (x + y + z)/3.0
- print "The mean is {}." .format(mean)
- # function that receives three integers as parameters, and calculates and returns the median
- def medianofThree( x, y, z):
- # function that receives three integers as parameters, and calculates and returns the mode
- def modeofThree( x, y, z):
- if (x == y):
- print "The mode is {}." .format(x)
- elif (x == z):
- print "The mode is {}." .format(x)
- elif (y == z):
- print "The mode is {}." .format(y)
- else:
- print "The mode is undefined."
- # function that receives three integers as parameters, and calculates and returns the range
- def rangeofThree( x, y, z):
- small = x
- if (small > y):
- small = y
- if (small > z):
- small = z
- large = x
- if (large < y):
- large = y
- if (large < z):
- large = z
- rangexyz = (large - small)
- print "The range is {}." .format(rangexyz)
- ###############################################
- # MAIN PART OF THE PROGRAM
- # implement the main part of your program below
- # comments have been added to assist you
- ###############################################
- # get three integers from the user
- x = getInteger()
- y = getInteger()
- z = getInteger()
- # determine and display the minimum value
- minofThree( x, y, z)
- # determine and display the maximum value
- maxofThree( x, y, z)
- # calculate and display the mean
- meanofThree( x, y, z)
- # calculate and display the median
- # calculate and display the mode
- modeofThree( x, y, z)
- # calculate and display the range
- rangeofThree( x, y, z)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement