kicoku:kicokusommer2023
Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
| Beide Seiten der vorigen RevisionVorhergehende ÜberarbeitungNächste Überarbeitung | Vorhergehende Überarbeitung | ||
| kicoku:kicokusommer2023 [2023/08/12 10:00] – newo | kicoku:kicokusommer2023 [2023/11/24 19:42] (aktuell) – [KiCoKu Sommer 2023] newo | ||
|---|---|---|---|
| Zeile 1: | Zeile 1: | ||
| - | ====== KiCoKu Sommer 2023 ====== | + | ====== KiCoKu Sommer 2023 ====== |
| - | ===== Python ===== | + | |
| + | Dieser Bereich basiert auf dem Buch "Teach your kids to code" from Bryson Pane und dem folgenden Udemy Kurs | ||
| + | https:// | ||
| + | Dieser Kurs ist zwar auf Englisch, aber sehr leicht zu verstehen. | ||
| + | |||
| + | Dauer: Mo. 28.8 bis Fr. 1.9 | ||
| + | Von 9:00 bis 13:00 | ||
| + | |||
| + | Teilnehmer: Felix G, Markus, Paul, Felix E | ||
| + | ===== Python | ||
| Installation: | Installation: | ||
| Zeile 52: | Zeile 61: | ||
| </ | </ | ||
| + | ===== Python Abschnitt 2 - Zeichnen ===== | ||
| ==== Erstes Ziel Sechs Eckige Spirale ==== | ==== Erstes Ziel Sechs Eckige Spirale ==== | ||
| Unser erstes Ziel, eine sechseckige Spirale zeichnen lassen. | Unser erstes Ziel, eine sechseckige Spirale zeichnen lassen. | ||
| Zeile 103: | Zeile 113: | ||
| Bei einer Schleife muss eine Einrückung gemacht werden | Bei einer Schleife muss eine Einrückung gemacht werden | ||
| < | < | ||
| - | # SquareSpiral3.py | + | # ViereckigeSpirale.py |
| import turtle | import turtle | ||
| # Verwendung des Stifts von der turtle Library | # Verwendung des Stifts von der turtle Library | ||
| Zeile 117: | Zeile 127: | ||
| === Aufgaben === | === Aufgaben === | ||
| Beschleunigen des Skripts, einfuegen der Geschwindigkeit (nach turtle.Pen)\\ | Beschleunigen des Skripts, einfuegen der Geschwindigkeit (nach turtle.Pen)\\ | ||
| - | t.speed(0)\\ | + | < |
| Ändern der Spirale\\ | Ändern der Spirale\\ | ||
| Ändern des Abstands\\ | Ändern des Abstands\\ | ||
| t.forward(2*x)\\ | t.forward(2*x)\\ | ||
| Ändern der Farbe\\ | Ändern der Farbe\\ | ||
| - | t.pencolor(" | + | < |
| Ändern der Lage\\ | Ändern der Lage\\ | ||
| t.left(91) | t.left(91) | ||
| + | {{: | ||
| + | ==== Kreise ==== | ||
| + | < | ||
| + | # KreisSpirale.py | ||
| + | import turtle | ||
| + | # Verwendung des Stifts von der turtle Library | ||
| + | t = turtle.Pen() | ||
| + | t.speed(0) | ||
| + | t.pencolor(" | ||
| + | # Mit der Schleife wird die Spirale gezeichnet | ||
| + | # x ist die Schleifenvariable, | ||
| + | for x in range(100): | ||
| + | # Zeichnen der Linie | ||
| + | t.circle(x) | ||
| + | # Drehen um 90 Grad | ||
| + | t.left(91) | ||
| + | </ | ||
| + | {{: | ||
| + | Ändern auf 90 und dann auf 60 Grad\\ | ||
| + | Ändern der Farben auf andere Werte\\ | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | ==== Verschiedene Farben ==== | ||
| + | < | ||
| + | # FaerbigeViereckigeSpirale.py | ||
| + | import turtle | ||
| + | t = turtle.Pen() | ||
| + | t.speed(0) | ||
| + | # Eine Liste von Farben | ||
| + | colors = [" | ||
| + | for x in range(100): | ||
| + | t.pencolor(colors[ x % 4 ]) | ||
| + | t.forward(2*x) | ||
| + | t.left(91) | ||
| + | </ | ||
| + | {{: | ||
| + | === Aufgaben === | ||
| + | Was passiert wenn die Farben geändert werden?\\ | ||
| + | Was passiert wenn die Zahl 4 geändert wird?\\ | ||
| + | Wie kann die Hintergrundfarbe geändert werden?\\ | ||
| + | Wie können Kreise gezeichnet werden?\\ | ||
| + | Was passiert wenn der Winkel von 91 auf 95 erhöht wird? | ||
| + | |||
| + | === Weitere Änderungen === | ||
| + | Verwendung einer Variable\\ | ||
| + | Mehr Farben\\ | ||
| + | Andere Berechnungen\\ | ||
| + | Eine zusätzliche Drehung am Ende | ||
| + | < | ||
| + | # FaerbigeViereckigeSpirale2.py | ||
| + | import turtle | ||
| + | t = turtle.Pen() | ||
| + | turtle.bgcolor(" | ||
| + | t.speed(0) | ||
| + | # Eine Liste von Farben | ||
| + | sides = 10 | ||
| + | colors = [" | ||
| + | " | ||
| + | for x in range(360): | ||
| + | t.pencolor(colors[ x % sides ]) | ||
| + | t.forward(x * 3 / sides + x) | ||
| + | t.left(360/ | ||
| + | t.width(x*sides/ | ||
| + | t.left(90) | ||
| + | </ | ||
| + | {{: | ||
| + | ===== Python Abschnitt 3 - Variablen ===== | ||
| + | ==== Textvariablen ==== | ||
| + | Ein Beispiel mit Textvariablen | ||
| + | < | ||
| + | # ThankYou.py | ||
| + | my_name = " | ||
| + | my_age = 43 | ||
| + | your_name = input(" | ||
| + | your_age = input(" | ||
| + | print(" | ||
| + | print(" | ||
| + | print(" | ||
| + | </ | ||
| + | Bildschirmausgabe | ||
| + | < | ||
| + | What is your name? Wolfgang | ||
| + | How old are you? 52 | ||
| + | My name is Bryson , and I am 43 years old. | ||
| + | Your name is Wolfgang , and you are 52 . | ||
| + | Thank you for taking this course, Wolfgang ! | ||
| + | </ | ||
| + | ==== Zahlen Variablen ==== | ||
| + | Beispiel Berechnung einer Pizzabestellung | ||
| + | < | ||
| + | #Pizza.py | ||
| + | |||
| + | # Ask the person how many pizzas they want, get the number with eval() | ||
| + | number_of_pizzas = eval(input(" | ||
| + | |||
| + | # Ask for the menu cost of each pizza | ||
| + | cost_per_pizza = eval(input(" | ||
| + | |||
| + | # Calculate the total cost of the pizzas as our subtotal | ||
| + | subtotal = number_of_pizzas * cost_per_pizza | ||
| + | |||
| + | # Wir geben 10% Trinkgeld | ||
| + | tip_rate = 0.1 # Store 10% as the decimal value 0.1 | ||
| + | trinkgeld = subtotal * tip_rate | ||
| + | |||
| + | # Add the sales tax to the subtotal for the final total | ||
| + | total = subtotal + trinkgeld | ||
| + | |||
| + | # Show the user the total amount due, including tax | ||
| + | print(" | ||
| + | print(" | ||
| + | print(" | ||
| + | </ | ||
| + | Bildschirmausgabe | ||
| + | < | ||
| + | How many pizzas do you want? 3 | ||
| + | How much does each pizza cost? 8 | ||
| + | The total cost is € 26.4 | ||
| + | This includes € 24 for the pizza and | ||
| + | € 2.4000000000000004 als Trinkgeld. | ||
| + | </ | ||
| + | ==== Wiederholte Zeichenausgabe ==== | ||
| + | Wiederholte Zeichenausgabe | ||
| + | < | ||
| + | # SayMyName.py | ||
| + | |||
| + | # Ask the user for their name | ||
| + | name = input(" | ||
| + | |||
| + | # Print their name 100 times | ||
| + | for x in range(100): | ||
| + | | ||
| + | # Print their name followed by a space, not a new line | ||
| + | print(name, end = " rules! ") | ||
| + | </ | ||
| + | Bildschirmausgabe | ||
| + | < | ||
| + | What is your name? Wolfgang | ||
| + | Wolfgang rules! Wolfgang rules! Wolfgang rules! Wolfgang rules! Wolfgang rules! Wolfgang rules! Wolfgang rules! | ||
| + | Wolfgang rules! Wolfgang rules! Wolfgang rules! Wolfgang rules! Wolfgang rules! Wolfgang rules! Wolfgang rules! | ||
| + | Wolfgang rules! Wolfgang rules! Wolfgang rules! Wolfgang rules! Wolfgang rules! Wolfgang rules! Wolfgang rules! | ||
| + | Wolfgang rules! Wolfgang rules! Wolfgang rules! Wolfgang rules! Wolfgang rules! Wolfgang rules! Wolfgang rules! | ||
| + | Wolfgang rules! Wolfgang rules! Wolfgang rules! Wolfgang rules! Wolfgang rules! Wolfgang rules! Wolfgang rules! | ||
| + | Wolfgang rules! Wolfgang rules! Wolfgang rules! Wolfgang rules! Wolfgang rules! Wolfgang rules! Wolfgang rules! | ||
| + | Wolfgang rules! Wolfgang rules! Wolfgang rules! Wolfgang rules! Wolfgang rules! Wolfgang rules! Wolfgang rules! | ||
| + | Wolfgang rules! Wolfgang rules! Wolfgang rules! Wolfgang rules! Wolfgang rules! Wolfgang rules! Wolfgang rules! | ||
| + | Wolfgang rules! Wolfgang rules! Wolfgang rules! Wolfgang rules! Wolfgang rules! Wolfgang rules! Wolfgang rules! | ||
| + | Wolfgang rules! Wolfgang rules! Wolfgang rules! Wolfgang rules! Wolfgang rules! Wolfgang rules! Wolfgang rules! | ||
| + | Wolfgang rules! Wolfgang rules! Wolfgang rules! Wolfgang rules! Wolfgang rules! Wolfgang rules! Wolfgang rules! | ||
| + | Wolfgang rules! Wolfgang rules! Wolfgang rules! Wolfgang rules! Wolfgang rules! Wolfgang rules! Wolfgang rules! | ||
| + | Wolfgang rules! Wolfgang rules! Wolfgang rules! Wolfgang rules! Wolfgang rules! Wolfgang rules! Wolfgang rules! | ||
| + | Wolfgang rules! Wolfgang rules! Wolfgang rules! Wolfgang rules! Wolfgang rules! Wolfgang rules! Wolfgang rules! | ||
| + | Wolfgang rules! Wolfgang rules! | ||
| + | </ | ||
| + | ==== Text zeichnen ==== | ||
| + | Textspirale | ||
| + | < | ||
| + | # SpiralMyName.py - prints a colorful spiral of the user's name | ||
| + | |||
| + | import turtle | ||
| + | t = turtle.Pen() | ||
| + | t.speed(0) | ||
| + | turtle.bgcolor(" | ||
| + | colors = [" | ||
| + | |||
| + | # Ask the user's name using turtle' | ||
| + | your_name = turtle.textinput(" | ||
| + | |||
| + | # Draw a spiral of the name on the screen, written 100 times | ||
| + | for x in range(100): | ||
| + | t.pencolor( colors[ x % 4] ) | ||
| + | t.penup() | ||
| + | t.forward( x * 4 ) | ||
| + | t.pendown() | ||
| + | t.write(your_name, | ||
| + | t.left(92) | ||
| + | </ | ||
| + | {{: | ||
| + | ==== Taschenrechner ==== | ||
| + | < | ||
| + | print(" | ||
| + | |||
| + | # Ask the user to enter a math problem | ||
| + | problem = input(" | ||
| + | |||
| + | # Keep going until the user enters ' | ||
| + | while (problem != " | ||
| + | | ||
| + | # Show the problem, and the answer using eval() | ||
| + | print(" | ||
| + | | ||
| + | # Ask for another math problem | ||
| + | problem = input(" | ||
| + | | ||
| + | # This while loop will keep going until you enter ' | ||
| + | </ | ||
| + | Bildschirmausgabe | ||
| + | < | ||
| + | MathHomework.py | ||
| + | Enter a math problem, or ' | ||
| + | The answer to 5 + 2 is: 7 | ||
| + | Enter another math problem, or ' | ||
| + | The answer to 5 / 2 is: 2.5 | ||
| + | Enter another math problem, or ' | ||
| + | The answer to 5 // 2 is: 2 | ||
| + | Enter another math problem, or ' | ||
| + | The answer to 5 % 2 is: 1 | ||
| + | Enter another math problem, or ' | ||
| + | The answer to (4 + 2) * (2 + 2) is: 24 | ||
| + | Enter another math problem, or ' | ||
| + | </ | ||
| + | ==== Eingabe für die färbige Spirale ==== | ||
| + | < | ||
| + | # ColorSpiralInput.py | ||
| + | import turtle | ||
| + | t = turtle.Pen() | ||
| + | t.speed(0) | ||
| + | turtle.bgcolor(" | ||
| + | # Set up a list of any 8 valid Python color names | ||
| + | colors = [" | ||
| + | " | ||
| + | # Ask the user for the number of sides | ||
| + | sides = int( turtle.numinput(" | ||
| + | " | ||
| + | # Draw a colorful spiral with the user-specified number of sides | ||
| + | for x in range(360): | ||
| + | t.pencolor( colors[x % sides] ) | ||
| + | t.forward( x * 3 / sides + x) | ||
| + | t.left(360 / sides + 1) | ||
| + | t.width(x * sides / 200) | ||
| + | </ | ||
| + | {{: | ||
kicoku/kicokusommer2023.1691827238.txt.gz · Zuletzt geändert: 2023/08/12 10:00 von newo
