INTERACTIVE ONLINE COURSE

Python 3

FOR BEGINNERS


"The first Python course that simply amazed me. Very well explained and easy to understand." (Alexandru Cosmin)

"The best Python course in Romania." (Iulian Geană)


ALL REVIEWS
LESSON 20
PAGE 1 / 1
I/O - Text Files in Python 3
Home >>> Online Lessons, Python 3

About Text Files

So far, we have used the input and print functions to read and write data in Python because it is an easy way to check and run programs.

In practice, things are more complex. Usually, when we write a program, we test it with a few inputs from the keyboard. Such tests are not significant. The program might have bugs (a term used by programmers, referring to hidden errors that a program might have). Also, we don't see how efficient our program is, although some efficiency calculations can be done before writing it.

But what if we have a list with 200,000+ values?



At that moment, an external text file can come to our aid. We might have data that changes or is frequently updated, like statistics related to the SARS-CoV-2 virus.

The files are text-based and can be created using an editor or directly from the interactive Python console editor. To be identified more easily, we can change their extension as shown above – *.in for input data, and *.out for output data (a somewhat standardized form).

Attention! In all computer science competitions, contestants' programs are tested using text files.

How to Use Text Files?

Read the material below carefully and complete the proposed exercises on your computer.
The online Python system does not have all the capabilities of the native interpreter; it is used for educational purposes only. If you do not have Python 3 installed on your computer, access the tutorial found [here].

As much as it allows us, we will create a small project together!
This section is now over.
 home   list  CONTENTS   perm_identity   arrow_upward