Computer Science, asked by js6189764, 2 months ago

write a program to read content of file and display 'I' in place of 'E' while displaying the content of the file all character should be as it is.please answer the question in python​

Answers

Answered by Anonymous
11

Replacing text - Python

Since we are not given/mentioned in the Question that by what programming language we write the required program, so here we are using python program to read content of file and display 'I' in place of 'E' while displaying the content of the file all character should be as it is.

Before we write the required program for this question, let's first take some hint for better understanding and know that what we need to do in this program and how to write the program.

What we need to do

We would take a user input function first, to accept the texts from the user. We know that the \tt{in put()} function returns a string, string is one of the basis types in Python that store text.

After that, we will use the syntax to replace the texts, here's the syntax to replace the texts:

\tt{>>> \; letter.replace(old, new)}

We then print out the file after replacing 'I' in place of 'E', by simply using \tt print() function to print the file.

\rule{300}{1}

The Program

texts = input("Enter your file: ")

replace = texts.replace("I","E")

print(replace)

We can also short this program, so let's short the program, by changing something.

texts = input("Enter your file: ")

print(texts.replace("I","E"))

Do you know, we can also shorten this program further, so let's short the program more, by changing something.

print((input("Enter your file: ")).replace("I","E"))

\rule{300}{1}

Sample run

The output of the given program will be as follows:

Enter your file: Hello there, I'm Eldarion.

E'm Eldarion.

Answered by anthonypaulvilly
2

Replacing text - Python

Since we are not given/mentioned in the Question that by what programming language we write the required program, so here we are using python program to read content of file and display 'I' in place of 'E' while displaying the content of the file all character should be as it is.

Before we write the required program for this question, let's first take some hint for better understanding and know that what we need to do in this program and how to write the program.

What we need to do

We would take a user input function first, to accept the texts from the user. We know that the  function returns a string, string is one of the basis types in Python that store text.

After that, we will use the syntax to replace the texts, here's the syntax to replace the texts:

We then print out the file after replacing 'I' in place of 'E', by simply using  function to print the file.

 

The Program

texts = input("Enter your file: ")

replace = texts.replace("I","E")

print(replace)

We can also short this program, so let's short the program, by changing something.

texts = input("Enter your file: ")

print(texts.replace("I","E"))

Do you know, we can also shorten this program further, so let's short the program more, by changing something.

print((input("Enter your file: ")).replace("I","E"))

Sample run

The output of the given program will be as follows:

Enter your file: Hello there, I'm Anthony

Anthony Paul Villy

Similar questions