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
PELASEE HELPPP WITH MARK BRAINLIST!!!! You are stopped at a red light, and a long string of cars is crossing in front of you. Wh
choli [55]

Answer:

1st one.

Explanation:

I think that because they the one who is going to get a ticket and also you will not gonna get in a car accident.

7 0
3 years ago
Read 2 more answers
Technician A says that the first step in diagnosing engine condition is to perform a thorough visual inspection. Technician B sa
mojhsa [17]

Answer:

Technician A

Explanation: Technician A is correct. Technician B is wrong, as an oil leak can trickle down onto other engine components, away from where the leak actually is.

5 0
3 years ago
The Molybdenum with an atomic radius 0.1363 nm and atomic weight 95.95 has a BCC unit cell structure. Calculate its theoretical
Nookie1986 [14]

Solution:

Given :

atomic radius, r = 0.1363nm = 0.1363×10⁻⁹m

atomic wieght, M = 95.96

Cell structure is BCC (Body Centred Cubic)

For BCC, we know that no. of atoms per unit cell, z = 2

and atomic radius, r =\frac{a\sqrt{3} }{4}

so, a = \frac{4r}{\sqrt{3}}

m = mass of each atom in a unit cell

mass of an atom = \frac{M}{N_{A} },

where, N_{A} is Avagadro Number = 6.02×10^{23}

volume of unit cell = a^{3}

density, ρ = \frac{mass of unit cell}{volume of unit cell}

density, ρ = \frac{z\times M}{a^{3}\times N_{A}}

ρ = \frac{2\times 95.95}{(\frac{4\times 0.1363\times 10^{-9}}{\sqrt{3}})^{3}\times (6.23\times 10^{23})}

ρ = 10.215gm/cm^{3}

5 0
3 years ago
Wassup everyone here is my question...
Varvara68 [4.7K]

Answer:

Step One: Know What Your Rocket Needs to Do. ...

Step Two: Establish Mission Parameters. ...

Step Three: Call in Experts. ...

Step Four: Start Drawing. ...

Step Five: Whittle Down the Possibilities. ...

Step Six: Pick the Best Design.

Explanation:

Hope this helps and thx for tha fwee pts

6 0
3 years ago
Which of the following methods of obtaining digitized images can recognize and preserve text and formatting?
Zarrin [17]
The answer is A a digital camera
6 0
3 years ago
Other questions:
  • Define an ADT for a two-dimensional array of integers. Specify precisely the basic operations that can be performed on such arra
    5·1 answer
  • A(n) ____ is an exact representation of an object projected onto a plane from a specific position.
    14·1 answer
  • Which of the following best describes the relationship between the World Wide Web and the Internet? А The World Wide Web is a pr
    5·1 answer
  • Technician A says that a way to prevent galvanic corrosion is to duplicate the original installation method. Technician B says t
    12·1 answer
  • Select the correct answer.
    12·1 answer
  • Which of the following can not be used to store an electrical charge?
    11·1 answer
  • Most goals
    12·1 answer
  • It is illegal to improperly dispose of antifreeze.<br> True<br> False
    8·2 answers
  • Their game off badminton is always on Tuesday
    11·1 answer
  • Which band has an average of $3.58 per hour of parking?
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!