Write a function to find the smallest odd number in a list. The function takes a list of numbers (each number is greater than or equal to 0) as an input. The function outputs a tuple, where the first number in the tuple is the smallest odd number and the second number in the tuple is the number of occurrences of that number.
For example, if the input is [1, 4, 7, 3, 5, 2, 1, 3, 6] then the output should be the tuple (1, 2)
Python please thanks
#a function to find the smallest odd number in a list.
#return a tuple, smallest number and its count
def smallest_ODDnum(l):
if len(l)==0:#if list is empty
return ()#returning empty tuple
s=-1#to store smallest odd number
c=0#to store count
for i in l:
if i%2==1:#if odd number
if c==0:
c+=1
s=i
else:
if i<s:#smaller than current smallest number
c=1
s=i
elif i==s:
c+=1
return (s,c)
#testing above method
print(smallest_ODDnum([1,4,7, 3, 5, 2, 1, 3, 6]))
print(smallest_ODDnum([3,4,2,7,2, 3,1, 5, 2,1,0,3, 6,0,0,1]))

Write a function to find the smallest odd number in a list. The function takes a...
Define a function called collapse() which takes a list as input. Each element of the list will either be an integer, or a list of integers. The function should modify the input list by replacing all of the elements which themselves are lists with the sum of their elements. For example: Test Result vals = [1, 2, 3, 4, 5] collapse(vals) print(vals) [1, 2, 3, 4, 5] vals = [1, [2, 3], 4, 5] collapse(vals) print(vals) [1, 5, 4, 5]...
1 write a Python function that takes in a list of integers and returns maximum and minimum values in the list as a tuple. Hint (can be done in one pass, you are not allowed to use built-on min and max functions.)max, min = find_max_min(my_list):2 write a Python function that takes in a list of integers (elements), and an integer number (num). The functions should count and return number of integers in elements greater than, less than, and equal to...
This is a python work, thank for helping!
7. (6 points) Write a function, countOfAndSmalest Number Between(low, high, ignore, listOfNumbers), that takes as input three numbers and a list of numbers, and returns a list containing two items: 1) how many items in listOfNumbers are greater than low, less than high, and not equal to ignore 2) the smallest number in listOfNumbers that is greater than low, less than high, and not equal to ignore (or None if there is...
Write a function decompressed(count_tuples)
that takes a list of counts of '0's and '1's as defined above and
returns the expanded (un-compressed) string. You may assume that
the first value of count_tuples has a count that is
greater than or equal to zero and all other counts are greater than
zero.
Comments to show how to figure this out would be greatly
appreciated
A data file in which particular characters often occur multiple times in a row can be compressed...
Write a program called SmallestLargest.java which outputs the biggest and smallest numbers in a list of numbers entered by the user. Ask the user for a terminating value which should be entered again when they are done inputting the list of numbers. First output the biggest number and then the smallest number. There must be at least 1 number in the list. YOU MUST USE THE IO MODULE FOR INPUT/OUTPUT. Report bad input via IO.reportBadInput() and exit on error. Example:...
Python Write a function named minGap that takes in a list of integers and returns the minimum ‘gap’ between values in the list. The gap between two adjacent values in a list is defined as the second value minus the first value. For example, suppose we have the following list: [1, 3, 6, 7, 12] The first gap is between indices 0 and 1 and its value is 3 − 1 = 2. The second gap is 6 − 3...
Write a Python function called FiveNumberSummary(myList) that takes as input a sorted list of numbers and calculates and displays a five-number summary of the list. Given a list of numbers, a five-number summary of the numbers is defined to be the following: Minimum, First Quartile, Median, Third Quartile, Maximum. The first and third quartiles are simply the median of the first half of the numbers and the median of the second half of the numbers.
Use C programming
Make sure everything works well only upload
Write a program that takes an integer from standard input and prints all prime numbers that are smaller than it to standard output. Recall that a prime number is a natural number greater than 1 whose only positive divisors are 1 and itself. At the start of the program, prompt the user to input a number by printing "Input a number greater than 2:\n". If the user's input is less...
Using PYTHON: (Find the index of the smallest element) Write a function that returns the index of the smallest element in a list of integers. If the number of such elements is greater than 1, return the smallest index. Use the following header: def indexOfSmallestElement(lst): Write a test program that prompts the user to enter a list of numbers, invokes this function to return the index of the smallest element, and displays the index. PLEASE USE LISTS!
PYTHON Programming short Questions: 1. Write a function takes as input name (string) and age (number) and prints: My name is <name> and I am <age> years old(where name and age are the inputs) 2. Write a function that takes as input a and b and returns the result of: ??ab 3. Write a function that takes as input a and b and returns the result of: ??ab if it is valid to divide a and b 4. Write a...