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
State 2 reasons on why blind spot checks are important
Marizza181 [45]

Answer:

How to Test for a Blind Spot . As you have learned, the blind spot is an area on your retina that has no visual receptors. Because of this, there is a tiny gap in your visual field. While your brain usually fills in the missing information so that you don't notice it, this quick and easy test makes it possible to demonstrate the blind spot , Of this, 300 crashes are, sadly, fatal. 2 Accidents are just as likely on Australian roads if blind spots are ignored. Not every car has blind-spot detection, so it's best to educate drivers about the importance of the blind spot to avoid accidents. However, not acknowledging the blind spot when driving isn't just dangerous for other cars on.

Explanation:

8 0
3 years ago
What are the philological elements of interior design most like?
sp2606 [1]

Answer:

Ea public address glven via the intercom system of a large buildingxplanation:

7 0
2 years ago
The atmosphere within a room is at 70 °F dry-bulb temperature, 50 percent degree of saturation, and 14.696 psia pressure. The in
Gre4nikov [31]

Answer:

Given that the temperature of the window is below the dew point it will condensate.

Explanation:

A psychrometric chart (like the one attached) will give you the information needed. This chart is for 14.696 psia.

On the bottom horizontal axes you have the dry-bulb temperature, in this case 70°F, going up from this point you can reach the 50% relative humidity curve (red point on chart), going horizontally from this point to the 100% relative humidity you get the dew point temperature (the point at which moisture will condensate) (blue point on chart). In this case the dew point is 50°C. Given that the temperature of the window is below the dew point it will condensate.

6 0
3 years ago
Anything that is made to meet a need or desire is?
slavikrds [6]

Answer:

I think it is process or technology

7 0
3 years ago
Read 2 more answers
A circular hoop sits in a stream of water, oriented perpendicular to the current. If the area of the hoop is doubled, the flux (
natka813 [3]

Answer:

The flux (volume of water per unit time) through the hoop will also double.

Explanation:

The flux = volume of water per unit time = flow rate of water through the hoop.

The Flow rate of water through the hoop is proportional to the area of the hoop, and the velocity of the water through the hoop.

This means that

Flow rate = AV

where A is the area of the hoop

V is the velocity of the water through the hoop

This flow rate = volume of water per unit time = Δv/Δt =Q

From all the above statements, we can say

Q = AV

From the equation, if we double the area, and the velocity of the stream of water through the hoop does not change, then, the volume of water per unit time will also double or we can say increases by a factor of 2

3 0
4 years ago
Other questions:
  • 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
    6·2 answers
  • Linear Time Invariant Systems For each of the systems below an input x(t) and the output y(t) are plotted. Determine whether eac
    5·1 answer
  • Which of the following is an example of an iterative process?
    12·1 answer
  • 1 kg of saturated steam at 1000 kPa is in a piston-cylinder and the massless cylinder is held in place by pins. The pins are rem
    5·1 answer
  • For an irreversible isothermal process occured in a system with temperature T, which following expression best evaluates the cha
    11·1 answer
  • A 350 m^3 retention pond that holds rainwater from a shopping mall is empty at the beginning of a rainstorm. The flow rate out o
    7·1 answer
  • A combined gas-steam power cycle uses a simple gas turbine for the topping cycle and a simpleRankine cycle for the bottoming cyc
    8·1 answer
  • The water behind Hoover Dam in Nevada is 221 m higher than the Colorado River below it. At what rate must water pass through the
    6·1 answer
  • Someone please please help me and explain!! I will give brainliest if right!!!
    9·2 answers
  • Which of the following about valence electron is correct?
    10·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!