Сравнить коммиты
2 Коммитов
Автор | SHA1 | Дата |
---|---|---|
![]() |
619fdaa6fb | 15 часов назад |
![]() |
0d14f1d582 | 16 часов назад |
@ -0,0 +1,2 @@
|
|||||||
|
print('This line was executed from .txt file!')
|
||||||
|
print('And this is two lines programm')
|
@ -0,0 +1,3 @@
|
|||||||
|
#Программа по Теме 1 Коваленко Дмитрий Максимович
|
||||||
|
print('Hello')
|
||||||
|
h=input('Your name=')
|
@ -0,0 +1,98 @@
|
|||||||
|
# Отчет по теме 1
|
||||||
|
|
||||||
|
Коваленко Дмитрий, А-01-23
|
||||||
|
|
||||||
|
## 1 Изучение среды IDLE
|
||||||
|
|
||||||
|
### 1.1 Работа с интерпретатором Python
|
||||||
|
|
||||||
|
Открыл интерпретатор python в терминале
|
||||||
|
|
||||||
|
```
|
||||||
|
vatarishin@MacBook-Air python-labs % python3
|
||||||
|
```
|
||||||
|
|
||||||
|
Попробовал пару простых комманд
|
||||||
|
```
|
||||||
|
>>> print('Hello')
|
||||||
|
Hello
|
||||||
|
>>> h=input('Your name=')
|
||||||
|
Your name=Dmitriy
|
||||||
|
```
|
||||||
|
Завершил раборту с интерпретатором в терминале
|
||||||
|
```
|
||||||
|
>>> exit()
|
||||||
|
vatarishin@MacBook-Air python-labs %
|
||||||
|
```
|
||||||
|
### 1.2 Работа с python в IDE
|
||||||
|
|
||||||
|
Создал файл [Pr0.py](Pr0.py) и непенес в него команды из предыдущего пункта.
|
||||||
|
|
||||||
|
Запустил файл на выполнение посредством GUI IDE VS CODE
|
||||||
|
```
|
||||||
|
vatarishin@MacBook-Air python-labs % /usr/bin/python3 /Users/vatarishin/lab_sem_5/python-labs/TEMA1/Pr0.py
|
||||||
|
Hello
|
||||||
|
Your name=Dmitriy
|
||||||
|
```
|
||||||
|
|
||||||
|
Попробовал альтернативный варинат запуска программы
|
||||||
|
```
|
||||||
|
vatarishin@MacBook-Air TEMA1 % python3 Pr0.py
|
||||||
|
Hello
|
||||||
|
Your name=Shin
|
||||||
|
```
|
||||||
|
|
||||||
|
Запустил на выполнение файл [prb1.py](prb1.py)
|
||||||
|
```
|
||||||
|
vatarishin@MacBook-Air python-labs % /usr/bin/python3 /Users/vatarishin/lab_sem_5/python-labs/TEMA1/prb1.py
|
||||||
|
Как Вас зовут? Дмитрий
|
||||||
|
Привет, Дмитрий
|
||||||
|
```
|
||||||
|
### 1.3 Изучение справки
|
||||||
|
```
|
||||||
|
help(print)
|
||||||
|
Help on built-in function print in module builtins:
|
||||||
|
|
||||||
|
print(...)
|
||||||
|
print(value, ..., sep=' ', end='\n', file=sys.stdout, flush=False)
|
||||||
|
|
||||||
|
Prints the values to a stream, or to sys.stdout by default.
|
||||||
|
Optional keyword arguments:
|
||||||
|
file: a file-like object (stream); defaults to the current sys.stdout.
|
||||||
|
sep: string inserted between values, default a space.
|
||||||
|
end: string appended after the last value, default a newline.
|
||||||
|
flush: whether to forcibly flush the stream.
|
||||||
|
|
||||||
|
Help on built-in function input in module builtins:
|
||||||
|
```
|
||||||
|
Попробовал вызвать две команды справки на одной строке
|
||||||
|
```
|
||||||
|
help(print); help(input)
|
||||||
|
Help on built-in function print in module builtins:
|
||||||
|
|
||||||
|
print(...)
|
||||||
|
print(value, ..., sep=' ', end='\n', file=sys.stdout, flush=False)
|
||||||
|
|
||||||
|
Prints the values to a stream, or to sys.stdout by default.
|
||||||
|
Optional keyword arguments:
|
||||||
|
file: a file-like object (stream); defaults to the current sys.stdout.
|
||||||
|
sep: string inserted between values, default a space.
|
||||||
|
end: string appended after the last value, default a newline.
|
||||||
|
flush: whether to forcibly flush the stream.
|
||||||
|
|
||||||
|
Help on built-in function input in module builtins:
|
||||||
|
|
||||||
|
input(prompt=None, /)
|
||||||
|
Read a string from standard input. The trailing newline is stripped.
|
||||||
|
|
||||||
|
The prompt string, if given, is printed to standard output without a
|
||||||
|
trailing newline before reading input.
|
||||||
|
|
||||||
|
If the user hits EOF (*nix: Ctrl-D, Windows: Ctrl-Z+Return), raise EOFError.
|
||||||
|
On *nix systems, readline is used if available.
|
||||||
|
```
|
||||||
|
|
||||||
|
### 1.4 Изучение примеров
|
||||||
|
Запустил файл [tdemo_chaos.py](tdemo_chaos.py)
|
||||||
|
|
||||||
|
Открылось окно GUI, где в случайном порядке рисуются точки, соедененные линиями
|
@ -0,0 +1,22 @@
|
|||||||
|
# Индивидуальное контрольное задание по теме 1
|
||||||
|
|
||||||
|
Коваленко Дмитрий, А-01-23
|
||||||
|
|
||||||
|
## Вопрос 8
|
||||||
|
|
||||||
|
Как можно запустить на выполнение программу, исходный код которой находится в тексто-вом файле ABC.txt?
|
||||||
|
|
||||||
|
## Ответ
|
||||||
|
|
||||||
|
Запустить код написанный в .txt файле можно при помощи функции ```exec()```
|
||||||
|
|
||||||
|
Пример файла [ABC.txt](ABC.txt)
|
||||||
|
Способ запуска кода из txt файла приведен в [test.py](test.py)
|
||||||
|
|
||||||
|
Результат выполнения
|
||||||
|
```
|
||||||
|
vatarishin@MacBook-Air python-labs % /Library/Developer/CommandLineTools/usr/bin/python3 /Users/vatarishin/lab_sem_5/python-labs/
|
||||||
|
TEMA1/test.py
|
||||||
|
This line was executed from .txt file!
|
||||||
|
And this is two lines programm
|
||||||
|
```
|
@ -0,0 +1,2 @@
|
|||||||
|
with open('/Users/vatarishin/lab_sem_5/python-labs/TEMA1/ABC.txt', 'r') as textScript:
|
||||||
|
exec(textScript.read())
|
Загрузка…
Ссылка в новой задаче