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
1 month 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 [797]1 month 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
Write a program that allows the user to navigate the lines of text in a file. The program should prompt the user for a filename
amid [800]

This code is in Python. I'm not certain what programming language you need.

Refer to the image:

7 0
1 month ago
Read 2 more answers
The video clip on driverless cars explained that brain signals from the individual wearing the headset are converted by computer
zubka84 [942]

There is a safety concern if the vehicle experiences a malfunction or encounters a red light or police; just operate your own vehicle instead.

5 0
1 month ago
Read 2 more answers
On a typical microprocessor, a distinct I/O address is used to refer to the I/O data registers and a distinct address for the co
maria [879]

Answer:

First I/O instruction format -> 256 ports

Second I/O instruction format -> 65536 ports

Explanation:

  • The initial instruction format can address 256 ports, computed from eight bits for port addressing as 2^8 = 256 ports.
  • The second instruction format allows for 65536 ports, which can be calculated using sixteen bits for addressing as 2^16 = 65536 ports.

Changing the opcode facilitates the selection between the first and second instruction format, allowing one input or output operation at a given moment.

5 0
25 days ago
Write an application that throws and catches an ArithmeticException when you attempt to take the square root of a negative value
Harlamova29_29 [932]

The code relevant to the problem in question:

import java.util.Scanner;

public class Test {

   public static void main(String[] args) {

       double number;

       double squareRootOfNumber;

       String userInput = null;

       Scanner scanner = new Scanner(System.in);

       System.out.println("Please enter a number: ");

       userInput = scanner.next();

       number = Double.parseDouble(userInput);

       squareRootOfNumber = Math.sqrt(number);

       if (number < 0) {

           throw new ArithmeticException("Cannot compute the square root of a negative number");

       }

       System.out.format("The square root of the entered number is %.2f %n", squareRootOfNumber);

   }

}

The program will output:

Please enter a number:

-90

Exception in thread "main" java.lang.ArithmeticException: Cannot compute the square root of a negative number at com..ans.Test.main(Test.java:18)

Explanation:

The standard Java library function java.lang.Math.sqrt does not throw an ArithmeticException for negative arguments, hence there’s no need to enclose your code in a try/catch block.

Instead, we manually trigger ArithmeticException using the throw keyword:

throw new ArithmeticException("Cannot compute the square root of a negative number");

3 0
1 month ago
OCR Land is a theme park aimed at children and adults. Entrance tickets are sold online. An adult ticket to OCR Land costs £19.9
Rzqust [894]

Answer:

count = 0

while count!= 8:

height = float(input("Enter the height of the rider: "))

if height >= 140:

print("You may ride")

count += 1

else:

if height >= 120:

answer = input("Is the rider accompanied by an adult (yes/no): ")

if answer == "yes":

print("You may ride")

count += 1

else:

print("You are not permitted to ride")

else:

print("You are not permitted to ride")

Explanation:

Begin with a count of zero, which will track the number of riders allowed. Use a while loop that continues until the count reaches 8. During each iteration, request the user's height. If the height is 140 cm or taller, display "You may ride" and increment the count. If the height is 120 cm or more, check if the rider is with an adult. If not, show the message "You are not permitted to ride"; otherwise, allow the ride and increase the count. If the height is below 120 cm, deny the ride.

5 0
29 days ago
Other questions:
  • Why is computer called versatile machine?
    7·1 answer
  • Two middle-order batsmen are compared based on their performance in their previous cricket match.
    7·1 answer
  • Some early computers protected the operating system by placing it in a memory partition that could not be modified by either the
    5·1 answer
  • Marien is using the Council of Science Editors (CSE) style guidelines to write her research paper. What is her most likely topic
    13·1 answer
  • Form the recurrence relations (RRs) for the number of vertices and the number of edges of a hypercube of n dimensions, Hn. Solve
    13·1 answer
  • How has the development of personal computer hardware and software reversed some of the trends brought on by the industrial revo
    15·1 answer
  • Widget Corp. wants to shift its list of inventory to a cloud so that its different branches can access it easily. The company ne
    7·1 answer
  • Write a loop to populate the list user_guesses with a number of guesses. The variable num_guesses is the number of guesses the u
    13·1 answer
  • When adopting and implementing a Software as a Service (SaaS) platform such as Salesforce for your business, which responsibilit
    7·1 answer
  • A wireless network was recently installed in a coffee shop and customer mobile devices are not receiving network configuration i
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!