##Отчёт по теме 1 Огарков Илья, А-03-23 ## 1 Изучение среды IDLE ## 1.1 Настройка текущего каталога ``` u111-05@w10prog-04 MINGW64 ~/Desktop/python-labs (main) $ git remote add upstream http://uit.mpei.ru/git/main/python-labs.git u111-05@w10prog-04 MINGW64 ~/Desktop/python-labs (main) $ git fetch upstream From http://uit.mpei.ru/git/main/python-labs * [new branch] main -> upstream/main u111-05@w10prog-04 MINGW64 ~/Desktop/python-labs (main) $ git stash push No local changes to save u111-05@w10prog-04 MINGW64 ~/Desktop/python-labs (main) $ git rebase upstream/main Current branch main is up to date. u111-05@w10prog-04 MINGW64 ~/Desktop/python-labs (main) $ git stash pop No stash entries found. u111-05@w10prog-04 MINGW64 ~/Desktop/python-labs (main) $ cd .git/ TEMA0/ TEMA3/ TEMA6/ TEMA9/ .gitignore TEMA1/ TEMA4/ TEMA7/ README.md TEMA2/ TEMA5/ TEMA8/ u111-05@w10prog-04 MINGW64 ~/Desktop/python-labs (main) $ cd TEMA1 u111-05@w10prog-04 MINGW64 ~/Desktop/python-labs/TEMA1 (main) $ touch report.md u111-05@w10prog-04 MINGW64 ~/Desktop/python-labs/TEMA1 (main) $ git status On branch main Your branch is up to date with 'origin/main'. Untracked files: (use "git add ..." to include in what will be committed) report.md nothing added to commit but untracked files present (use "git add" to track) u111-05@w10prog-04 MINGW64 ~/Desktop/python-labs/TEMA1 (main) $ git add report.md u111-05@w10prog-04 MINGW64 ~/Desktop/python-labs/TEMA1 (main) $ git status On branch main Your branch is up to date with 'origin/main'. Changes to be committed: (use "git restore --staged ..." to unstage) new file: report.md u111-05@w10prog-04 MINGW64 ~/Desktop/python-labs/TEMA1 (main) $ git commit -m "first commit" [main 502c4c5] first commit Committer: Пользователь № 5 аудитории Ж-111 Your name and email address were configured automatically based on your username and hostname. Please check that they are accurate. You can suppress this message by setting them explicitly. Run the following command and follow the instructions in your editor to edit your configuration file: git config --global --edit After doing this, you may fix the identity used for this commit with: git commit --amend --reset-author 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 TEMA1/report.md u111-05@w10prog-04 MINGW64 ~/Desktop/python-labs/TEMA1 (main) $ git push Enumerating objects: 6, done. Counting objects: 100% (6/6), done. Delta compression using up to 4 threads Compressing objects: 100% (3/3), done. Writing objects: 100% (4/4), 429 bytes | 429.00 KiB/s, done. Total 4 (delta 1), reused 1 (delta 0), pack-reused 0 remote: remote: Create a new pull request for 'OgarkovIA:main': remote: http://uit.mpei.ru/git/main/python-labs/compare/main...OgarkovIA:main remote: remote: . Processing 1 references remote: Processed 1 references in total To http://uit.mpei.ru/git/OgarkovIA/python-labs.git 437460a..502c4c5 main -> main ``` ## 1.3-8 ```python >>> print('Hello') Hello >>> h=input('Your name=') Your name=Ilya >>>exit() ``` ## 1.9 Изучите предложения главного меню ![Скриншот диалога открытия файла](9.png) ## 1.10 ```python #Программа по Теме 1 Огарков Илья Александрович print('Hello') h=input('Your name=') import os os.chdir('\\Users\\u111-05\\Desktop\\python-labs\\TEMA1') ``` ## 1.11 ```python import prb1 Hello Your name= ``` ## 1.13 ```python # Протокол по Теме 1 Огарков Илья Александрович import os os.chdir('\\Users\\u111-05\\Desktop\\python-labs\\TEMA1') import prb1 ``` # 1.14 ```python 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(input) 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. ``` ## 1.15 ```python # 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() ``` ```python #!/usr/bin/env python3 # -*- coding: cp1252 -*- """ turtle-example-suite: tdemo_clock.py Enhanced clock-program, showing date and time ------------------------------------ Press STOP to exit the program! ------------------------------------ """ from turtle import * from datetime import datetime def jump(distanz, winkel=0): penup() right(winkel) forward(distanz) left(winkel) pendown() def hand(laenge, spitze): fd(laenge*1.15) rt(90) fd(spitze/2.0) lt(120) fd(spitze) lt(120) fd(spitze) lt(120) fd(spitze/2.0) def make_hand_shape(name, laenge, spitze): reset() jump(-laenge*0.15) begin_poly() hand(laenge, spitze) end_poly() hand_form = get_poly() register_shape(name, hand_form) def clockface(radius): reset() pensize(7) for i in range(60): jump(radius) if i % 5 == 0: fd(25) jump(-radius-25) else: dot(3) jump(-radius) rt(6) def setup(): global second_hand, minute_hand, hour_hand, writer mode("logo") make_hand_shape("second_hand", 125, 25) make_hand_shape("minute_hand", 130, 25) make_hand_shape("hour_hand", 90, 25) clockface(160) second_hand = Turtle() second_hand.shape("second_hand") second_hand.color("gray20", "gray80") minute_hand = Turtle() minute_hand.shape("minute_hand") minute_hand.color("blue1", "red1") hour_hand = Turtle() hour_hand.shape("hour_hand") hour_hand.color("blue3", "red3") for hand in second_hand, minute_hand, hour_hand: hand.resizemode("user") hand.shapesize(1, 1, 3) hand.speed(0) ht() writer = Turtle() #writer.mode("logo") writer.ht() writer.pu() writer.bk(85) def wochentag(t): wochentag = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"] return wochentag[t.weekday()] def datum(z): monat = ["Jan.", "Feb.", "Mar.", "Apr.", "May", "June", "July", "Aug.", "Sep.", "Oct.", "Nov.", "Dec."] j = z.year m = monat[z.month - 1] t = z.day return "%s %d %d" % (m, t, j) def tick(): t = datetime.today() sekunde = t.second + t.microsecond*0.000001 minute = t.minute + sekunde/60.0 stunde = t.hour + minute/60.0 try: tracer(False) # Terminator can occur here writer.clear() writer.home() writer.forward(65) writer.write(wochentag(t), align="center", font=("Courier", 14, "bold")) writer.back(150) writer.write(datum(t), align="center", font=("Courier", 14, "bold")) writer.forward(85) second_hand.setheading(6*sekunde) # or here minute_hand.setheading(6*minute) hour_hand.setheading(30*stunde) tracer(True) ontimer(tick, 100) except Terminator: pass # turtledemo user pressed STOP def main(): tracer(False) setup() tracer(True) tick() return "EVENTLOOP" if __name__ == "__main__": mode("logo") msg = main() print(msg) mainloop() ``` ## Фото часов Описание