In Python Complete the function powersOf5(). Have the function take a parameter n and return a list of the first n powers of 5. One way to calculate powers of 5 is by starting with 1 and then multiplying the previous number by 5.
Examples:
powersOf5( 1 ) returns [1]
powersOf5( 2 ) returns [1, 5]
powersOf5( 3 ) returns [1, 5, 25]
powersOf5( 6 ) returns [1, 5, 25, 125, 625, 3125]
powersOf5( 10 ) returns [1, 5, 25, 125, 625, 3125, 15625, 78125, 390625, 1953125]
code:

output:

def powersOf5(n): #function
powers_of_n_list = [1] #initialize list with one element with value
1, thus index at element 0 is 1
for i in range(1,n): #loop through 1 to n-1
powers_of_n_list.insert(i,powers_of_n_list[i-1]*5) #insert element
which is obtained by multiplying 5 with element at previous index
at index i of list , thus element at index 1 = element at index 0 *
5 = 1*5 = 5, element at index 2 = element at index 1*5 = 5*5 = 25
and so on..
return powers_of_n_list #return list
print("powersOf5(1): ", powersOf5(1))
print("powersOf5(2): ", powersOf5(2))
print("powersOf5(3): ", powersOf5(3))
print("powersOf5(6): ", powersOf5(6))
print("powersOf5(10): ", powersOf5(10))
In Python Complete the function powersOf5(). Have the function take a parameter n and return a...
In Python, Complete the extraCreditTotal() function to take a list of grades as a parameter and return the total number points above 100. Examples: extraCreditTotal( [101, 83, 107, 90] ) returns 8 (because 1 + 0 + 7 + 0 is 8) extraCreditTotal( [89, 113, 95] ) returns 13 extraCreditTotal( [89, 73, 96, 97, 99, 100] ) returns 0
Complete in python The function unique_count returns the number of unique items in its parameter, lst, which is a list. For example, if given the list [3, 3, 3, 5, 3], unique_count would return 2, because there are only two unique items in the list: 3 and 5. here is the starter code def unique_count(lst):
In python Complete the function mostCommonCount() so that will accept a list of names as a parameter, and return the count of the most common name in the list. Examples: mostCommonCount( ['marquard', 'zhen', 'csev', 'zhen', 'cwen', 'marquard', 'zhen', 'csev', 'cwen', 'zhen', 'csev', 'marquard', 'zhen'] ) returns 5 mostCommonCount( ['Jacob', 'Michael', 'Joshua', 'Matthew', 'Emily', 'Madison', 'Emma', 'Olivia', 'Hannah'] ) returns 1
For Python: Complete the function sum_v2 that takes an integer n as input parameter and computes the sum of all odd integers between 5 and n (inclusively). Use FOR LOOP only and NO IF STATEMENTS.
The function below takes a single parameter, a list of numbers called number_list. Complete the function to return a string of the provided numbers as a series of comma separate values (CSV). For example, if the function was provided the argument [22, 33, 44], the function should return '22,33,44'. Hint: in order to use the join function you need to first convert the numbers into strings, which you can do by looping over the number list to create a new...
This is a python question. Write a function mult_table(n) that consumes a natural number n and returns the n+1 by n+1 multiplication table (where each entry in the inner list is equal to the product of which list it is and the inner list position number, or in other words, the product of the row and column numbers). Using accumulative recursion, no abstract list functions. def mult_table(n) ''' Returns the n+1 by n+1 multiplication table mult_table: Nat => (listof...
in python Complete the function read_r_line(fname, ln) to take a filename and a line number and return the contents of that line number from the file as a string. Hint: The code from Files03 will be helpful. Example: read_r_line('myf.txt', 5) will return 'I like peanut'
Complete the get_mid_letter() function which is passed a list of strings as a parameter. The function returns a string made up of the concatenation of the middle letter of each word from the parameter list. The string returned by the function should be in lowercase characters. If the parameter list is an empty list, the function should return an empty string For example Test Result print("1.", get mid_letter"Jess", "Cain", Amity", "Raeann"])) 1. siia Answer (penalty regime: 0 %) 1 -Idef...
28Write a Python function from scratch called has_5_or_more_elements that takes a single list parameter. Your function should return a Boolean. The return value should be True if the list parameter has 5 or more elements and False otherwise.
#Write a function called next_fib. next_fib should take #have two parameters: a list of integers and a single integer. #For this description, we'll call the single integer n. # #next_fib should modify the list to add the next n pseudo- #Fibonacci numbers to the end of the sequence. A pseudo- #Fibonacci number is the sum of the previous two numbers in #the sequence, but in our case, the previous two numbers may #not be the original numbers from the Fibonacci...