
write the following code in python 3.2+. Recursive function prefered. Thank you!
Please give thumbs up, If it is helpful for you. Thankyou!!
mydict={}
def q3(lst):
global mydict
if len(lst) <3:
return
else:
str1 = ''.join(lst[0:3])
if (str1 not in mydict.keys()):
mydict[str1]=1
q3(lst[1:])
else:
mydict[str1]+=1
q3(lst[1:])
return mydict
lst=['A','B','A','B','A','A']
print(q3(lst))
![I #1 /usr/bin/env python2 2# -*- coding: utf-8- Created on Fri Apr 28 15:34:13 2017 6 @author 9 10 def q3 (lst) global nydict if len(lst) <3 12 13 14 15 16 17 18 19 return else str1- . join(lst[ :3]) if (str1 not in nydict.keys()) mydictstr1]-1 q3(lstl1:) else mydictstr1]+ 1 q3(lst[1: ]) 21 return nydict 23 24 25 26 1st=[ A , B , A , B , A , A ] 27 print (q3(lst)) 28](http://img.homeworklib.com/questions/fa6d74b0-4e3d-11eb-938e-1bae6dce71cd.png?x-oss-process=image/resize,w_560)
Output:

write the following code in python 3.2+. Recursive function prefered. Thank you! Define a function named...
Write a recursive function called freq_of(letter, text) that finds the number of occurrences of a specified letter in a string. This function has to be recursive; you may not use loops! CodeRunner has been set to search for keywords in your answer that might indicate the use of loops, so please avoid them. For example: Test Result text = 'welcome' letter = 'e' result = freq_of(letter, text) print(f'{text} : {result} {letter}') welcome : 2 e and A list can be...
Python 5. Write a function named grade_components that has one parameter, a dictionary. The keys for the dictionary are strings and the values are lists of numbers. The function should create a new dictionary where the keys are the same strings as the original dictionary and the values are tuples. The first entry in each tuple should be the weighted average of the non-negative values in the list (where the weight was the number in the 0 position of the...
Define a Python function named borough_count
that has one parameter. The parameter is a string representing the
name of a CSV file. The CSV file is a subset of NYC's dataset of
all film permits issued since April 2016. Each row in the CSV file
has the format:
Event Id, Police Precinct(s), Event Type, Borough, Category
Your function must return a dictionary. The keys of this dictionary
will be the boroughs read in from the file (boroughs are at index...
Write a python program (recursive.py) that contains a main() function. The main() should test the following functions by calling each one with several different values. Here are the functions: 1) rprint - Recursive Printing: Design a recursive function that accepts an integer argument, n, and prints the numbers 1 up through n. 2) rmult - Recursive Multiplication: Design a recursive function that accepts two arguments into the parameters x and y. The function should return the value of x times...
python 3.7
write a function called read_file() which accepts a filename and returns a list of tuple objects. For example, if we have the following data: 0.000000000 192.168.0.24 10.0.0.5 H-NM 1.001451000 192.168.0.24 10.0.0.5 2.002970000 192.168.0.24 10.0.0.5 3.003552000 192.168.0.24 10.0.0.5 4.005007000 192.168.0.24 10.0.0.5 then the list should contain the following: [('192.168.0.24', 0, 84), ('192.168.0.24', 1, 84), ('192.168.0.24', 2, 84), ('192.168.0.24', 3, 84), ('192.168.0.24', 4, 84)] Note: • Each line consists of a number of fields separated by a single tab character....
Define the functions in Python 3.8
1. Write a function most frequent n that takes a list of strings and an integer n, and that returns a dictionary where the keys are the top n most frequent unique words in the list, and the values are the frequency of each word: For example, most frequent n(text, 3) should return the dictionary {'is': 2, "the’: 3, 'of': 2}, and most frequent n(text, 2) could return either {'is': 2, 'the’: 3} or...
i need python code, thank you very much!
characters) and prints ) 3. Write function, smallestCharacterLargerThan(keyChar, inputString) that takes as input key character, keyChar, and a string of one or more letters (and no other the "smallest" character in the string that is larger than keyChar, where one character is smaller than another if it occurs earlier in the alphabet (thus 'C is smaller than 'y' and both are larger than 'B') and 2) the index of the final occurrence...
average_value_in_file / Python 3.x: Your assistance is appreciated, thank you! Write a function named average_value_in_file that accepts a file name as a parameter and reads that file, assumed to be full of numbers, and returns the average (mean) of the numbers in that file. The parameter, filename, gives the name of a file that contains a list of numbers, one per line. You may assume that the file exists and follows the proper format. For example, if a file named...
1.1. Write a function named "areFirstTwoTheSame AsLast TwoChars" that accepts a string. It returns true if the first two characters and the last two characters of the string are the same. It returns false otherwise. In addition, if the string is empty or has only one character, it also returns false. For example, these are the strings with their expected return values false falsc "AB" true "ABA" false "ABAB" trus "ABBA" false "ABCABC false "ABCCAB" true 1.2 Write a function...
Write code on best Python style and with appropriate indentation. 1. Given that you have function f that accepts a kwargs argument and does not have a return. You also have a variable d that has been assigned a dictionary. Write a line of code that passes variable d to function f. 2a) Complete the following code to build the states dictionary. The USPresidents.txt file has a number of lines of data, with each line containing two pieces of data:...