***PYTHON 3***
We are going to practice building some simple lists. Create a function called create_list. It takes 2 parameters, start and end both are integers. This function should return a list that contains all the numbers from start, to end inclusive. So you'll need a loop to count and just append that number into your list and return it. (5 pts )
lst = create_list(5, 10)
lst would be [5, 6, 7, 8, 9, 10]
It should be able to go backwards too.
lst = create_list(10, 5)
lst would be [10, 9,
8, 7, 6, 5]
DON'T FORGET TO GIVE YOUR FUNCTION A DOCSTRING.( 1 pt )
def create_list(start, end):
if start <= end:
lst = []
i = start
while i <= end:
lst.append(i)
i += 1
else:
lst = []
i = start
while i >= end:
lst.append(i)
i -= 1
return lst
print(create_list(5, 10))
print(create_list(10, 5))

***PYTHON 3*** We are going to practice building some simple lists. Create a function called create_list....
1. use python List to Dictionary Write a function that has three parameters: a list of unsorted numbers with no duplicates, a start number, and an end number. This function should return a dictionary with all integers between the start and end number (inclusive) as the keys and their respective indices in the list as the value. If the integer is not in the list, the corresponding value would be None. Example unsorted list: [2,1,10,0,4,3] two numbers: 3, 10 returned...
In PYTHON!
Exercise 3: Lists and Functions In this exercise we will explore the use of lists and functions with multiple inputs and multiple outputs. Your task is to implement the separate_and_sort function. This function takes two input parameters: 1. A list containing strings and integers in any order. 2. An optional integer parameter size which controls how many items in the list the function will process. If the length of the list is smaller than the value of size,...
Using PyCharm, under lab8, under Directory exercise, create a Python file called more_loops.py. Write a function, nbrs_greater that accepts 2 integer lists as a parameters, and returns a list of integers that indicates how many integers in the second list are greater than each integer in the first list. For example: nbrs_greater([3, 4, 1, 2, 7], [10, 1, 4, 2, 5, 3]) returns [3, 2, 5, 4, 1] because: Number of numbers in Element of first list Numbers greater from...
Python
1 Write a function called sum_odd that takes two parameters, then calculates and returns the sum of the odd numbers between the two given integers. The sum should include the two given integers, if they are odd. You can assume the arguments will always be positive integers, and the first smaller than or equal to the second. 3 To get full credit on this problem, you must define at least 1 function, use at least 1 loop, and use...
Python: P2 Write a function that reverses a python list using recursion (Chapter 6-3 in our textbook) E.g.: Input: [9, 8, 7, 6, 5, 4, 3, 2, 1, 0] Output: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] Constraints: - List elements are integers - The function should return a reversed array, not print its elements You may use the following code as template: def reverse(my_list, index = None): # your code here
Please use Python 3, thank you~ Write a program that: Defines a function called find_item_in_grid, as described below. Calls the function find_item_in_grid and prints the result. The find_item_in_grid function should have one parameter, which it should assume is a list of lists (a 2D list). The function should ask the user for a row number and a column number. It should return (not print) the item in the 2D list at the row and column specified by the user. The...
1. Define a function in python that returns the sum of the following 4 lists. Remember to store and re- use your code instead of summing the values for each list 4 times. Hence, define a function that takes as an argument a list and returns the sum of values. Copy the following lists and paste them in a Python file after you define the sum_of_values function Call the function and pass to it a different list each call as...
Write a method called alternate that accepts two Lists as its parameters and returns a new List containing alternating elements from the two lists, in the following order: • First element from first list • First element from second list • Second element from first list • Second element from second list • Third element from first list • Third element from second list If the lists do not contain the same number of elements, the remaining elements from the...
PYTHON
The first function you will write should be called ‘countDown’.
Your function should take zero (0) arguments. The function should
return one (1) list containing integers from 10 to 1 and finally,
the string “Liftoff!”. (i.e., [10, 9, 8, 7, 6, 5, 4, 3, 2, 1,
‘Liftoff!’]). You function must be recursive (i.e., it should
contain a call to itself within the function body). You will get NO
credit if you use any loops (for, while, etc).
3. Function...
IN PYTHON: Write a function that takes, as arguments, two lists, one of which is a character list and the other is the corresponding frequencies, and sorts the characters in ascending order of frequencies. The function should return a list consististing of two lists: the first list is the list of characters and the second is the list of corresponding frequencies, consistent with the rearranged characters. Name this function sortCharacters(characterList, frequencyList). For example, >>>sortCharacters(["a", "b", "c", "d"], [5, 8, 3,...