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
Transcript
posledela

Answer:

O is truse is the best answer hhahahha

Explanation:

8 0
3 years ago
a buyer can purchase 70 screwdrivers ten 4-inch length twelve 6 inch length twenty 8-inch length are needed. how many heavy 24-i
jasenka [17]

Answer:

28 , 24-inch screwdrivers

Explanation:

The total number of screwdrivers that can be purchased is = 70

4 - inch length screwdrivers = 10

6- inch length screwdrivers = 12

8- inch length screwdrivers = 20

Total = 20 +12 +10 = 42

Remaining = 70-42 = 28

So, heavy 24-inch screwdrivers = 28

3 0
3 years ago
A pipeline (NPS = 14 in; schedule = 80) has a length of 200 m. Water (15℃) is flowing at 0.16 m3/s. What is the pipe head loss f
dangina [55]

Answer:

Head loss is 1.64

Explanation:

Given data:

Length (L) = 200 m

Discharge (Q) = 0.16 m3/s

According to table of nominal pipe size , for schedule 80 , NPS 14,  pipe has diameter (D)= 12.5 in or 31.8 cm 0.318 m

We know, head\ loss  = \frac{f L V^2}{( 2 g D)}

where, f = Darcy friction factor

V = flow velocity

g = acceleration due to gravity

We know, flow rate Q = A x V

solving for V

V = \frac{Q}{A}

    = \frac{0.16}{\frac{\pi}{4} (0.318)^2} = 2.015 m/s

obtained Darcy friction factor  

calculate Reynold number (Re) ,

Re = \frac{\rho V D}{\mu}

where,\rho = density of water

\mu = Dynamic viscosity of water at 15 degree  C = 0.001 Ns/m2

so reynold number is

Re = \frac{1000\times 2.015\times 0.318}{0.001}

            = 6.4 x 10^5

For Schedule 80 PVC pipes , roughness (e) is  0.0015 mm

Relative roughness (e/D) = 0.0015 / 318 = 0.00005

from Moody diagram, for Re = 640000 and e/D = 0.00005 , Darcy friction factor , f = 0.0126

Therefore head loss is

HL = \frac{0.0126 (200)(2.015)^2}{( 2 \times 9.81 \times 0.318)}

HL = 1.64 m

7 0
3 years ago
What are the benefits of NSTP CWTS?​
geniusboy [140]

Explanation:

The purpose of this program is to recognize the Youth's vital role in nation- building, promote consciousness among youth and develop their physical, moral, spiritual, intellectual and social well-being. It shall inculcate in the youth patriotism, nationalism, and advance their involvement in public and civic affairs.

8 0
3 years ago
Identify one of the advantages of 3d modeling?
Naddik [55]

Answer:

Hello Adam here! (UWU)

Explanation:

The advantages of 3D modeling for designers is not limited to productivity and coordination, it is an excellent communication tool for both the designer and end user. 3D models can help spark important conversations during the design phase and potentially avoid costly construction mishaps.

Happy to Help! (>.O)

6 0
3 years ago
Other questions:
  • Engineers are designing a cylindrical air tank and are trying to determine the dimensions of the tank. The proposed material for
    14·1 answer
  • What does STP and NTP stands for in temperature measurement?
    15·1 answer
  • Nitrogen enters a steady-flow heat exchanger at 150 kPa, 10°C, and 100 m/s, and it receives heat as it flows through it. Nitroge
    15·1 answer
  • Can a real refrigerator have higher COP than the COP of the Carnot refrigerator?
    7·2 answers
  • What are the characteristic features of stress corrosion cracks?
    15·1 answer
  • A closed, rigid tank is lled with a gas modeled as an ideal gas, initially at 27°C and a gage pressure of 300 kPa. The gas is he
    15·1 answer
  • How many kg moles of Sodium Sulphate will contain 10 kg of<br> Sodium?
    10·2 answers
  • La iluminación de la superficie de un patio amplio es 1600 lx cuando el ángulo de elevación del sol 53°. Calcular la iluminación
    15·1 answer
  • Can some one plz give me brainlys
    14·2 answers
  • Adding new equipment or processes may require changes to the PPE requirements for
    7·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!