New game
Download
Get Academic Plan
Share game
Integrate it into your platform

You can integrate the game into an LMS compatible with LTI 1.1 or LTI 1.3 such as Canvas, Moodle, or Blackboard. This way, the scores will be automatically saved into the platform’s gradebook.
Download
You have exceeded the maximum number of games you can integrate into Google Classroom with your current Plan.

To integrate as many games as you want in Google Classroom, you need an Academic Plan or a Commercial Plan.

You have exceeded the maximum number of games you can integrate into Microsoft Teams with your current Plan.

To integrate as many games as you want in Microsoft Teams, you need an Academic Plan or a Commercial Plan.

Downloading games is an exclusive feature for users with an Academic Plan or a Commercial Plan.

Get your Academic Plan or your Commercial Plan now and start integrating your games into your LMS, website or blog.

If you wish, you can download a demo game here and test its integration:

Файлы в Python: основы и примеры

Slideshow

Played 1

About this activity

Основы работы с файлами на Python

Created by

Kazakhstan

Download the paper version to play

Make your own free game from our game creator
Compete against your friends to see who gets the best score in this game

Top Games

%
Anonymous
Anonymous
%
%
%
You have exceeded the maximum number of games you can print with your current Plan.

To print as many games as you want, you need an Academic Plan or a Commercial Plan.

Print your game
Файлы в Python: основы и примеры
 

Файлы в Python: основы и примерыOnline version

Основы работы с файлами на Python

by Olga Tsymbota
1

Что такое файл и зачем он нужен

Файл — внешний источник данных, который можно открыть и прочитать. В текстовых файлах обычно хранится текст и данные в простом формате. Поддерживаются форматы CSV, JSON и другие.
2

Типы файлов и форматы

Чтобы работать с данными, различают текстовые и двоичные файлы. Текстовые файлы читаются как текст; другие форматы требуют специальных обработчиков (CSV, JSON, Excel, PDF).
3

Основные режимы открытия файлов

r — чтение, w — запись (создает файл), a — добавление в конец. r+, w+, a+ позволяют чтение и запись.
4

Пример: открытие файла на чтение

Открываем файл для чтения: file1 = open('sample.txt', 'r'). Затем читаем содержимое и закрываем файл.
5

Пример: запись в файл

Создаем файл и записываем текст: file = open('myFile.txt', 'w+'); файл записывает строку и затем закрывается.
6

Добавление данных к файлу

Чтобы добавить текст, используйте режим a или a+. Важно помнить о необходимости перехода на новую строку при добавлении.
7

Чтение данных из файла

Можно читать весь файл целиком или построчно, используя read(), readline() или readlines().
8

Чтение строк как список

readlines() возвращает список строк; можно итерироваться по нему и обрабатывать каждую строку.
9

Чтение построчно

Цикл while с readline() позволяет обрабатывать файл построчно до конца файла. Не забывайте закрывать файл.
10

Альтернативы и полезные практики

Используйте with open(...) как контекстный менеджер для автоматического закрытия файла и безопасной работы с ресурсами.
Are you sure you want to leave the page?

If you leave, you will lose the game in progress.