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
Deffense [45]
3 years ago
13

read a file called filled in with a few sentences or a paragraph. Then write a function called typoglycemia, which scrambles the

letters in the words in the file leaving the first and last characters unchanged and then writes the results to a new file called "scrambled.txt".Save the file
Engineering
1 answer:
sladkih [1.3K]3 years ago
7 0

Answer:

def typoglycemia():

import random

punct = (".", ";", "!", "?", ",")

count = 0

new_word = ""

inputfile = input("Enter input file name:")

with open(inputfile, 'r') as fin:

for line in fin.readlines(): #Read line by line in txt file

for word in line.split(): # Read word by word in each line

if len(word) > 3: # If word length >3

'''If word ends with punctuation, Remove first letter, last letter and punctuation

shuffle the words: Add the removed letters at their respective positions'''

if word.endswith(punct):

word1 = word[1:-2]

word1 = random.sample(word1, len(word1))

word1.insert(0, word[0])

word1.append(word[-2])

word1.append(word[-1])

''' If there is no punctuation mark: Remove first and last letter.

Shuffle the word then add removed letters at their respective position'''

else:

word1 = word[1:-1]

word1 = random.sample(word1, len(word1))

word1.insert(0, word[0])

word1.append(word[-1])

new_word = new_word + ''.join(word1) + " "

''' If word length <3, just append the word and " " to the the previous words'''

else:

new_word = new_word + word + " "

with open((inputfile[:-4] + "scrambled.txt), 'a+') as fout:

fout.write(new_word + "\n")

new_word = ""

You might be interested in
assume a five layer network model. There are 700 bytes of application data. There is a 20 bye header at the transport layer, a 2
amm1812

Answer: The overhead percentage is 7.7%.

Explanation:

We call overhead, to all those bytes that are delivered to the physical layer, that don't carry real data.

We are told that we have 700 bytes of application data, so all the other bytes are simply overhead, i.e. , 58 bytes composed by the transport layer header, the network layer header, the 14 byte header at the data link layer and the 4 byte trailer at the data link layer.

So, in order to assess the overhead percentage, we divide the overhead bytes between the total quantity of bytes sent to the physical layer, as follows:

OH % = (58 / 758) * 100 = 7.7 %

4 0
3 years ago
Nêu đặc điểm của tín hiệu PAM rời rạc dạng lưỡng cực NRZ, RZ
zhuklara [117]

Answer:

yes it is certainly good ice cream

4 0
3 years ago
What is the function maintenance? List some important steps for vibration monitoring based maintenance.
Mrrafil [7]

The maintenance is in charge of controlling that all the machines of a company are constantly running in order to avoid damages that cause loss of money when the machines fail.

The maintenance based on vibration monitoring allows to predict failures in some rotating machines such as:

1. worn bearings

2.alignment

3.balance

4. affected gears

5. bent shafts

6. rocks

7.gags

8. eccentricity

9. failures of electrical origin

4 0
3 years ago
An engineering firm just lost one of their larger customers. The firm president says that the solution to this problem is to fir
Shkiper50 [21]

Answer:

The engineers disagreed because their jobs were on the line

The ethical factors are:

The reason for the customer dumping the business is yet to be figured out

The need to keep cost to the lowest ebb in order to keep maintain profitability at the expense of employees' welfare

The are several ways of growing customer base which  are yet to be exploited.

Explanation:

The engineers disagree because there is no direct connection between the company's loss of the customer and their proposed layoff of the engineers,at least no one strong evidence has been given by the president.

The ethical factors inherent in this case are as follows:

The reason for the customer dumping the business is yet to be figure out

The need to keep cost to the lowest ebb in order to keep maintain profitability.

The are several ways of growing customer base which  are yet to be exploited.

There is  a need for a fact-finding exercise to establish the main motive behind losing such customer,without which the company can run into more troubles in future,otherwise the company would keep firing its good hands each time a customer dumps it.

Also,the president had resulted into such decision in order to maintain company's margins,where then lies ethics of welfare economics?Welfare economics is about looking beyond margins and looking at issues from a wider perspective of fulfilling the needs of employees in order for them to put in their best performance,at least by granting them job safety.

The company could have also grown business by investing in new technology that sets it apart from competitors instead of just jumping into the conclusions of sacking employees in a business where the company's strength lies in quality of engineers that it has.

7 0
3 years ago
Write a program that removes all spaces from the given input. You may assume that the input string will not exceed 50 characters
GrogVix [38]

Answer:

Program that removes all spaces from the given input

Explanation:

// An efficient Java program to remove all spaces  

// from a string  

class GFG  

{  

 

// Function to remove all spaces  

// from a given string  

static int removeSpaces(char []str)  

{  

   // To keep track of non-space character count  

   int count = 0;  

 

   // Traverse the given string.  

   // If current character  

   // is not space, then place  

   // it at index 'count++'  

   for (int i = 0; i<str.length; i++)  

       if (str[i] != ' ')  

           str[count++] = str[i]; // here count is  

                                   // incremented  

         

   return count;  

}  

 

// Driver code  

public static void main(String[] args)  

{  

   char str[] = "g eeks for ge eeks ".toCharArray();  

   int i = removeSpaces(str);  

   System.out.println(String.valueOf(str).subSequence(0, i));  

}  

}  

5 0
4 years ago
Read 2 more answers
Other questions:
  • Refrigerant-134a enters a diffuser steadily as saturated vapor at 600 kPa with a velocity of 160 m/s, and it leaves at 700 kPa a
    10·2 answers
  • Define the Problem
    11·1 answer
  • A simply supported beam spans 25 ft and carries a uniformly distributed dead load of 0.6 kip/ft, including the beam self-weight,
    15·1 answer
  • There are 30 students in a class. Choose the statement that best explains why at least two students have last names that begin w
    12·1 answer
  • a digital multimeter is set to read dc volts on the 4 volt scale the meter leads are connected to a 12 volt battery what will th
    14·2 answers
  • Digital leaders are people who __ others down a particular path.
    13·2 answers
  • A fair die is thrown, What is the probability gained if you are told that 4 will
    12·1 answer
  • Give three examples of how engineering has made human life better in your opinion.
    13·1 answer
  • What should you use to keep battery terminals from corroding
    12·1 answer
  • When starting up a dual fuel system, the temperature rise method for determining airflow cannot be used with the compressor cycl
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!