RUVIDEO
Поделитесь видео 🙏

2. FILE HANDLING IN PYTHON || DATA FILE HANDLING ||CLASS 12 COMPUTER SCIENCE || PYTHON || TEXT FILE

#NANDINI_DAS
2.1 Introduction to Files
We have so far created programs in Python that accept the input, manipulate it and display the output. But that output is available only during execution of the program and input is to be entered through the keyboard. This is because the variables used in a program have a lifetime that lasts till the time the program is under execution.
What if we want to store the data that were input as well as the generated output permanently so that we can reuse it later? Usually, organisations would want to permanently store information about employees, inventory, sales, etc. to avoid repetitive tasks of entering the same data. Hence, data are stored permanently on secondary storage devices for reusability. We store Python programs written in script mode with a .py extension. Each program is stored on the secondary device as a file. Likewise, the data entered, and the output can be stored permanently into a file.
So, what is a file? A file is a named location on a
secondary storage media where data are permanently
stored for later access.
2.2. Types of Files
Computers store every file as a collection of 0s and 1s
i.e., in binary form. Therefore, every file is basically just
a series of bytes stored one after the other. There are
mainly two types of data files — text file and binary
file. A text file consists of human readable characters,
which can be opened by any text editor. On the other
hand, binary files are made up of non-human readable
characters and symbols, which require specific programs
to access its contents.
2.2.1 Text file
A text file can be understood as a sequence of characters
consisting of alphabets, numbers and other special
symbols. Files with extensions like .txt, .py, .csv, etc.
are some examples of text files. When we open a text file
using a text editor (e.g., Notepad), we see several lines
of text. However, the file contents are not stored in such
a way internally. Rather, they are stored in sequence
of bytes consisting of 0s and 1s. In ASCII, UNICODE or
any other encoding scheme, the value of each character
of the text file is stored as bytes. So, while opening a
text file, the text editor translates each ASCII value
and shows us the equivalent character that is readable
by the human being. For example, the ASCII value 65
(binary equivalent 1000001) will be displayed by a text
editor as the letter ‘A’ since the number 65 in ASCII
character set represents ‘A’.
Each line of a text file is terminated by a special
character, called the End of Line (EOL). For example,
the default EOL character in Python is the newline
(\n). However, other characters can be used to indicate
EOL. When a text editor or a program interpreter
encounters the ASCII equivalent of the EOL character,
it displays the remaining file contents starting from a
new line. Contents in a text file are usually separated
by whitespace, but comma (,) and tab (\t) are also
commonly used to separate values in a text file.
2.2.2 Binary Files
Binary files are also stored in terms of bytes (0s and 1s),
but unlike text files, these bytes do not represent the
ASCII values of characters. Rather, they represent the
actual content such as image, audio, video, compressed
versions of other files, executable files, etc. These files
are not human readable. Thus, trying to open a binary
file using a text editor will show some garbage values.
We need specific software to read or write the contents
of a binary file.
Binary files are stored in a computer in a sequence
of bytes. Even a single bit change can corrupt the file
and make it unreadable to the supporting application.
Also, it is difficult to remove any error which may occur
in the binary file as the stored contents are not human
readable. We can read and write both text and binary
files through Python programs.
2.3 Opening and Closing a Text File
In real world applications, computer programs deal
with data coming from different sources like databases,
CSV files, HTML, XML, JSON, etc. We broadly access
files either to write or read data from it. But operations
on files include creating and opening a file, writing data
in a file, traversing a file, reading data from a file and
so on. Python has the io module that contains different
functions for handling files.

Что делает видео по-настоящему запоминающимся? Наверное, та самая атмосфера, которая заставляет забыть о времени. Когда вы заходите на RUVIDEO, чтобы посмотреть онлайн «2. FILE HANDLING IN PYTHON || DATA FILE HANDLING ||CLASS 12 COMPUTER SCIENCE || PYTHON || TEXT FILE», вы рассчитываете на нечто большее, чем просто загрузку плеера. И мы это понимаем. Контент такого уровня заслуживает того, чтобы его смотрели в HD 1080, без дрожания картинки и бесконечного буферизации.

Честно говоря, Rutube сегодня — это кладезь уникальных находок, которые часто теряются в общем шуме. Мы же вытаскиваем на поверхность самое интересное. Будь то динамичный экшн, глубокий разбор темы от любимого автора или просто уютное видео для настроения — всё это доступно здесь бесплатно и без лишних формальностей. Никаких «заполните анкету, чтобы продолжить». Только вы, ваш экран и качественный поток.

Если вас зацепило это видео, не забудьте взглянуть на похожие материалы в блоке справа. Мы откалибровали наши алгоритмы так, чтобы они подбирали контент не просто «по тегам», а по настроению и смыслу. Ведь в конечном итоге, онлайн-кинотеатр — это не склад файлов, а место, где каждый вечер можно найти свою историю. Приятного вам отдыха на RUVIDEO!

Видео взято из открытых источников Rutube. Если вы правообладатель, обратитесь к первоисточнику.