Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
lehrkraefte:blc:informatik:glf22:python:graphics [2022/11/17 10:04] Ivo Blöchliger [Linien] |
lehrkraefte:blc:informatik:glf22:python:graphics [2022/11/25 08:09] (current) Ivo Blöchliger [Sinus/Cosinus] |
||
---|---|---|---|
Line 78: | Line 78: | ||
</ | </ | ||
- | ===== Sinus/Cosinus ===== | + | ===== Cosinus/ |
Testen und Verstehen Sie folgendes Programm: | Testen und Verstehen Sie folgendes Programm: | ||
Line 122: | Line 122: | ||
<WRAP todo> | <WRAP todo> | ||
- | Bauen Sie die Funktion '' | + | Bauen Sie die Funktion '' |
<hidden Lösungsvorschlag> | <hidden Lösungsvorschlag> | ||
+ | <code python> | ||
from graphics import * | from graphics import * | ||
from math import cos,sin,pi | from math import cos,sin,pi | ||
Line 147: | Line 148: | ||
win.getMouse() # Pause to view result | win.getMouse() # Pause to view result | ||
win.close() | win.close() | ||
+ | </ | ||
</ | </ | ||
</ | </ | ||
Line 237: | Line 239: | ||
</ | </ | ||
+ | ===== Weitere Aufgaben ===== | ||
+ | Programmieren Sie ein Programm, das folgende Bilder erzeugt: | ||
+ | {{: | ||
+ | {{: | ||
+ | |||
+ | <hidden Lösungsvorschlag> | ||
+ | <code python> | ||
+ | from graphics import * | ||
+ | from math import cos,sin,pi | ||
+ | |||
+ | win = GraphWin(" | ||
+ | |||
+ | |||
+ | def huellkurve(): | ||
+ | win.setCoords(-0.1, | ||
+ | n=50 | ||
+ | for i in range(n+1): | ||
+ | x = i/n | ||
+ | Line(Point(x, | ||
+ | |||
+ | def spirale(): | ||
+ | win.setCoords(-1.1, | ||
+ | umdrehungen = 5 | ||
+ | schritte = 400; | ||
+ | for i in range(schritte): | ||
+ | winkel = i/ | ||
+ | winkel2 = (i+1)/ | ||
+ | radius = i/schritte; | ||
+ | Line(Point(radius*cos(winkel), | ||
+ | |||
+ | |||
+ | |||
+ | def clickAndWait(titel=" | ||
+ | global win # Damit kann die Variable win auch verändert werden | ||
+ | win.getMouse() # Pause to view result | ||
+ | win.close() | ||
+ | win = GraphWin(titel, | ||
+ | |||
+ | |||
+ | huellkurve() | ||
+ | clickAndWait(" | ||
+ | spirale() | ||
+ | |||
+ | win.getMouse() # Pause to view result | ||
+ | |||
+ | win.close() | ||
+ | </ | ||
+ | </ | ||
====== Setup ====== | ====== Setup ====== | ||
Es gibt einen Screencast: [[https:// | Es gibt einen Screencast: [[https:// | ||
+ | |||
+ | ===== Windows ===== | ||
Auf der Kommandozeile (git-bash) egal in welchem Ordner: | Auf der Kommandozeile (git-bash) egal in welchem Ordner: | ||
Line 244: | Line 296: | ||
pip install graphics.py | pip install graphics.py | ||
</ | </ | ||
+ | ===== Linux/Mac ===== | ||
+ | <code bash> | ||
+ | sudo pip3 install tk graphics.py | ||
+ | </ | ||
+ | |||
+ | ===== Alle Systeme ===== | ||
- | Unter Linux/Mac ist '' | ||
Gehen Sie in einen geeigneten Ordner (wo Ihre eigenen Dateien fürs Programmieren liegen) und öffnen Sie dort den Ordner mit VisualCode: | Gehen Sie in einen geeigneten Ordner (wo Ihre eigenen Dateien fürs Programmieren liegen) und öffnen Sie dort den Ordner mit VisualCode: | ||
Line 267: | Line 324: | ||
</ | </ | ||
- | Sollte dieser Code noch nicht funktionieren (Linux/ | ||
- | <code bash> | ||
- | pip3 install tk | ||
- | </ |