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
Where do the names of counterweight items originally come from
Ugo [173]

Answer:

an equivalent weight or force : counterbalance.

4 0
3 years ago
Read 2 more answers
What are the advantages of using a network?
Rudiy27

Answer:

Sharing devices such as printers saves money.

Site (software) licences are likely to be cheaper than buying several standalone licences.

Files can easily be shared between users.

Network users can communicate by email and instant messenger.

Security is good - users cannot see other users' files unlike on stand-alone machines.

Data is easy to backup as all the data is stored on the file server.

I hope I helped

5 0
3 years ago
A 0.01 significance level is used for a hypothesis test of the claim that when parents use a particular method of gender? select
Nataly_w [17]

Answer:

Option D

H_o equals 0.5 H_a less than 0.5

Explanation:

Information given

N=144

X=66

P=\frac {x}{n}=66/144= 0.458333\approx 0.46

The hypothesis

Null hypothesis

Probability, p =0.5

H_o: p =0.5

Alternative hypothesis

Probability, p<0.5

H_a: p

5 0
4 years ago
Your driver license will be _____ if you race another driver on a public road, commit a felony using a motor vehicle, or are fou
ser-zykov [4K]

Answer:

Revoked

Explanation:

Your driver license will be revoked if you race another driver on a public road, commit a felony using a motor vehicle, or are found guilty of reckless driving three times in one year.

4 0
2 years ago
12. Which of the following letter doesn't still the same when its viewed
Mashcka [7]

Answer:

the correct answer is option B. W

3 0
3 years ago
Read 2 more answers
Other questions:
  • Where are revolved sections placed in a print? A) in between break lines B) cutting planes are used to identify their locations
    12·1 answer
  • Refrigerant 134a is the working fluid in a vaporcompression heat pump that provides 35 kW to heat a dwelling on a day when the o
    14·1 answer
  • In a steady-flow industrial process, m kg/s of an ideal gas flows through a heater at a constant mass flow rate. It is your job
    7·1 answer
  • In adopt me, (Roblox) should I trade my fly ride neon penguin for a car,2 shibu inus and a fly ride neon unicorn?????? This is n
    15·2 answers
  • An airplane tows a banner that is b = 0.8 m tall and ℓ = 25.0 m long at a speed of 150 km/hr. (a) If the drag coefficient based
    12·1 answer
  • What is poop made out of
    13·2 answers
  • A seasonal color change helps animals in the Taiga to
    11·1 answer
  • A primary incentive for entrepreneurs is
    5·1 answer
  • Dan is applying for a job as an engineering technician. What are the tasks that he may be asked to perform?
    15·1 answer
  • How do I solve this ?
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!