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
Water of dynamic viscosity 1.12E-3 N*s/m2 flows in a pipe of 30 mm diameter. Calculate the largest flowrate for which laminar fl
Naya [18.7K]

Answer:

For water

Flow rate= 0.79128*10^-3 Ns

For Air

Flow rate =1.2717*10^-3 Ns

Explanation:

For the flow rate of water in pipe.

Area of the pipe= πd²/4

Diameter = 30/1000

Diameter= 0.03 m

Area= 3.14*(0.03)²/4

Area= 7.065*10^-4

Flow rate = 7.065*10^-4*1.12E-3

Flow rate= 0.79128*10^-3 Ns

For the flow rate of air in pipe.

Flow rate = 7.065*10^-4*1.8E-5

Flow rate =1.2717*10^-3 Ns

7 0
3 years ago
The Acme tool is aligned to the work with: A. A square B. The eye C. An Acme tool gage D. A center gage
kotegsom [21]

Answer:

(c) an acme tool gage

Explanation:

with the help of an acme tool we measure the pitch of a screw thread it is used as reference for finding the pitch of the thread it is also called an inspection tool is aligned to work with an acme tool gage it is also used for gage the internal and external threaded product. it is also used for grinding and setting tools it is mainly work 29° thread angle

8 0
3 years ago
Air at 27°C and a velocity of 5 m/s passes over the small region As (20 mm × 20 mm) on a large surface, which is maintained at T
JulsSmile [24]

Answer:

a) The maximum possible heat removal rate = 2.20w

b) Fin length = 37.4 mm

c) Fin effectiveness = 89.6

d) Percentage increase = 435%

Explanation:

See the attached file for the explanation.

5 0
3 years ago
Subcooled liquid water flows adiabatically in a constant diameter pipe past a throttling valve that is partially open. The liqui
Llana [10]

Answer:

hi-he = 0

pi-pe  = positive

ui-ue = negative

ti-te = negative

Explanation:

we know that fir the sub cool liquid water is

dQ = Tds = du +  pdv   ............1

and  Tds = dh - v dP         .............2

so now for process of throhling is irreversible when v is constant

then heat transfer is = 0 in irreversible process

so ds > 0

so here by equation 1 we can say

ds  > 0  

dv = 0 as v is constant

so that Tds = du    .................3

and du > 0

ue - ui > 0

and

now by the equation 2 throttling process  

here enthalpy is constant

so dh = 0

and Tds  = -vdP

so ds > 0  

so that -vdP > 0  

as here v is constant

so -dP =P1- P2

so P1-P2 > 0

so pressure is decrease here

5 0
3 years ago
What was the purpose of the vasa ship
goldfiish [28.3K]
The main purpose was for power. The vessel has come to symbolize Sweden's Great Power Period, when the nation became a major European power and controlled much of the Baltic.
8 0
3 years ago
Other questions:
  • What is the solution to the system of equations?<br><br>2x-y=7<br>y=2x+3​
    8·1 answer
  • Describe a simple process
    11·1 answer
  • Two points along a wire are labeled Xand Y. The current is measured to be iXY= –3A.The reference direction of iXY is defined by
    11·1 answer
  • When choosing a respirator for your job, you must conduct a _____ test.
    15·1 answer
  • Match each situation with the type of material (conductor or inductor) you would want to use in it. You need to connect a recent
    15·1 answer
  • A digital Filter is defined by the following difference equation:
    11·1 answer
  • A common chef's knife is single-beveled.<br> TRUE<br> FALSE
    10·1 answer
  • The purpose of the international residential code is to
    9·1 answer
  • If you have 300 skittles in a bag and you need to have 28 percent yellow. How many yellow skittles would you have to make a mini
    11·1 answer
  • When mass is the same, what is the relationship between radius and compression strength?
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!