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
A 600-ha farmland receives annual rainfall of 2500 mm. There is a river flowing through the farmland with an inflow rate of 5 m3
shepuryov [24]

Answer:

E = 7333.33 mm

Explanation:

The annual evapotranspiration (E) amount can be calculated using the water budget equation:

P*A + Q_{in}*\Delta t = E*A + \Delta S + Q_{out}*\Delta t   (1)

<u>Where</u>:

<em>P: is the precipitation = 2500 mm, </em>

<em>Q(in): is the water flow into the river of the farmland = 5 m³/s, </em>

<em>ΔS: is the change in water storage = 2.5x10⁶ m³,  </em>

<em>Q(out): is the water flow out of the river of the farmland = 4 m³/s.</em>

<em>Δt: is the time interval = 1 year = 3.15x10⁷ s </em>

<em>A: is the surface area of the farmland = 6.0x10⁶ m² </em>  

Solving equation (1) for ET we have:

E = \frac{P*A + Q_{in}*\Delta t - \Delta S - Q_{out}*\Delta t}{A}

E = \frac{2.5 m \cdot 6.0 \cdot 10^{6} m^{2} + 5 m^{3}/s \cdot 3.15 \cdot 10^{7} s - 2.5 \cdot 10^{6} m^{3} - 4 m^{3}/s \cdot 3.15 \cdot 10^{7} s}{6.0\cdot 10^{6} m^{2}}                                  

E = 7333.33 mm

Therefore, the annual evapotranspiration amount is 7333.33 mm.

I hope it helps you!  

3 0
4 years ago
Hey how is everybody?
Tomtit [17]

Answer:

ig good

mostly bored

u would rlly drive that instead a ferrari??

Explanation:

7 0
3 years ago
Read 2 more answers
Let S = { p q |p, q are prime numbers greater than 0} and E = {0, −2, 2, −4, 4, −6, 6, · · · } be the set of even integers. . Pr
Finger [1]

Answer:

prove that | S | = | E | ; every element of S there is an Image on E , while not every element on E has an image on S

Explanation:

Given that S = { p q |p, q are prime numbers greater than 0}

                    E = {0, −2, 2, −4, 4, −6, 6, · · · }

To prove  by constructing a bijection from S to E

detailed  solution attached below

After the bijection :

<em>prove that | S | = | E |</em> :  every element of S there is an Image on E , while not every element on E has an image on S

∴ we can say sets E and S are infinite sets

7 0
3 years ago
Many companies are combining their online business activities with an existing physical presence. In about 100 words, explain wh
Daniel [21]

Answer:

Companies are combining their online business activities with their existing physical presence in order to lower costs of their operations. When both these things are combined labor costs are reduced because with online presence the company has to have limited number of branches, inventory costs are reduced because additional inventories for every physical outlet is not required and delivery costs are reduced because now company don't have to supply the things to all the outlets on regular basis.

Trust of the people is also improved because mostly people are reluctant to order from the brands that only have their online store and donot have any physical presence. Value added services are provided by a company who have both online and offline presence like home delivery and customized offerings.

 

3 0
3 years ago
Steel balls 10 mm in diameter are annealed by heating to 1150 k and then slowly cooling to 450 k in an air environment for which
Darina [25.2K]

Answer:

The answer is below

Explanation:

Given that:

ρ = 800 kg/m3, c = 600 J/kg-K,  k = 40 W/m-K, Initial temperature = Ti = 1150,

Environment temperature = T = 450 K, Final temperature = T∞ = 325 K

Diameter = 10 mm = 0.01 m, A = 6

The estimated time for cooling process (t) is given as:

t=\frac{\rho dc}{hA} ln\frac{T_i-T_\infty}{T-T_infty}=\frac{7800*0.01*600}{25*6} ln\frac{1150-325}{450-325}\\  \\t=589\ s\\t=0.1635\ h

The estimated cooling time is 589 s

4 0
3 years ago
Other questions:
  • What is the capacity of the machine in batches?
    10·1 answer
  • Air is contained in a vertical piston–cylinder assembly such that the piston is in static equilibrium. The atmosphere exerts a p
    9·1 answer
  • Position from polar velocity A particle P starts at time t 0s at the position
    12·1 answer
  • Discurso de Santiago Manuin Valera,
    10·1 answer
  • Hi. I would like to know why one side of an island can get more rain (more rain forms), while the other gets less.
    15·2 answers
  • Ammonia in a piston–cylinder assembly undergoes two processes in series. At the initial state, p1 = 120 lbf/in.2 and the quality
    15·1 answer
  • A cylindrical specimen of Aluminium having a diameter of 12.8 mm and gauge length of 50.8 is pulled in tension. Use the data giv
    5·1 answer
  • In the last 5 meters of braking, you lose ___ of your speed.
    6·1 answer
  • A 12 kg hockey puck is traveling at a velocity of 15 m/s. What is the momentum?
    7·1 answer
  • (2pts) In _______________, the pulse amplitude is made proportional to the amplitude of the modulating signal. pulse-amplitude m
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!