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
What are the disadvantages of military shovels?
Xelga [282]

Answer:

being prepared and having sufficient military resources available can be great IF there is an attack although it can be viewed as intimidating and scare off allies. also, it can cause other resources too thin.

Explanation:

it is great to have a sense of national pride and togetherness although if it gets out of hand it can be almost brainwashing and used to control citizens.

4 0
2 years ago
What are the two (2) different design elements of scratch?
Roman55 [17]

Answer: There is four elements of Scratch. The stage, the sprites, the script and the programming palette.

Explanation:

6 0
2 years ago
The efficiency of a steam power plant can beincreased by bleeding off some of the steam thatwould normally enter the turbine and
3241004551 [841]

Answer:

Explanation:

This is Answer....

5 0
2 years ago
Working with which of these systems requires a technician that has been certified in an EPA-approved course?
makvit [3.9K]

EPA Regulations provides a certified course for the technicians involved in the Air-conditioning system.

Answer: Option (b)

<u>Explanation:</u>

The EPA regulation has implemented an act called the "Clean Air Act" under the "section of 609".

This act provides some basic requirements for EPA Regulation such as follows;

  • Refrigerant: This unit must be approved by EPA Regulations before being implemented into the atmosphere.
  • Servicing: This system provides a certified course for technicians in service and also approve them with proper refrigerant equipment.
  • Reuse Refrigerants: The use of recycled refrigerants must be properly monitored before it comes in to serve.
6 0
3 years ago
Write an<br> algorithm and draw a flowchart to convert the length in feet to<br> centimeter
Simora [160]

Answer:

blah blah blah sh ut up read learn

3 0
3 years ago
Other questions:
  • Suppose that a wing component on an aircraft is fabricated from an aluminum alloy that has a plane strain fracture toughness of
    13·1 answer
  • What is the name of the model/shape below?
    5·2 answers
  • The Review_c object has a lookup relationship up to the Job_Application_c object. The job_Application_c object has a master-deta
    7·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
  • Calculate the number of vacancies per cubic meter for some metal, M, at 749°C. The energy for vacancy formation is 0.86 eV/atom,
    5·1 answer
  • Complete the following sentence.
    7·1 answer
  • What is it that makes a battery rechargeable? How is it different from a regular battery?
    14·2 answers
  • Cody’s car accelerates from 0m/s to 45 m/s northward in 15 seconds. What is the acceleration of the car
    14·1 answer
  • The current at resonance in a series L-C-R circuit is 0.2mA. If the applied voltage is 250mV at a frequency of 100 kHz and the c
    9·1 answer
  • أجوبة على مسائل في الإستاتيكا أيمكن ذالك
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!