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
a uniform density sheet of metal is cut into a shape of an isosceles triangle, which is oriented with the base at the bottom and
Cloud [144]

The horizontal center of mass will be located at the horizontal center of mass will be located on the center line. This is further explained below.

<h3>What is Location?</h3>

Generally, a location or place that is inhabited, open for occupation or distinguished by some distinctive feature: situation The setting of the property contributes significantly to its overall allure.

In conclusion, The center line will serve as the location for the horizontal center of mass, which will be found at the same location as the center line.

Read more about Location

brainly.com/question/11718756

#SPJ1

6 0
2 years ago
1.What is the output of the following program? [10 Marks]namespace ConsoleApp1{class Program{static void Main(string[] args){int
Nataliya [291]

The program outputs the following rectangular array:

0 0 0 0

0 1  2 3

0 2 4 6

0 3 6 9

0 4 8 12

This is the correctly formatted C# program:

namespace ConsoleApp1{

   class Program

   {

       static void Main(string[] args)

       {

           int i, j;    // <em>declare index variables used to iterate over the array A</em>

           int [,] A = new int[5,5];   // <em>create a 5 by 5 array</em>

           

           /*<em> Iterate over the array with the index variables i and j</em>

<em>                and initialize each location A[i, j] with the product </em>

<em>                of i and j.</em> */  

           for (i = 0; i < 5; ++i)

           {

               for (j = 0; j < 4; ++j)

               {

                   A[i, j] = i*j;

               }

           }

           

           /* <em>Iterate over the array again. This time, swap locations </em>

<em>                A[i, j] with A[j, i]</em> */

           for (i = 0; i < 5; ++i)

           {

               for (j = 0; j < 4; ++j)

               {

                   if (i < 5)

                   {

                       A[j, i] = A[i, j];

                   }

                   else

                       break;

                   

                   // <em>display the current location A[i, j]</em>

                   Console.Write(A[i, j] + " ");

                   

               }

               /* <em>print a newline to prepare for the next line of printing</em>

                   <em>which corresponds to the next column i</em> */

               Console.WriteLine();

                // <em>pause and wait for user keypress before continuing</em>

               Console.ReadLine();

               

               }

           }

       }

   }

When executed, this program simply prints a rectangular array like so;

0 0 0 0

0 1  2 3

0 2 4 6

0 3 6 9

0 4 8 12

Learn more about predicting program output here: brainly.com/question/20259194

6 0
2 years ago
which of the following is not a name of one of the central features of Facebook timeline activity log Graph Search for Daily New
Pani-rosa [81]
The correct answer is Graph Search for Daily News

This does not exist on Facebook, unlike the timeline and the activity log.
3 0
3 years ago
❤️❤️❤️❤️❤️❤️❤️❤️IS THERE ANYONE'S STILL AWAKE?? HMM HEHE I'M HERE AGAIN~~~ FOLLOW ME FOR MOR3~~​
insens350 [35]

Answer:

hello?

Explanation:

3 0
2 years ago
Read 2 more answers
[30 points, will mark Brainliest] Which of the following is the lowest hexadecimal value? Explain why. Options to chose; F2, 81,
larisa86 [58]

Answer:

The answer to this question is given below in the explanation section.

Explanation:

First, we need to convert these hexadecimal numbers into decimal numbers, then we can easily identify which one is the lowest hexadecimal.

The hexadecimal numbers are F2, 81, 3C, and 39.

F2 = (F2)₁₆ = (15 × 16¹) + (2 × 16⁰) = (242)₁₀

81 = (81)₁₆ = (8 × 16¹) + (1 × 16⁰) = (129)₁₀

3C = (3C)₁₆ = (3 × 16¹) + (12 × 16⁰) = (60)₁₀

39 = (39)₁₆ = (3 × 16¹) + (9 × 16⁰) = (57)₁₀

The 39 is the lowest hexadecimal number among the given numbers.

Because 39 hex is equal to 57 decimal.

39 = (39)₁₆ = (3 × 16¹) + (9 × 16⁰) = (57)₁₀

5 0
3 years ago
Other questions:
  • Here is a Test Code segment:
    13·1 answer
  • A short-term job or work project that can be paid or unpaid and can lead to a full-time, paying position is called a(n) _____.
    5·2 answers
  • Which ipv6 static route would serve as a backup route to a dynamic route learned through ospf?
    12·1 answer
  • What symbol following a menu command lets you know that a dialog box will be displayed? an arrow a check mark an ellipse a radio
    5·2 answers
  • A model release can be either oral or written down. true or false
    13·2 answers
  • Given a double variable named areaofsquare write the necessary code to read in a value , the area of some square, into areaofsqu
    9·1 answer
  • Design and implement an application that reads a sequence of up to 25 pairs of names and postal (ZIP) codes for individuals. Sto
    9·1 answer
  • Define the missing function. licenseNum is created as: (100000 * customID) licenseYear, where customID is a function parameter.
    12·1 answer
  • How are web design &amp; web development different from each other?
    9·1 answer
  • How does the issue of cybersecurity relate to the internet of things?.
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!