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
Illusion [34]
2 years ago
10

Write a Python program called wdcount.py which uses a dictionary to count the number of occurrences of each word (ignoring case)

in a pure text file encoding UTF-8. Note that the input text file name is given from the command line. To make it simple, you may assume that the file does not contain any punctuation characters. Your program should print each word along with its number of occurrences in descending order. That is the most frequent word should be printed first.
Computers and Technology
1 answer:
Art [367]2 years ago
5 0

The program is an illustration of loops.

<h3>What are loops?</h3>

Loops are program statements used to perform repetition

<h3>The wordcount.py program</h3>

The program written in Python, where comments are used to explain each line is as follows

# This opens the file in read mode

text = open("myFile.txt", "r")

# This creates an empty dictionary

d = dict()

#This iterates through the text

for line in text:

# This splits the line into words, after removing leading & trailing spaces, and newline characters

words = line.strip().lower().split(" ")

# This iterates through all the words

for word in words:

 # The following if condition counts the occurrence of each word

 if word in d:

  d[word] = d[word] + 1

 else:

  d[word] = 1

#This prints the words and their frequencies, in descending order

for w in sorted(d, key=d.get, reverse=True):

   print(w, d[w])

Read more about loops at:

brainly.com/question/16397886

You might be interested in
A dns query failure is referred to a higher level domain name server under what condition
zalisa [80]
Within the Flags detail is a flag titled recursion desired. This flag shows whether or not the local DNS should continue to query other DNSs if it is not able to resolve the current query. As DNS is local, it may or may not have the enough information to allow the address to be resolved. If the recursion flag is set, the local <span>DNS will continue to query higher level DNSs until it is able to resolve the address.  In short, t</span>he condition is when a flag is raised and it doesn’t have enough <span>information to allow the request.</span>
5 0
3 years ago
Read 2 more answers
Design a chip that can complete four bit binary addition, subtraction, and, or operation. Complete the Verilog program and show
marissa [1.9K]

Answer:

How am I supposed to design a chip here?

Explanation:

5 0
3 years ago
Read 2 more answers
A method countDigits(int num) of class Digits returns the remainder when the input argument num(num &gt; 0) is divided by the nu
sertanlavr [38]

Answer:

#include <iostream>

using namespace std;

class Digits

{

   public:

   int num;

   int read()       //method to read num from user

   {

       cout<<"Enter number(>0)\n";

       cin>>num;

       return num;

   }

   int digit_count(int num)  //method to count number of digits of num

   {

       int count=0;

       while(num>0)    //loop till num>0

       {

           num/=10;

           count++;   //counter which counts number of digits

       }

       return count;

   }

   int countDigits(int num)   //method to return remainder

   {

       int c=digit_count(num); //calls method inside method

       return num%c;  

   }

};

int main()

{

   Digits d;    //object of class Digits is created

   int number=d.read();   //num is read from user

   cout<<"\nRemainder is : "<<d.countDigits(number);  //used to find remainder

   return 0;

}

Output :

Enter number(>0)

343

Remainder is : 1

Explanation:

As program is missing to find errors , a logically write program is written to find the remainder when a number is divided by its number of digits. A class  Digits is constructed which has public variable num and methods read(), digit_count(), countDigits().

  • read() - This method reads value of num from the user and return num.
  • digit_count() - This method takes a integer as parameter and counts the number of digits of a number passed as argument. while loop is used to increement the counter until num<0. This returns the value of count.
  • countDigits() - This method takes a integer as a parameter and returns remainder when the argument is divided by number of  digits of argument. Number of digits is calculated by using method digit_count().

At last in main method , object of Digits class is created and its methods are used to find the output.

7 0
3 years ago
An internal _____ refers to a specific representation of an internal model, using the database constructs supported by the chose
boyakko [2]

Answer:

An internal schema                                                            

Explanation:

  • The internal schema refers to the physical storage structure of database.
  • It refers to the lowest level of abstraction.
  • This is also called physical schema.
  • It contains multiple instances of multiple internal records.
  • It provides information about the representation of the whole database that what data is stored in DB and in what form e.g the data is stored in the records form on the disk.
  • This schema gives detailed description of internal model which involves storage structure of the database, representation and classification of stored data. This format of data is only understandable by the Database management system.
7 0
3 years ago
Tax that you pay when making a profit from selling a house is an example of:
spayn [35]
B lol its the only one that makes since all though im not sure if im exactly right 
4 0
2 years ago
Other questions:
  • What is WEB 1.0 to WEB3.0
    11·1 answer
  • Enables businesses and consumers to share data or use software applications directly from a remote server over the Internet or w
    6·1 answer
  • Can you call a mobile a computer. It Yes<br>why? If No why​
    7·2 answers
  • What is a computer system?
    9·1 answer
  • Does anyone know a good reason WHY to change your username.
    5·1 answer
  • Where can I learn how you hack?​
    8·2 answers
  • How do I write a pseudocode algorithm to read a sequence of number terminated by the number 999 and print the sum of the positiv
    7·1 answer
  • 1. What is the Internet?
    8·2 answers
  • How is technology moving the business world forward?
    13·1 answer
  • python. create a program that asks the user to input their first name and their favorite number. Then the program should output
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!