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
bogdanovich [222]
3 years ago
15

8.17 Lab: Strings of a Frequency Write a program that reads whitespace delimited strings (words) and an integer (freq). Then, th

e program outputs the strings from words that have a frequency equal to freq in a case insensitive manner.
Computers and Technology
1 answer:
gavmur [86]3 years ago
5 0

Answer:

def occurencesOfWords(words,freq):

  frequency_dictionary={}

  matched_frequency_words=[]

  for i in range(len(words)):

      counter=1

      a=words[i].lower()

      for j in range(len(words)):

          if(i==j):

              continue

          b=words[j].lower()

          if(a==b):

              counter+=1

      frequency_dictionary[words[i]]=counter

  for key in frequency_dictionary:

      if(frequency_dictionary[key]==freq):

          matched_frequency_words.append(key)

  return matched_frequency_words

if __name__=='__main__':

  user_input=input()

  freq=int(input())

  words=user_input.split(" ");

  required_words=occurencesOfWords(words,freq)

  for s in required_words:

      print(s)

Explanation:

  • Inside the occurencesOfWords function, initialize a frequency_dictionary that is used to store the string and the frequency of that specific string .
  • matched_frequency_words is an array that is used to store each string whose frequency matches with the provided frequency
  • Run a nested for loop up to the length of words and inside the nested for loop, skip the iteration if both variables i and j are equal as both strings are at same index.
  • Increment the counter variable, if two string are equal.
  • Loop through the frequency_dictionary to get the matching frequency strings .
  • Finally test the program inside the main function.
You might be interested in
Which program will have the output shown below?
Nutka1998 [239]

Answer: Python

Explanation: All I know is that the programming language is Python.

8 0
3 years ago
Read 2 more answers
In critical thinking, an argument is:
djverab [1.8K]
C... it’s c ok.......................
6 0
3 years ago
Read 2 more answers
Write a program in Java programming language that given two clock times prints out the absolute number of minutes between them
Triss [41]

Answer:

// Java Program to Find the difference

// between Two Time Periods

// Importing the Date Class from the util package

import java.util.*;

// Importing the SimpleDateFormat

// Class from the text package

import java.text.*;

public class GFG {

public static void main(String[] args) throws Exception

{

 // Dates to be parsed

 String time1 = "18:00:00";

 String time2 = "7:30:50";

 // Creating a SimpleDateFormat object

 // to parse time in the format HH:MM:SS

 SimpleDateFormat simpleDateFormat

  = new SimpleDateFormat("HH:mm:ss");

 // Parsing the Time Period

 Date date1 = simpleDateFormat.parse(time1);

 Date date2 = simpleDateFormat.parse(time2);

 // Calculating the difference in milliseconds

 long differenceInMilliSeconds

  = Math.abs(date2.getTime() - date1.getTime());

 // Calculating the difference in Hours

 long differenceInHours

  = (differenceInMilliSeconds / (60 * 60 * 1000))

  % 24;

 // Calculating the difference in Minutes

 long differenceInMinutes

  = (differenceInMilliSeconds / (60 * 1000)) % 60;

 // Calculating the difference in Seconds

 long differenceInSeconds

  = (differenceInMilliSeconds / 1000) % 60;

 // Printing the answer

 System.out.println(

  "Difference is " + differenceInHours + " hours "

  + differenceInMinutes + " minutes "

  + differenceInSeconds + " Seconds. ");

}

}

7 0
2 years ago
A small business named Widgets, Inc. has hired you to evaluate their wireless network security practices. As you analyze their f
solmaris [256]

Answer:

disable SSID broadcast and change the network name

Explanation:

Based on my experience with information technology and wireless networks my recommendation would be to disable SSID broadcast and change the network name. Disabling SSID will prevent the network name from appearing on devices that are searching for a network to connect to, and by changing the name it will also prevent anyone who knows the previous name from connecting unless they know the new name. Both of which will drastically increase security.

8 0
3 years ago
Re-write the below program correcting the bugs
motikmotik

Answer:

??????????????????????????

5 0
3 years ago
Other questions:
  • To include totals and other statistics at the bottom of a datasheet, click the ____ button on the HOME tab to include the Total
    12·1 answer
  • Your isp connects to the core routers of the internet via a _____. cable mode spine backbone satellite
    12·1 answer
  • Which task manager tab provides details about how a program uses system resources?
    14·1 answer
  • Your sister wants to purchase Microsoft Office 2013 for her new laptop. She doesn't want to pay for a subscription, and she want
    12·1 answer
  • Mirrors on cars exist to____.
    7·2 answers
  • Terminal emulation, especially the unprotected ____________________ protocol, should be blocked from any access to all internal
    9·1 answer
  • You have purchased a printer that has the capability to print in duplex mode so that users can print on both sides of a sheet of
    7·1 answer
  • Which 1947 Invention paved the way for the Digital Revolution?
    12·2 answers
  • Jjhb ft fv tuning Denise l Debbie
    9·1 answer
  • How do I add a Child to my Brainly account
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!