kicoku:kicokusommer2023
Dies ist eine alte Version des Dokuments!
Inhaltsverzeichnis
KiCoKu Sommer 2023
Python
Installation: Python für Windows
Test der Installation
Eingabe in einen Python Interpreter
>>>1+2+3
6
>>>print("Hallo Du")
Hallo Du
Berechnungen
Eingabe in einen Python Interpreter
>>>1 + 1 2 >>>3 - 2 1 >>>4 * 4 16 >>>8 / 4 2.0 >>>7 / 4 1.75 >>>7 // 4 1 >>>7 % 4 3 >>>4 ** 2 16 >>>8 - 2 * 3 2 >>>( 8 - 2 ) * 3 18
Text Ein und Ausgabe
Eingabe der Python IDLE und Ausführen (mit F5)
# YourName.py
name = input("What is your name?\n")
print("Hi, ", name, name, name, name, name)
Bildschirmausgabe:
What is your name? Wolfgang Hi, Wolfgang Wolfgang Wolfgang Wolfgang Wolfgang
Erstes Ziel Sechs Eckige Spirale
Unser erstes Ziel, eine sechseckige Spirale zeichnen lassen. Dieses Programm zeigt erstmal nur unser erstes Ziel. Das Programm muss so noch nicht verstanden werden.
#NiceHexSpiral.py
import turtle
colors=['red', 'purple', 'blue',
'green', 'yellow', 'orange']
t=turtle.Pen()
t.speed(0)
turtle.bgcolor('black')
for x in range(360):
t.pencolor(colors[x%6])
t.width(x/100+1)
t.forward(x)
t.left(59)
Zeichnen von Dreieck und Viereck
#Viereck.py
import turtle
t=turtle.Pen()
#Erstes Viereck
t.forward(200)
t.left(90)
t.forward(200)
t.left(90)
t.forward(200)
t.left(90)
t.forward(200)
t.left(90)
#Zweites Viereck in rot
t.pencolor("red")
for x in range(4):
t.forward(100)
t.left(90)
#Und ein Dreieck in grün
t.pencolor("green")
for x in range(3):
t.forward(300)
t.left(120)
kicoku/kicokusommer2023.1691825122.txt.gz · Zuletzt geändert: 2023/08/12 09:25 von newo


