форкнуто от main/python-labs
Вы не можете выбрать более 25 тем
Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
3.5 KiB
3.5 KiB
Отчёт по лабораторной работе №1
Криштул Александр, А-03-23
Знакомство с программой-интерпретатором
>>> print('Hello!')
Hello!
>>> h=input('Your name: ')
Your name: Alexander
>>> print(h)
Alexander
>>> exit()
Инструкции настройки рабочего каталога среды
>>> import os
>>> os.chdir('C:\\Users\\User\\Desktop\\LR\\python-labs\\TEMA1')
>>> os.getcwd()
'C:\\Users\\User\\Desktop\\LR\\python-labs\\TEMA1'
pr0.py
Содержимое файла:
print('Hello!')
h=input('Your name: ')
print(h)
Результат выполнения программы:
>>>
========== RESTART: C:\Users\User\Desktop\LR\python-labs\TEMA1\pr0.py ==========
Hello!
Your name: Alex
Alex
prb1.py
Содержимое файла:
name = input("Как Вас зовут? ")
print("Привет,", name)
Результат выполнения программы:
>>>
= RESTART: C:\Users\User\Desktop\LR\python-labs\TEMA1\prb1.py
Как Вас зовут? Alexander
Привет, Alexander
pycache и содержимое файла Pr0.cpython-34.pyc
Содержимое файла:
a
–‘µhr г @ s& e d ѓ edѓZddlZe dЎ dS )zHello!zYour name: й Nz*C:\Users\User\Desktop\LR\python-labs\TEMA1)ЪprintЪinputЪhЪosЪchdir© r r ъ1C:\Users\User\Desktop\LR\python-labs\TEMA1\pr0.pyЪ<module> s
В папке pycache хранится скомпилированный двоичный код, который нужен ля оптимизации загрузки и запуска программы.
Раздел помощи (Help)
>>> 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(input)
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.
Файл tdemo_chaos.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)
Результат выполнение программы:
Демонстрация работы модуля Turtle на примере Clock
