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]
2 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]2 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
Windmills slow the air and cause it to fill a larger channel as it passes through the blades. Consider a circular windmill with
Scilla [17]

Answer:

DIAMETER  = 9.797 m

POWER = \dot W = 28.6 kW

Explanation:

Given data:

circular windmill diamter D1 = 8m

v1 = 12 m/s

wind speed = 8 m/s

we know that specific volume is given as

v =\frac{RT}{P}

  where v is specific volume of air

considering air pressure is 100 kPa and temperature 20 degree celcius

v =  \frac{0.287\times 293}{100}

v = 0.8409 m^3/ kg

from continuity equation

A_1 V_1 = A_2 V_2

\frac{\pi}{4}D_1^2 V_1 = \frac{\pi}{4}D_1^2 V_2

D_2 = D_1 \sqrt{\frac{V_1}{V_2}}

D_2 = 8 \times \sqrt{\frac{12}{8}}

D_2 = 9.797 m

mass flow rate is given as

\dot m = \frac{A_1 V_1}{v} = \frac{\pi 8^2\times 12}{4\times 0.8049}

\dot m = 717.309 kg/s

the power produced \dot W = \dot m \frac{ V_1^2 - V_2^2}{2} = 717.3009 [\frac{12^2 - 8^2}{2} \times \frac{1 kJ/kg}{1000 m^2/s^2}]

\dot W = 28.6 kW

8 0
3 years ago
An excavation is at risk for cave-in and water accumulation because of the excess soil that has accumulated. What type of excava
N76 [4]

Answer:Topographic map. Contour line. Learning Objectives. After completing this chapter, you will be able to: □ Define civil engineering and civil drafting.

Explanation:

4 0
3 years ago
Read 2 more answers
35 points an brainiest if correct
Jet001 [13]
I think the answer is B. 10D
6 0
2 years ago
Determine the constant speed at which the cable at A must be drawn in by the motor in order to hoist the load 6 m in 1.5s
zlopas [31]

Answer:

4m/s

Explanation:

We know that power supplied by the motor should be equal to the rate at which energy is increased of the mass that is to be hoisted

Mathematically

Power_{motor} } =\frac{Energy }{time}\

We also know that Power = force x velocity      ..................(i)

The force supplied by the motor should be equal to the weight (mg) of the block since we lift the against a force equal to weight of load

=> power = mg x Velocity........(ii)

While hoisting the load at at constant speed only the potential energy of the mass increases

Thus Potential energy = Mass x g x H...................(iii)

where

g = accleration due to gravity (9.81m/s2)

H = Height to which the load is hoisted  

Equating equations (ii) and (iii) we get

m x g x v = \frac{mgh}{t}

thus we get v = H/t

Applying values we get

v = 6/1.5 = 4m/s

5 0
3 years ago
11) If the evaporating pressure was 76 psig for r-22and the compressor inlet temperature was 65f, what would be the total superh
Karolina [17]
Saturated Pressure Temperature chart for R-22 shows 45 degF at 76 psig
65-45= 20 degF superheat



7 0
2 years ago
Other questions:
  • A water pump delivers 6 hp of shaft power when operating. The pressure differential between the outlet and the inlet of the pump
    9·1 answer
  • A satellite is launched 600 km from the surface of the earth, with an initial velocity of 8333.3 m./s, acting parallel to the ta
    14·1 answer
  • Which of the following has nothing to do with insulating glass? Group of answer choices
    10·2 answers
  • A rectangular channel 2 m wide carries 3 m3 /s of water at a depth of 1.2 m. If an obstruction 40 cm wide is placed in the middl
    12·1 answer
  • What was the purpose of the vasa ship
    11·1 answer
  • Water evaporating from a pond does so as if it were diffusing across an air film 0.15 cm thick. The diffusion coefficient of wat
    8·1 answer
  • A well-insulated tank in a vapor power plant operates at steady state. Saturated liquid water enters at inlet 1 at a rate of 125
    8·1 answer
  • The hydraulic tool holder is a type of what? A.port B. clamp C. Press D. Actuator​
    11·1 answer
  • What do you think the top TWO game elements are that directly contribute to player immersion?
    15·1 answer
  • 9. What power tool incorporates a set of dies and punches to cut new
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!