byvs 1 неделю назад
Родитель 437460afc1
Сommit e549fe8e03

@ -0,0 +1,5 @@
#Программа по Теме 1 Степанищев Виктор Романович
print('Hello')
h=input('Your name=')
import os
os.chdir(r"/home/byvs/MPEI/Programming Python/Stepanishchev/TEMA1/")

Двоичные данные
figure0.png

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 18 KiB

Двоичные данные
figure1.png

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 14 KiB

@ -0,0 +1,2 @@
name = input("Как Вас зовут? ")
print("Привет,", name)

@ -0,0 +1,96 @@
#Отчёт по теме 1
Степанищев Виктор, А-03-23
## 1 Знакомство с интерпретатором
Введение инструкций в окно интерпретатора
```
>>>print('Hello')
Hello
>>>h=input('Your name=')
Your name=Viktor
>>>exit()
```
## 2 Знакомство с интерактивной оболочкой IDLE
Настройка текущего каталога
```
import os
os.chdir(r"/home/byvs/MPEI/Programming Python/python-labs/TEMA1/")
```
Создание Pr0.py в рабочем каталоге и его запуск тремя способами: import Pr0, F5, 'Запустить модуль'
```
#Программа по Теме 1 Степанищев Виктор Романович
print('Hello')
h=input('Your name=')
import os
os.chdir(r"/home/byvs/MPEI/Programming Python/Stepanishchev/TEMA1/")
```
Запуск prb1.py
```
>>> import prb1
Как Вас зовут? Viktor
Привет, Viktor
```
В папке _pycache_ хранится двоичный скомпилированный код, который нужен для оптимизации загрузки и запуска программы
Раздел помощи help в главном меню IDLE предлагает следующие виды помощи: документацию по IDLE, доку по Python
и наглядную демонстрацию работы модуля Turtle
```
>>>help(print)
Help on built-in function print in module builtins:
print(*args, sep=' ', end='\n', file=None, flush=False)
Prints the values to a stream, or to sys.stdout by default.
sep
string inserted between values, default a space.
end
string appended after the last value, default a newline.
file
a file-like object (stream); defaults to the current sys.stdout.
flush
whether to forcibly flush the stream.
>>>help(print), help(input)
Help on built-in function print in module builtins:
print(*args, sep=' ', end='\n', file=None, flush=False)
Prints the values to a stream, or to sys.stdout by default.
sep
string inserted between values, default a space.
end
string appended after the last value, default a newline.
file
a file-like object (stream); defaults to the current sys.stdout.
flush
whether to forcibly flush the stream.
Help on built-in function input in module builtins:
input(prompt='', /)
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.
(None, None)
```
Результат работы программы tdemo_chaos.py :
<image src="figure0.png">
Демонстрация работы модуля Turtle на примере clock из Turtle Demo в выпадающем меню help:
<image src="figure1.png">

@ -0,0 +1,59 @@
# File: tdemo_chaos.py
# Author: Gregor Lingl
# Date: 2009-06-24
# A demonstration of chaos
from turtle import *
N = 80
def f(x):
return 3.9*x*(1-x)
def g(x):
return 3.9*(x-x**2)
def h(x):
return 3.9*x-3.9*x*x
def jumpto(x, y):
penup(); goto(x,y)
def line(x1, y1, x2, y2):
jumpto(x1, y1)
pendown()
goto(x2, y2)
def coosys():
line(-1, 0, N+1, 0)
line(0, -0.1, 0, 1.1)
def plot(fun, start, color):
pencolor(color)
x = start
jumpto(0, x)
pendown()
dot(5)
for i in range(N):
x=fun(x)
goto(i+1,x)
dot(5)
def main():
reset()
setworldcoordinates(-1.0,-0.1, N+1, 1.1)
speed(0)
hideturtle()
coosys()
plot(f, 0.35, "blue")
plot(g, 0.35, "green")
plot(h, 0.35, "red")
# Now zoom in:
for s in range(100):
setworldcoordinates(0.5*s,-0.1, N+1, 1.1)
return "Done!"
if __name__ == "__main__":
main()
mainloop()
Загрузка…
Отмена
Сохранить