Question: Hello, I need help writing a Python program that tests various functions for practice: Min Max Write a function called minmax that takes a list
Hello, I need help writing a Python program that tests various functions for practice:
Min Max
Write a function called minmax that takes a list of numbers and returns the smallest element and largest element as the tuple smallestlargestYou cannot use the builtin function minor max
Example otuput:
def minmaxlst:
Example Test Function:
def testminmax:
if minmax:
printError with minmax
Additional Function:
You will create a function that ensures the input list order is not relied upon to solve this task.
All Pairs Function:
Write a function called allpairs that takes two lists as parameters, x and yand
returns a new list containing all possible pairs consisting of one element from x and one
element from y as long as they are not the same.
Do not use builtin functions or sets.
Example Output:
If the list x and y then the result is the list
Restrictions: Note that doesnt appear because they are the same element.
A pair of elements xyis equivalent to the pair yxand you should not generate both and you should test for this
List to Dict Function:
Write a function called listtodict that takes a list as an argument and returns a dictionary containing the keys through nwhere n is the size of the list, and the values correspond to the values in the list.
Example Output:
If the list is then the dictionary maps and
Invert Dict Function:
Write a function, called invertdict, that takes a dictionary as an argument and returns a new dictionary with the keys and values inverted keys become values and values become keys
Requirements:
What happens if there are duplicate values? A short comment with the answer is fine.
Adds to Target Function:
Write a function, called addstotarget, given an integer target and a list of n unordered integers Awhich determines if there is a distinct pair of integers in A that add up to the target. The function should return True or False depending on if it is possible. You must perform this task using sets.
Example Output:
Given a target of and a list A then there is a pair of integers that add up to : and If the target were then there isnt a pair of distinct integers that add up to cant use twice even if it appears twice in the list
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
