Question: 1. Write a function countletters(s) that takes as input then counts and returns the letter occurrences in the string S, the counter is case insensitive,
1. Write a function countletters(s) that takes as input then counts and returns the letter occurrences in the string S, the counter is case insensitive, A equals a. Example >>> countletter("Welcome Python') {W: 1, 'e': 2, T: 1, 'c': 1, 'c': 2, 'm': 1, "p': 1, y: 1, 't': 1, h': 1, 'n': 1} 2. Write a function letter_counter(s) that takes a string as a parameter that counts the frequency of vowels and consonant letters. It should return a dictionary with two keys only "vowel" and "cons" with the corresponding count as a value. Note: vowels are "a,e,i,o,u" >>> letter_counter("Nice idea') {"cons': 3, 'vowel": 5) >>>letter_counter(") {"vowel': 0, "cons': 0 3. Write a function intersect(D1, D2) that takes 2 dictionaries and returns a list of common keys that appear in both D1 and D2. Example Call to Function: >>>D1 = {1:'a', 2:'b', 3:'c') >>>D2 = {2:x', 1:'y', 4:"2"} >>> intersect(D1, D2) [1,2] 4. write a function insert(d,k,v) that takes a dictionary, a key, and a value, and inserts the key value pair in the dictionary. >>>d=dict() >>>d('one')-1 >>>insert(d, 'one',2) ('one': [1, 2]]
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
