The files are attached below. Please do the coding in the exact manner and order my professor needs it to be.
Assignment 6 Question 1 Part 1: Simple Functions For this part you will be completing a series of short programming challenges that use various function concepts. Each challenge should be saved as its own file (i.e. Kapp_Craig_Assign6_part1_challenge1.py). Challenge 1 Begin by copying the following program into a new file. # these are the basic arithmetic functions you will be using for this challenge # function: add # input: two integers/floats # processing: adds the two supplied values # output: returns the sum (integer/float) def add(a,b): return a+b # function: sub # input: two integers/floats # processing: subtracts the two supplied values # output: returns the difference (integer/float) def sub(a,b): return a-b # function: mult # input: two integers/floats # processing: multiplies the two supplied values # output: returns the product (integer/float) def mult(a,b): return a*b # function: div # input: two integers/floats # processing: divides the first value by the second value # output: returns the result (float) def div(a,b): return a/b # function: sqrt # input: one integer/float # processing: computes the square root of the supplied value # output: returns the square root (float) def sqrt(a): return a**0.5 # function: square # input: one integer/float # processing: raises the supplied integer/float to the 2nd power # output: returns the square (integer/float) def square(a): return a**2 Your task is to translate some simple expressions into function calls. Here are the rules: • You can only fill in the blank with a single line of code • You cannot use any math operations (i.e. +, -, /, *, // or % are strictly prohibited) • You cannot use any print statements • You cannot reduce your terms (i.e. if you are asked to translate 1+2+3 you can't simply add these together yourself and supply the number 5 to the program) • The only thing you can use are calls to the functions above, in any order • You cannot use any calls to any functions other than the ones above (i.e. input, len, etc. are all prohibited) Here is an example to get you started: # translate this expression: # y = mx + b m = 3 x = 2 b = 5 y = __________ print(y) # you should expect 11 as your output You can solve this by create a function call that looks like the following: y = add(mult(m,x),b) Challenge 1: Expression 1 # translate this expression: # x = (3-4) + (1*2) x = __________ print(x) # you should expect 1 as your output Challenge 1: Expression 2 # translate this expression: # x = 5 + 1 + 7 + 9 + 13 + 12 x = __________ print(x) # you should expect 47 as your output Challenge 1: Expression 3 # translate this expression: # x = (5 + 1) / (7 + 2 + 3) x = __________ print(x) # you should expect 0.5 as your output Challenge 1: Expression 4 # compute the distance between these two points # point 1 x1 = 0 y1 = 0 # point 2 x2 = 100 y2 = 100 distance = ______________________ print (distance) # you should expect 141.4213562373095 as your output Recall that the distance formula is defined as follows: Challenge 2 Write two functions called 'maximum' and 'minimum' - these function should accept two arguments and return the larger/ smaller of the two supplied values. For the purpose of this program you can always assume that the arguments being supplied are numeric. Describe your function using IPO notation. Your program should work perfectly with the following code: a = 5 b = 10 c = 15 d = 20 e = 20 ans1 = maximum(a,b) ans2 = maximum(a,c) ans3 = maximum(a,d) print (ans1,ans2,ans3) # 10 15 20 ans4 = minimum(d,c) ans5 = minimum(d,b) ans6 = minimum(d,a) print (ans4,ans5,ans6) # 15 10 5 ans7 = maximum( maximum(a,b), maximum(c,d) ) print ("The biggest is:", ans7) ans8 = maximum(d,e) # d and e are the same, so either is considered the maximum ans8 = minimum(d,e) # d and e are the same, so either is considered the minimum print(ans8, ans8) # 20 20 Challenge 3 Write a function called 'valid_date' which accepts two arguments - a month and a day (both integers, will always be integers). Test to see if the date being described is valid or not. If the date is valid your function should return a True value, and if it is not it should return a False value. For the purpose of this program you can assume February has 28 days. Describe your function using IPO notation. Your program should work perfectly with the following code: print (valid_date(99,1)) # False print (valid_date(1,99)) # False print (valid_date(99,99)) # False print (valid_date(-99,1)) # False print (valid_date(1,-99)) # False print (valid_date(-99,-99)) # False print (valid_date(9,25)) #True print (valid_date(10,15)) # True print (valid_date(11,31)) # False print (valid_date(2,28)) # True print (valid_date(2,29)) # False Challenge 4 # write a function called 'simple_sort_version1' that accepts two values. you can assume # that your three values will always be the same data type (all ints, all floats or all strings). # sort these two values in ascending order and return them in that order. # you may use any function that you've written so far in this assignment if you'd like to (maximum, minimum, etc) # your function should work perfectly with the following lines of code a,b = simple_sort_version1(10,20) print (a,b) # 10 20 a,b = simple_sort_version1(20,10) print (a,b) # 10 20 a,b = simple_sort_version1(30,30) print (a,b) # 30 30 Challenge 5 # next, write a new function called 'simple_sort_version2' that accepts three values. you can assume # that your three values will always be the same data type (all ints, all floats or all strings). # sort these values in ascending order and return them. # you may use any function that you've written so far in this assignment if you'd like to (simple_sort_version1, maximum, minimum, etc) # your function should work perfectly with the following lines of code a,b,c = simple_sort_version2(10,20,30) print (a,b,c) # 10 20 30 a,b,c = simple_sort_version2(10,30,20) print (a,b,c) # 10 20 30 a,b,c = simple_sort_version2(30,20,10) print (a,b,c) # 10 20 30 a,b,c = simple_sort_version2(30,20,20) print (a,b,c) # 20 20 30 assignment 6 question 2 Part 2 For part 2 of this assignment you will be writing a series of programs that build on one another, so it's important to progress through this part in order. You should submit each individual part of the assignment as a separate file to the Assignment #6 category inside of Brightspace. Part 2a: Number Analysis Functions Write a series of five functions that determine if a given positive integer is EVEN, ODD, PRIME, PERFECT and ABUNDANT. Each of these functions should accept a single integer as an argument and return whether the integer meets the criteria for that classification. Here's some IPO notation to get you started: # function: is_even # input: a positive integer # processing: determines if the supplied number is even # output: boolean # function: is_odd # input: a positive integer # processing: determines if the supplied number is odd # output: boolean # function: is_prime # input: a positive integer # processing: determines if the supplied number is prime. a prime number is # a number that only has two factors - the number 1 and itself. # for example, 17 is prime because it only has two factors (1 and 17). # in order to determine this you might need to count the # of factors # between 1 and the number you are testing. a note on efficiency: if you are # testing a number (say, 15) and you find a factor (say, 3) - do you need to even continue # to find additional factors? The number 1 should not be considered to be prime. # output: boolean # function: is_perfect # input: a positive integer # processing: determines if the supplied number is perfect. a perfect number # is a number that is equal to the sum of its factors (i.e. the # number 6 is perfect because 6 = 1 + 2 + 3) # output: boolean # function: is_abundant # input: a positive integer # processing: determines if the supplied number is abundant. an abundant number # is a number