1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Zielflug [23.3K]
3 years ago
13

Write a program that reads whitespace delimited strings (words) and an integer (freq). Then, the program outputs the strings fro

m words that have a frequency equal to freq in a case insensitive manner. Your specific task is to write a function words Frequency(words, freq), which will return a list of strings (in the order in which they appear in the original list) that have a frequency same as the function parameter freq. The parameter words to the function words Frequency(words, freq) should be a list data structure. If two strings in the list words contain the same sequence of characters but are different case, they are considered the same. For example, we will consider the strings UCONN and uconn to be the same.
Computers and Technology
1 answer:
Lesechka [4]3 years ago
3 0

Answer:

See explaination for the code

Explanation:

def wordsOfFrequency(words, freq):

d = {}

res = []

for i in range(len(words)):

if(words[i].lower() in d):

d[words[i].lower()] = d[words[i].lower()] + 1

else:

d[words[i].lower()] = 1

for word in words:

if d[word.lower()]==freq:

res.append(word)

return res

Note:

First a dictionary is created to keep the count of the lowercase form of each word.

Then, using another for loop, each word count is matched with the freq, if it matches, the word is appended to the result list res.

Finally the res list is appended.

You might be interested in
The primary key is a field that uniquely and completely identifies a record.
Leokris [45]
True

----------------------------------
6 0
3 years ago
Read 2 more answers
. Write a function called is_sorted that takes a list as a parameter and returns True if the list is sorted in ascending order a
aalyn [17]

Answer:

There are multiple ways to solve the given problem, I will be presenting the most simple and easy way of solving this problem in few lines of code.

Python code:

def is_sorted(user_list):

   return user_list == sorted(user_list)

user_list=input("Please enter a list: ")

user_list = user_list.split()

print(is_sorted(user_list))

print("Your list: ", user_list)

Explanation:

A function is_sorted is created which takes a list as input and using the sorted() function of python which returns true when the list is sorted in ascending order and returns false when the list is not sorted in ascending order.

Driver code includes getting input list from the user and using split() function to create a list separated by space then printing the output of is_sorted function and in the last printing the contents of that list.

Output:

Please enter a list: 1 3 6 9

True

Your list:  ['1', '3', '6', '9']

Please enter a list: 15 7  2 20

False

Your list:  ['15', '7', '2', '20']

8 0
3 years ago
DO NOT ANSWER FOR JUST POINTS
Elza [17]

Answer:

E.

a medium dashed line

Explanation:

I always use medium hehe so I think that'll work.

5 0
2 years ago
Read 2 more answers
Think about a career you would like to have 10 years from now.
WITCHER [35]

Answer: Scientist

Explanation: Scientists use technology to record data, as well as using technology to study different things, for example scientists use computers to track DNA.

6 0
2 years ago
Function of an actuator
RSB [31]

Answer:

an actuator is a device that uses a form of power to convert a control signal into mechanical motion

6 0
3 years ago
Read 2 more answers
Other questions:
  • A ________ is a system of hardware and software that stores user data in many different geographical locations and makes that da
    14·1 answer
  • 2. Statement: "I don't agree with you." Nonverbal gesture: Type of gesture:
    6·1 answer
  • Your health insurance company gives you a discount if you wear a fitness-tracking bracelet. After wearing it for a few months, y
    5·1 answer
  • ABC software company is to develop software for effective counseling for allotment of engineering seats for students with high s
    13·1 answer
  • Consider a binary-search method in an array that reports whether an object is in the array. The documentation indicates that the
    11·1 answer
  • Does white space have visual weight? Yes or No
    7·2 answers
  • Write a C++ program to count even and odd numbers in array. The array size is 50. The array elements will be entered by the user
    13·1 answer
  • Pls help! for computers edge 2021
    7·1 answer
  • 8.6 Code Practice: Question 2
    7·1 answer
  • Lab 8-1: Working with Boot Loader and Runlevels what is the root password
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!