1. Write a function in python to read the content from a
text file "poem.txt" line by line and display the same on
screen
Answers
Answered by
8
Answer:
def read_file():
file = open("poem.txt","r")
for line in file:
print(line, end="")
file.close()
read_file()
Answered by
1
Concept
- Python is a general-purpose, high-level, interpreted programming language.
- Code readability is prioritized in its design philosophy, which makes heavy use of indentation.
- Python uses garbage collection and dynamic typing.
- Python is a popular computer programming language used to create software and websites, automate processes, and analyze data.
- Since Python is a general-purpose language, it may be used to develop a wide range of applications and isn't tailored for any particular issues.
- Python is frequently utilized by software engineers as a support language for build control and administration, testing, and many other purposes.
Explanation
- The function in python to read the content from a text file "poem.txt" line by line and display the same on screen will be as follow:
def read_file():
file = open("poem.txt","r")
for line in file:
print(line, end="")
file.close()
read_file()
#SPJ3
Similar questions