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
Air flows at 45m/s through a right angle pipe bend with a constant diameter of 2cm. What is the overall force required to keep t
HACTEHA [7]

Answer:

b)1.08 N

Explanation:

Given that

velocity of air V= 45 m/s

Diameter of pipe = 2 cm

Force exerted by fluid  F

F=\rho AV^2

So force exerted in x-direction

F_x=\rho AV^2

F_x=1.2\times \dfrac{\pi}{4}\times 0.02^2\times 45^2

F=0.763 N

So force exerted in y-direction

F_y=\rho AV^2

F_y=1.2\times \dfrac{\pi}{4}\times 0.02^2\times 45^2

F=0.763 N

So the resultant force R

R=\sqrt{F_x^2+F_y^2}

R=\sqrt{0.763^2+0.763^2}

R=1.079

So the force required to hold the pipe is 1.08 N.

3 0
3 years ago
Roku internet service providet​
podryga [215]

Answer:

What?? I do not understand?

6 0
3 years ago
A point in the x-y plane is represented by its x-coordinate and y-coordinate. Design the class Point that can store and process
Black_prince [1.1K]

Answer:

#include <iostream>

#include <iomanip>

using namespace std;

class pointType

{

public:

pointType()

{

x=0;

y=0;

}

pointType::pointType(double x,double y)

{

this->x = x;

this->y = y;

}          

void pointType::setPoint(double x,double y)

{

this->x=x;

this->y=y;

}

void pointType::print()

{

cout<<"("<<x<<","<<y<<")\n";

}

double pointType::getX()

{return x;

}

double pointType::getY()

{return y;

}

private:

   double x,y;

};

int main()

{

pointType p2;

double x,y;

cout<<"Enter an x Coordinate for point ";

cin>>x;

cout<<"Enter an y Coordinate for point ";

cin>>y;

p2.setPoint(x,y);

p2.print();

system("pause");    

return 0;

}

5 0
3 years ago
Which Battery should be removed first to prevent short circuits?
Cerrena [4.2K]
You are going to have to be more specific than that, perhaps add a picture next time ? Unfortunately, this question can’t be answered.
8 0
3 years ago
Which cod is the best whoever has the best awnser gets brainliest​
Gnesinka [82]

Explanation:

black ops 2

5 0
3 years ago
Other questions:
  • ¿Existen formas verbales en singular y en plural?<br>POR FAVOR DIGAMEN EXAMEN TENGO HORITA
    5·1 answer
  • The purification of hydrogen gas is possible by diffusion through a thin palladium sheet. Calculate the number of kilograms of h
    15·1 answer
  • During engine operation, what force causes a cylinder head to pull tighter against the head gasket?
    11·1 answer
  • I got a rubber band car assigned as a project today. The goal is for the car to go farther/faster than the car my teacher is mak
    6·1 answer
  • Design a digital integrator using the impulse invariance method. Find and give a rough sketch of the amplitude response, and com
    15·1 answer
  • Where do the names of counterweight items originally come from
    7·2 answers
  • engineering controls are devices such as self sheathing needles and sharps containers to block or eliminate the sharp risk. true
    9·1 answer
  • Fill in the tables and find the equivalent resistance for the following circuits:
    8·1 answer
  • A motor car shaft consists of a steel tube 30 mm internal diameter and 4 mm thick. The engine develops 10 kW at 2000 r.p.m. Find
    11·1 answer
  • Economics is the study of how individuals and societies make choices under the condition of
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!