Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

174 строки
4.6 KiB
Markdown

This file contains invisible Unicode characters!

This file contains invisible Unicode characters that may be processed differently from what appears below. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to reveal hidden characters.

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

# Отчет по теме 1
Бережков Дмитрий, А-01-23
## Изучение среды IDLE
```py
>>> print('Hello')
Hello
>>> h=input('Your name=')
Your name=Dima
>>>print(h)
Dima
>>> exit()
```
## Настройки рабочего каталога среды
```py
>>> import os
>>> os.chdir('C:\\MPEI\\PO_ASY\\BerezhkovGit\\python-labs\\TEMA1')
```
## Файл Pr0.py
Содержимое файла:
```py
print('Hello')
h=input('Your name=')
print(h)
import os
os.chdir('C:\\MPEI\\PO_ASY\\BerezhkovGit\\python-labs\\TEMA1')
```
Результат выполнения программы:
```py
>>>
=================== RESTART: C:\MPEI\PO_ASY\BerezhkovGit\python-labs\TEMA1\Pr0.py ==================
Hello
Your name=Dima
Dima
```
Альтернативный способ запуска программы на исполнение:
```py
>>> import Pr0
Hello
Your name=Dima
Dima
```
## Файл Prb1.py
Содержимое файла:
```py
name = input("Как Вас зовут? ")
print("Привет,", name)
```
Результат выполнения программы:
```py
================== RESTART: C:\MPEI\PO_ASY\BerezhkovGit\python-labs\TEMA1\prb1.py ==================
Как Вас зовут? Dima
Привет, Dima
```## __pycache__ и содержимое файла Pr0.cpython-34.pyc
Содержимое файла:
```py
у
Гh г  у` \ " S 5 \" S5 r\ " \5 SSKr\R " S5 g)ЪHelloz
Your name=й Nz-C:\MPEI\PO_ASY\BerezhkovGit\python-labs\TEMA1)ЪprintЪinputЪosЪchdir© у Ъ4C:\MPEI\PO_ASY\BerezhkovGit\python-labs\TEMA1\Pr0.pyЪ<module>r  s- рб ЂgЩ УЂЩ ЂaЫ Ш Р =Х >r
```
В папке __pycache__ хранится скомпилированный двоичный код, который нужен для оптимизации
## Раздел помощи(help)
```py
>>> 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.
```
```py
>>> 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.
```
## Файл tdemo_chaos.py
Содержание файла:
```py
# 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()
```
Результат выполнения программы:
<image src="chaos.png">
## Работа модуля Turtle, пример clock
<image src="clock.png">