Write a python program that will find the longest word in a file. The program should print the word and the number of characters in that word. Hint you would be using dictionaries, string module, and files for this exercise.

Answers

Answer 1

Answer:

Explanation:

The following code is written in Python. It is a function that takes in the file location as a parameter and reads it. It then splits the text into a list and loops through the list. The length of every element is compared to the value in the variable length and if it is larger it saves that words length to the variable length and saves the word to the variable longestWord. These variables get printed at the end of the program. A test case has been provided and can be seen in the image below.

import re

def longestWordInFile(file):

   file = open(file, 'r')

   text = file.read()

   wordList = text.lower()

   wordList = re.split('\s', wordList)

   length = 0

   longestWord = ''

   for word in wordList:

       if len(word) > length:

           length = len(word)

           longestWord = word

   print(longestWord + " is the longest with " + str(length) + " characters.")


Related Questions

Code Example 17-1 class PayCalculator { private: int wages; public: PayCalculator& calculate_wages(double hours, double wages) { this->wages = hours * wages; return *this; } double get_wages() { return wages; } }; (Refer to Code Example 17-1.) What coding technique is illustrated by the following code? PayCalculator calc; double pay = calc.calculate_wages(40, 20.5).get_wages(); a. self-referencing b. function chaining c. dereferencing d. class chaining

Answers

Answer:

The answer is "Option b".

Explanation:

Function chaining is shown by this code, as the functions are called one after the other with one statement. Whenever you want to call a series of methods through an object, that technique is beneficial. Just because of that, you may give the same effect with less code and have a single given value only at top of the leash of operations.

How should you mark the query if it is a valid one?
A) Gibberish or Vague
B) Profane
C) Foreign Language
D) Valid
E) None

Answers

Answer:

None

HOPE IT WILL HELP YOU.

MARK THE ANSWER BRAINLIST

how do you get The special and extended ending in final fight 2 snes

Answers

Yes what that person above said!

Microsoft created Adobe Photoshop? TRUE FALSE​

Answers

Answer:

false the creator of adobe photoshop was microsoft adobe photoshop is a popular photo editing software which was developed by a company named as adobe inc.

Answer:

Photoshop is created by Adobe, and Adobe is an independent company started by Jhon Warnockand.

i need an introduction of apple and microsoft

Answers

During the first Macintosh's development and early years of production, Microsoft was a critical Apple ally. The software pioneer created important programs for Apple's PC in the early '80s. ... Jobs lashed out at Gates during a meeting later that same year and equated Microsoft's plans for Windows to theft.

write a program that keeps taking integers until the user enters in python

Answers

int main {

//variables

unsigned long num = 0;

std::string phrase = " Please enter your name for confirmation: " ;

std::string name;

//codes

std::cout << phrase;

std::cin>> name;

while ( serial.available() == 0 ) {

num++;

};

if ( serial.avaliable() > 0 ) {

std::cout << " Thank you for your confirmation ";

};

};

Which of the following are examples of third party software that banks use? (Select all that apply.)
A -compliance reporting
B -unencrypted Microsoft Suite
C -accounting software
D -customer relationship management

Answers

Answer:

c , it is a correct answer for the question

Highlight and detail two ways that you can use Excel to make you more efficient as a college student.
You can consider such things as study schedules, school supply lists, or grade books (among many other options), but make sure to describe each in a way that is personal to your academics.

Answers

Answer:

Technological advances can create enormous economic and other benefits, but can also lead to significant changes for workers. IT and automation can change the way work is conducted, by augmenting or replacing workers in specific tasks. This can shift the demand for some types of human labor, eliminating some jobs and creating new ones.

Explanation:

10. Question
What are the drawbacks of purchasing something online? Check all that apply.

Answers

Explanation:

1) the quality of purchased good may be low

2) there might me fraud and cheaters

3) it might be risky

4) we may not get our orders on time

There are many drawbacks of purchasing online, some of them are as follows,

Chance of pirated item in place of genuine product.Chances of fraud during digital purchase and transaction.Product not deliver on time as expected.Not getting chance to feel the product before purchase.

These are some of the drawbacks of purchasing something online.

Learn more: https://brainly.com/question/24504878

which technique is the best to help you manage time better ​

Answers

Answer:

Make a schedule and select certain times to do certain things so that you could have time for more things.

Explanation:

I did the same thing now I can make time for myself.

Explain how data structures and algorithms
are useful to the use of computers in
data management (10 marks)


Explain how data structure and uses of computer in data management

Answers

Answer:

Data management is a important tool for data handling.

Explanation:

A good knowledge about the data stricture and data management is a prerequisite for working with codes and algorithms. It helps to identify the techniques for designing the algorithms and data storage in the system. It helps to find out the data hierarchy. Thereby allowing the data management in an efficient and effective way. It can increase the skills in computer programming

2. Which property is used for hiding text of the textbox?
a) Password Char b) Text Char c) Char Password d) Pass Char

Answers

Answer:

password char

Explanation:

The password char property allows the text being written in the textbox to be hidden in the form of dots or stars. As such the user entering the password is secure, as no one nearby can know the password by watching the texts.

what is tha length of Mac address ?​

Answers

Answer:

short length which includes all details about the addres

why am i doing the investigation​

Answers

Because it’s your interest

3. A 3D model of a designed product would be used to communicate the

Answers

Answer:

A 55

Explanation:

A 3D model of a designed product would be used to communicate the photorealistic renditions of the product.

What is 3D?

It should be noted that 3D modeling is the process if developing a coordinate representation of an object.

In this case, a 3D model of a designed product would be used to communicate the photorealistic renditions of the product.

Learn more about 3D on:

brainly.com/question/26350554

#SPJ2

Write a program that creates an an array large enough to hold 200 test scores between 55 and 99. Use a Random Number to populate the array.Then do the following:1) Sort scores in ascending order.2) List your scores in rows of ten(10) values.3) Calculate the Mean for the distribution.4) Calculate the Variance for the distribution.5) Calculate the Median for the distribution.

Answers

Answer:

Explanation:

The following code is written in Python. It uses the numpy import to calculate all of the necessary values as requested in the question and the random import to generate random test scores. Once the array is populated using a for loop with random integers, the array is sorted and the Mean, Variance, and Median are calculated. Finally The sorted array is printed along with all the calculations. The program has been tested and the output can be seen below.

from random import randint

import numpy as np

test_scores = []

for x in range(200):

   test_scores.append(randint(55, 99))

sorted_test_scores = sorted(test_scores)

count = 0

print("Scores in Rows of 10: ", end="\n")

for score in sorted_test_scores:

   if count < 10:

       print(str(score), end= " ")

       count += 1

   else:

       print('\n' + str(score), end= " ")

       count = 1

mean = np.mean(sorted_test_scores)

variance = np.var(sorted_test_scores, dtype = np.float64)

median = np.median(sorted_test_scores)

print("\n")

print("Mean: " + str(mean), end="\n")

print("Variance: " + str(variance), end="\n")

print("Median: " + str(median), end="\n")

Create union floatingPoint with members float f, double d and long double x. Write a program that inputs values of type float, double and long double and stores the values in union variables of type union floatingPoint. Each union variable should be printed as a float, a double and a long double. Do the values always print correcly? Note The long double result will vary depending on the system (Windows, Linux, MAC) you use. So do not be concern if you are not getting the correct answer. Input must be same for all cases for comparison Enter data for type float:234.567 Breakdown of the element in the union float 234.567001 double 0.00000O long double 0.G0OO00 Breaklo n 1n heX float e000000O double 436a9127 long double 22fde0 Enter data for type double :234.567 Breakdown of the element in the union float -788598326743269380.00OGOO double 234.567000 long double 0.G00000 Breakolon 1n heX float 0 double dd2f1aa0 long double 22fde0 Enter data for type long double:

Answers

Answer:

Here the code is given as follows,

#include <stdio.h>

#include <stdlib.h>

union floatingPoint {

float floatNum;

double doubleNum;

long double longDoubleNum;

};

int main() {

union floatingPoint f;

printf("Enter data for type float: ");

scanf("%f", &f.floatNum);

printf("\nfloat %f ", f.floatNum);

printf("\ndouble %f ", f.doubleNum);

printf("\nlong double %Lf ", f.longDoubleNum);

printf("\n\nBreakdown in Hex");

printf("\nfloat in hex %x ", f.floatNum);

printf("\ndouble in hex %x ", f.doubleNum);

printf("\nlong double in hex %Lx ", f.longDoubleNum);

printf("\n\nEnter data for type double: ");

scanf("%lf", &f.doubleNum);

printf("float %f ", f.floatNum);

printf("\ndouble %f ", f.doubleNum);

printf("\nlong double %Lf ", f.longDoubleNum);

printf("\n\nBreakdown in Hex");

printf("\nfloat in hex %x ", f.floatNum);

printf("\ndouble in hex %x ", f.doubleNum);

printf("\nlong double in hex %Lx ", f.longDoubleNum);

printf("\n\nEnter data for type long double: ");

scanf("%Lf", &f.longDoubleNum);

printf("float %f ", f.floatNum);

printf("\ndouble %f ", f.doubleNum);

printf("\nlong double %Lf ", f.longDoubleNum);

printf("\n\nBreakdown in Hex");

printf("\nfloat in hex %x ", f.floatNum);

printf("\ndouble in hex %x ", f.doubleNum);

printf("\nlong double in hex %Lx ", f.longDoubleNum);

return 0;

}

Which of the following acronyms refers to a network or host based monitoring system designed to automatically alert administrators of known or suspected unauthorized activity?
A. IDS
B. AES
C. TPM
D. EFS

Answers

Answer:

Option A (IDS) is the correct choice.

Explanation:

Whenever questionable or unusual behavior seems to be detected, another alarm is sent out by network security equipment, which would be considered as Intrusion Detection System.SOC analysts as well as occurrence responders can address the nature but instead, develop a plan or take steps that are necessary to resolve it predicated on such notifications.

All other three alternatives are not related to the given query. So the above option is correct.

Create a Python dictionary that returns a list of values for each key. The key can be whatever type you want.

Design the dictionary so that it could be useful for something meaningful to you. Create at least three different items in it. Invent the dictionary yourself. Do not copy the design or items from some other source.

Next consider the invert_dict function.

def invert_dict(d):
inverse = dict()
for key in d:
val = d[key]
if val not in inverse:
inverse[val] = [key]
else:
inverse[val].append(key)
return inverse

Modify this function so that it can invert your dictionary. In particular, the function will need to turn each of the list items into separate keys in the inverted dictionary.
Run your modified invert_dict function on your dictionary. Print the original dictionary and the inverted one.
Describe what is useful about your dictionary. Then describe whether the inverted dictionary is useful or meaningful, and why.

Answers

Answer:

Explanation:

# name : [animal type, age, sex]

animal_shellter = {

 "Teddy": ["dog",4,"male"],

 "Elvis": ["dog",1,"male"],

 "Sheyla": ["dog",5,"female"],

 "Topic": ["hamster",3,"male"],

 "Kuzya": ["cat",10,"male"],

 "Misi": ["cat",8,"female"],

}

print(animal_shellter)

print("")

def invert(d):

 inverse = dict()

 for key in d:

   val = d[key]

   for item in val:

     if item not in inverse:

       inverse[item] = [key]

     else:

       inverse[item].append(key)

 return inverse  

inverted_shellter = invert(animal_shellter)

print(inverted_shellter)

Consider a short, 90-meter link, over which a sender can transmit at a rate of 420 bits/sec in both directions. Suppose that packets containing data are 320,000 bits long, and packets containing only control (e.g. ACK or handshaking) are 240 bits long. Assume that N parallel connections each get 1/ N of the link bandwidth. Now consider the HTTP protocol, and assume that each downloaded object is 300 Kbit long, and the initial downloaded object contains 6 referenced objects from the same sender.

Required:
Would parallel download via parallel instances of non-persistent HTTP make sense in this case? Now consider persistent HTTP. Doyou expect significant gains over the non-persistent case?

Answers

Please send pics and than I sent you lol I wanna wanna play with you lol but I’m gonna play play with this girl and play with me ur mommy mommy play good day bye mommy bye love.

College
START: what new information, strategies, or techniques have you learned that will increase your technology skills? Explain why its important to START doing this right away

Answers

Answer:

Read Technical Books. To improve your technical skills and knowledge, it's best to read technical books and journals. ...

Browse Online Tutorials. ...

Build-up online profile. ...

Learn new Tools. ...

Implement what you learned. ...

Enrich your skillset. ...

Try-out and Apply.

Mario is giving an informative presentation about methods for analyzing big datasets. He starts with the very basics, like what a big dataset is and why researchers would want to analyze them. The problem is that his audience consists primarily of researchers who have worked with big data before, so this information isn’t useful to them. Which key issue mentioned in the textbook did Mario fail to consider?

Answers

Answer:

Audience knowledge level

Explanation:

The Key issue that Mario failed to consider when preparing for her presentation is known as Audience knowledge level.  

Because Audience knowledge level comprises educating your audience with extensive information about the topic been presented. she actually tried in doing this but she was educating/presenting to the wrong audience ( People who are more knowledgeable than her on the topic ). she should have considered presenting a topic slightly different in order to motivate the audience.

1. Which Property is used for changing the background color of any control
a) Font color b) Back color c) Text color d) color back

Answers

'Back Color' is characterized as the CSS property that is employed to modify or alter the background color belonging to any element of control.

B). 'Back Color' is the property that is used for altering the background color.

However, it excludes the margin area of the element and includes the entire size of the element along with the filler. One can select the color of his/her choice in order to promote the readability of the text by contrasting the background color to the text color. Thus, option B is the correct answer.

Learn more about 'CSS properties' here:

brainly.com/question/2671236

You are the IT administrator for a small corporate network. You have recently experienced some problems with devices on the workstation in the Support Office. In this lab, your task is use Device Manager to complete the following:______.
The new network card you installed isn't working as expected (speed is only 1 Mbps). Until you can figure out what the problem is, disable the Broadcom network adapter and enable the Realtek network adapter. To make sure the network adapter has the latest drivers, update the driver for the Realtek network adapter by searching Microsoft Update. You recently updated the driver for your video card. However, the system experiences periodic crashes that you suspect are caused by the new driver. Roll back the driver to a previous version. Move the Ethernet cable to the integrated network port on the motherboard.

Answers

Answer:

I will fix it by my mind by thinking

Based on the above scenario, the steps to take is given below\

What is the management about?

The first thing is to Right-click Start and click on Device Manager and then you expand Network adapters.

Later you Disable the network adapter  and then Update the driver .

Learn more about Ethernet from

https://brainly.com/question/1637942

#SPJ2

1. Open the start file EX2019-ChallengeYourself-9-3. The file will be renamed automatically to include your name. Change the project file name if directed to do so by your instructor, and save it.
2. If the workbook opens in Protected View, click the Enable Editing button in the Message Bar at the top of the workbook so you can modify the workbook.
3. Use Consolidate to create a summary of real estate sales for all property types. Place the consolidated data on the Summary worksheet in cells B3: C15. Use the Average function to consolidate the data from cells B2: C14 in the Condo, Townhouse, and Single Family worksheets. Include links to the source data.
4. Import individual sales data from the tab-delimited text file Select Sales Data 2019-2020. Import the data as a table in cell A1 of the Select Sales worksheet.
5. Remove the data connection when the import is complete.
6. In the Select Sales worksheet, add data validation to restrict values in the House Type columns (cells B2: B139) to the values in the cell range named PropertyTypes. Include a drop-down list of values in the cells to assist in data correction.
7. Add the following input message to cells B2:B139: Select a property type from the list.
8. Add the following error alert to cells B2:B139: Not a valid property type.
9. Apply data validation circles to any values that violate the data validation rules you just created.
10. Add a comment to cell B1 in the Select Sales worksheet that reads: This needs to be fixed.
11. Add a hyperlink from cell B1 in the Select Sales worksheet to link to the named range (defined name) PropertyTypes. Test the link.
12. Use Flash Fill to add a new column of data to the Select Sales worksheet to display the number of bedrooms/the number of bathrooms.
a. In the Select Sales worksheet, cell F1, type the heading: BR/BA
b. Complete the column of data using this pattern in cell F2: 1 BR/1 BA
You will need to enter at least two samples in order for Flash Fill to suggest the correct autofill data. Check your work carefully.
Sales Summary 2019-2020
Number of Sales Average Selling Price
1
2
3 One BR, One BA
4 One BR, Two BA +
5 Two BR, One BA
6 Two BR, Two BA
7 Two BR, Two BA +
8 Three BR, One BA
9 Three BR, Two BA
10 Three BR, Three BA +
11 Four BR, One BA
12 Four BR, Two BA
13 Four BR, Three BA+
14 Five BR-. One BA
15 Five BR+ Two BA+
16
17
18
19
20
21
22
23
24

Answers

Answer:

Omg what is this

soooo long questionn

i am fainted

what rubbish you written how long the question is of which subject

what's your name

Programming languages categorize data into different types. Identify the characteristics that match each of the following data types.

a. Can store fractions and numbers with decimal positions
b. Is limited to values that are either true or false (represented internally as one and zero).
c. Is limited to whole numbers (counting numbers 1, 2, 3, ...)

Answers

Answer:

a) Integer data type.

b) Real data type.

c) Boolean data type.

Explanation:

a) Integer data type is limited to whole numbers (counting numbers 1, 2, 3…….).

b) Real data type can store fractions and numbers with decimal positions (such as dollar values like $10.95).

c) Boolean data type is limited to values that are either true or false (represented internally as 1 and 0 respectively).

Difference between hardcopy and hardware​

Answers

Hardware is the tangible, or physical, pieces that make up your computer. ... A soft copy (just like software) remains on the computer and cannot be physically touched while a hard copy (just like your computer's hardware) is a printed piece of paper that be be touched

Discuss the OSI Layer protocols application in Mobile Computing

Answers

Answer:

The OSI Model (Open Systems Interconnection Model) is a conceptual framework used to describe the functions of a networking system. The OSI model characterizes computing functions into a universal set of rules and requirements in order to support interoperability between different products and software.

hope that helps you

please follow

please mark brainliest

Write a program to compare the content of AX and DX registers, if they are equal store 1 (as 8 bits) in locations with offset addresses (0020H, 0021H, ..., 0040H), otherwise leave these locations without changing.
???​

Answers

Answer:

so srry I'm very low that this question

List any four strategies of IT Policy?

Answers

Answer:

News skill and qualifications

Other Questions
Answer can u help please You will create a molecular clock model for an arthropod gene. Follow these guidelines to make your model:Your timeline will span from 90 million years ago to the present. The common ancestor in your model is an arthropod that lived 90 million years ago. The gene that youll track codes for a protein in the species venom.The DNA sequence youll track contains 10 nitrogen bases. You can choose the order of the bases and where the mutations occur.This gene mutates at a rate of approximately 0.76 base pairs every 17.1 million years. To build your model, calculate the estimated time period it takes for 1 base pair to mutate.The first time period will only show the common ancestor. At the beginning of the second time period, three lineages will diverge from the common ancestor, each with a different mutation in their gene sequences.The first and third descendant species will survive for the rest of the timeline. The second descendant species was extinct 50 million years ago.Calculate how long it will take for one full base pair mutation to occur. Explain your reasoning by constructing a mathematical equation. Franklin is a research scientist at Insight Research Corporation (IRC). IRC has five research scientists, four assistants, one secretary, and one CEO. Franklin has developed ALS, a disease which binds him to a wheelchair. He is one of the greatest scientists in the world, and can still do his job. Franklin has requested that IRC accommodate his disability, making changes to the company restroom and widening the doors to the building. The changes would be relatively inexpensive, costing only $2,000. If Franklin sues under the Americans with Disabilities Act (ADA), what result Explain in detail what caused the population of peppered moths to change from mostly light-colored variations to mostly dark-colored variations in the 1800s. Explain how the peppered moth mutation is an example of natural selection. Explain what would happen to the populations of both variations of peppered moth once the pollution disappeared. Determine which variation of the peppered moth would be more successful in your neighborhood, and explain in detail your reasoning supporting your conclusion. Predict what may happen to the population of peppered moths if they were relocated to a lush, green rainforest ecosystem. How would this impact natural selection and their struggle to survive? Find the area of the figure in the image attached. Round to the nearest tenth if necessary. Define hypothesisThx! A two year old client experiencing an anaphylactic reaction and respiratory distress with laryngeal spasms is being prepared for an endotracheal tube (ETT) placement. The healthcare provider has ordered 0.5mL of epinephrine 1:10,000 to be given STAT. The attempts to place an intravenous catheter were unsuccessful. What is another appropriate route to administer the epinephrine during this anaphylactic emergency Item 1 Which fraction is equivalent to 3.47? 3_23/50 3_47/100 3_12/25 I don't know. A person walks away from a pulley pulling a rope slung over it. The rope is being held at a height 10 feet below the pulley. Suppose that the weight at the opposite end of the rope is rising at 4 feet per second. At what rate is the person walking when s/he is 20 feet from being directly under the pulley Jenny asked 12 students how many courses they have taken so far at her college. Here is the list of answers.16, 7, 21, 14, 9, 11, 22, 19, 17, 12, 5, 25What is the percentage of these students who have taken fewer than 21 courses? Emulsifiers are Multiple Choice molecules with two nonpolar ends that can be used to disperse lipids into polar liquids such as water. molecules with a polar end and a nonpolar end that can be used to disperse lipids into polar liquids such as water. molecules with two polar ends that can be used to disperse lipids into polar liquids such as water. proteins that transport nonpolar substances in the bloodstream. proteins that transport polar substances in the bloodstream. What is the Constant of which bait works best for a fly trap? I need to know what is the median of the data Andrew is an avid archer. He launches an arrow that takes a parabolic path.The equation of the height of the arrow with respect to time isy = -4.9x2 + 48x, where y is the height of the arrow in meters aboveAndrew's bow and x is the time in seconds since Andrew shot the arrow.Find how long it takes the arrow to come back to a height even with his bowheight. How many of Pauls letters are undisputed?a. 5b. 7c. 9d. 11 A characteristic is a feature that helps to identify something. How would you describe a characteristic of a good movie or book? 20) solve: [tex] {8}^{2} + 2 = [/tex]21) solve: [tex]4(2x + 5y = [/tex]22) simplify the expression [tex]4( {2}^{2} + 30) - 4 = [/tex] A. Nepalese sculptures of Buddha were more realistic than Indian sculptures of Buddha B. Buddhism had spread from India to Nepal by the 11th century C. Buddhism was not practiced outside of India during the 11th century D. Buddhism had spread from Nepal to India by the 11th century why am i doing the investigation what effect does the force of gravity have on a stone thrown vertically upwards