answer.
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
BaLLatris
2 months ago
6

A file concordance tracks the unique words in a file and their frequencies. Write a program that displays a concordance for a fi

le. The program should output the unique words and their frequencies in alphabetical order. Variations are to track sequences of two words and their frequencies, or n words and their frequencies. Below is an example file along with the program input and output: example.txt
Computers and Technology
1 answer:
oksian1 [950]2 months ago
3 0

Answer:

Below is the Python code with suitable comments.

Explanation:

#Input file name acquisition

filename=input('Enter the input file name: ')

#Opening the input file

inputFile = open(filename,"r+")

#Dictionary definition.

list={}

#Read and split file content using a loop

for word in inputFile.read().split():

#Check if the word exists in the file.

if word not in list:

list[word] = 1

#Increment count by 1

else:

list[word] += 1

#Closing the file.

inputFile.close();

#Output a blank line

print();

#Sorting words according to their ASCII values.

for i in sorted(list):

#Display unique words along with their

#frequencies in alphabetical order.

print("{0} {1} ".format(i, list[i]));

You might be interested in
Cloud Kicks is undergoing a GDPR-focused implementation to ensure access to personal information data is limited to only users w
Rzqust [1037]

Response:

Option A.

Clarification:

The organization is executing a GDPR-focused strategy to ensure that access to sensitive data is limited to only those users who genuinely need full rights to a corporate account. It utilizes a personalized account structure.

Thus, the Consultant provides specific Account permissions to the Renewals and Sales Operations teams, enabling them to establish roles for the Renewals and Sales Account teams, with sales team members matched to the respective customers.

5 0
1 month ago
Describe a strategy for avoiding nested conditionals. Give your own example of a nested conditional that can be modified to beco
maria [1035]

Answer:

To prevent nested conditionals, one can utilize logical expressions like the AND operator.

A recommended approach is creating an interface class with a method designed for a shared function. This design approach is known as the strategy design pattern. The conditional statements can be consolidated into this method. Subsequently, each class can implement this interface and invoke that shared method as needed by constructing instances of subclasses and calling the common method for those objects. This illustrates polymorphism.

Explanation:

Nested conditionals occur when if or else if statements are placed within another condition. For instance:

if( condition1) {

//runs when condition1 is true

  if(condition2) {

//runs when both condition1 and condition2 are true

  }  else if(condition3) {

 //when condition1 is true and condition3 is also true

} else {

 //condition1 is true but neither condition2 nor conditions3 are satisfied

}  }

Excessive nested conditionals can complicate the program, rendering it hard to read or comprehend, particularly if there's improper indentation. Debugging also becomes challenging when there are numerous nested statements.

Thus, several strategies can be adopted to eliminate nested conditionals, such as utilizing a switch statement.

For instance, I’ll present an example of the strategies discussed earlier:

Logical Expressions Usage:

A method to avoid nested conditionals is by employing logical expressions with logical operators like the AND operator. The previous nested conditionals can be reframed as:

if(condition1 && condition2){ //only runs when both condition1 and condition2 are true

} else if(condition1 && condition3) {

executes only if both condition1 and condition3 are true

} else if(condition1 ){

//condition1 is satisfied but neither condtion2 nor condtion3 are true  }

This can be further simplified to one condition as:

if(!condition3){

// when  condition1 and condition2 are both satisfied

}

else

// condition3 is met

Now, consider a simple instance dealing with whether to attend school based on certain conditions.

if (temperature< 40)

{

   if (busArrived=="yes")

   {

       if (!sick)

       {

           if (homework=="done")

           {

               printf("Go to school.");

           }

       }                    

   }

}

Here, nested conditionals are evident. This can be restructured into a solitary conditional using the AND logical operator.

if ((temperature <40) && (busArrived=="yes") &&

(!sick) && (homework=="done"))

{    cout<<"Eligible for promotion."; }

The alternate method is utilizing an interface. For example, you can

abstract class Shape{

//declare a method common to all sub classes

  abstract public int area();

// same method that varies by formula of area for different shapes

}

class Triangle extends Shape{

  public int area() {

     // implementation of area code for Triangle

return (width * height / 2);

  }

}

class Rectangle extends Shape{

  public int area() {

     // implementation of area code for Rectangle

    return (width * height)

  }

}

Now, you can readily create Rectangle or Triangle instances and invoke area() for any of those objects, resulting in execution of the appropriate version accordingly.

4 0
2 months ago
To be a successful computer systems engineer, you must be proficient in programming languages and operating systems. Similarly,
maria [1035]

In summary, the skills listed are referred to as Technical capabilities. These capabilities encompass the Knowledge and skillset required to execute specific tasks. Meanwhile, Soft skills are equally vital, as they pertain to the capability of effectively engaging and communicating with others.

6 0
1 month ago
Read 2 more answers
Which of the following is an absolute cell reference
Amiraneli [1052]
The term for the contents of the cell is an absolute cell reference. Excel allows each cell to contain numbers, strings, or formulas. Users can enter values into a cell and apply built-in formulas to perform calculations and obtain results in the target cell. When users attempt to copy and paste data into another cell, they can use the paste special option to select values, meaning that only the data is copied, excluding the formula; this is known as the absolute reference of the cell. With paste special, users can also replicate images or Unicode.
6 0
2 months ago
An employee of a large corporation remotely logs into the company using the appropriate username and password. The employee is a
Natasha_Volkova [1026]

Respuesta: Te proporcioné 6 opciones de las cuales puedes elegir.

Integridad

Escalabilidad

Calidad de Servicio

Tolerancia a Fallos

Redes de Línea Eléctrica

Seguridad

6 0
2 months ago
Other questions:
  • Why were the practitioners of alternative software development methods not satisfied with the traditional waterfall method?
    9·1 answer
  • To what extent are the following computer systems instances of artificial intelligence:
    14·1 answer
  • An author is preparing to send their book to a publisher as an email attachment. The file on their computer is 1000 bytes. When
    6·1 answer
  • You are a police officer trying to crack a case. You want to check whether an important file is in the evidence room. Files have
    5·2 answers
  • Write measurable performance objectives.Suppose that a trainer has identified as a generalgoal for a training module,"Able to fo
    13·1 answer
  • The principal that users have access to only network resources when an administrator explicitly grants them is called __________
    6·1 answer
  • Identify the correct XHTML syntax for inserting an image as a hyperlink from the options provided. A. book.gif B. C. D.
    9·1 answer
  • The dealer's cost of a car is 85% of the listed price. The dealer would accept any offer that is at least $500 over the dealer's
    7·1 answer
  • Chris accidentally steps on another student’s foot in the hallway. He apologizes, but the other student does not want to hear it
    13·2 answers
  • This assignment is based on Exercise 8.4 from your textbook. Each of the following Python functions is supposed to check whether
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!