Benutzer-Werkzeuge

Webseiten-Werkzeuge


kicoku:kicokusommer2023

Unterschiede

Hier werden die Unterschiede zwischen zwei Versionen angezeigt.

Link zu dieser Vergleichsansicht

Beide Seiten der vorigen RevisionVorhergehende Überarbeitung
Nächste Überarbeitung
Vorhergehende Überarbeitung
kicoku:kicokusommer2023 [2023/08/14 09:44] – [Textvariablen] newokicoku: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://www.udemy.com/course/teach-your-kids-to-code\\ 
 +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 Abschnitt 1 - Installation und Test =====
  
 Installation: [[https://www.python.org/downloads/windows/|Python für Windows]] Installation: [[https://www.python.org/downloads/windows/|Python für Windows]]
Zeile 52: Zeile 61:
 </code> </code>
  
 +===== 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 256: Zeile 266:
 € 2.4000000000000004 als Trinkgeld. € 2.4000000000000004 als Trinkgeld.
 </code> </code>
-==== Zahlen Variablen ====+==== Wiederholte Zeichenausgabe ==== 
 +Wiederholte Zeichenausgabe 
 +<code> 
 +# SayMyName.py 
 + 
 +# Ask the user for their name 
 +name = input("What is your name? ") 
 + 
 +# 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! ") 
 +</code> 
 +Bildschirmausgabe 
 +<code> 
 +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!  
 +</code> 
 +==== Text zeichnen ==== 
 +Textspirale 
 +<code> 
 +# SpiralMyName.py - prints a colorful spiral of the user's name 
 + 
 +import turtle               # Set up turtle graphics 
 +t = turtle.Pen() 
 +t.speed(0) 
 +turtle.bgcolor("black"
 +colors = ["red", "yellow", "blue", "green"
 + 
 +# Ask the user's name using turtle's textinput pop-up window 
 +your_name = turtle.textinput("Enter your name", "What is your name?"
 + 
 +# 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, font = ("Times", int( (x + 4) / 4), "bold") ) 
 +    t.left(92) 
 +</code> 
 +{{:kicoku:spiralmyname.png?200|}} 
 +==== Taschenrechner ==== 
 +<code> 
 +print("MathHomework.py"
 + 
 +# Ask the user to enter a math problem 
 +problem = input("Enter a math problem, or 'q' to quit: ") 
 + 
 +# Keep going until the user enters 'q' to quit 
 +while (problem != "q"): 
 +     
 +    # Show the problem, and the answer using eval() 
 +    print("The answer to ", problem, "is:", eval(problem) ) 
 +     
 +    # Ask for another math problem 
 +    problem = input("Enter another math problem, or 'q' to quit: ") 
 +     
 +    # This while loop will keep going until you enter 'q' to quit  
 +</code> 
 +Bildschirmausgabe 
 +<code> 
 +MathHomework.py 
 +Enter a math problem, or 'q' to quit: 5 + 2 
 +The answer to  5 + 2 is: 7 
 +Enter another math problem, or 'q' to quit: 5 / 2 
 +The answer to  5 / 2 is: 2.5 
 +Enter another math problem, or 'q' to quit: 5 // 2 
 +The answer to  5 // 2 is: 2 
 +Enter another math problem, or 'q' to quit: 5 % 2 
 +The answer to  5 % 2 is: 1 
 +Enter another math problem, or 'q' to quit: (4 + 2) * (2 + 2) 
 +The answer to  (4 + 2) * (2 + 2) is: 24 
 +Enter another math problem, or 'q' to quit: q 
 +</code> 
 +==== Eingabe für die färbige Spirale ==== 
 +<code> 
 +# ColorSpiralInput.py 
 +import turtle 
 +t = turtle.Pen() 
 +t.speed(0) 
 +turtle.bgcolor("black"
 +# Set up a list of any 8 valid Python color names 
 +colors = ["red", "yellow", "blue", "green", 
 +          "orange", "purple", "white", "gray"
 +# Ask the user for the number of sides 
 +sides = int( turtle.numinput("Number of sides", 
 +                             "How many sides do you want (1-8)?", 4, 1, 8)) 
 +# 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) 
 +</code> 
 +{{:kicoku:inputcolorspiral.png?200|}}
kicoku/kicokusommer2023.1691999041.txt.gz · Zuletzt geändert: 2023/08/14 09:44 von newo