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 (smallest,largest).You cannot use the built-in function min()or max().
Example otuput:
def minmax(lst):
...
Example Test Function:
def test_minmax():
if minmax([1,2,3])!=(1,3):
print("Error with minmax([1,2,3])")
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 all_pairs that takes two lists as parameters, x and y,and
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 built-in functions or sets.
Example Output:
If the list x =[1,4,6,8]and y =[5,2,6]then the result is the list [(1,5),(1,2),(1,6),(4,5),(4,2),(4,6),(6,5),(6,2),(8,5),(8,2),(8,6)].
Restrictions: Note that (6,6)doesn't appear because they are the same element.
A pair of elements (x,y)is equivalent to the pair (y,x)and you should not generate both (and you should test for this).
List to Dict Function:
Write a function called list_to_dict that takes a list as an argument and returns a dictionary containing the keys 1through n,where n is the size of the list, and the values correspond to the values in the list.
Example Output:
If the list is [2,6,6,1,7,9]then the dictionary maps 1->2,2->6,3->6,4->1,5->7,and 6->9
Invert Dict Function:
Write a function, called invert_dict, 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 adds_to_target, given an integer target and a list of n unordered integers A,which 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 13,and a list A =[1,6,7,3,7,10,3]then there is a pair of integers that add up to 13: 10and 3.If the target were 14then there isnt a pair of distinct integers that add up to 14(cant use 7twice 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 blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!