SlideShare uma empresa Scribd logo
1 de 23
Baixar para ler offline
Wie fange ich mit dem Programmieren an?
Jugend hackt, 9.7.2015
Hubert Hesse (@hubx)
Vom Problem zum Programm
● Eingabe/Ausgabe (Spezifikation)
● Vereinfachen
○ “Ich will ein Antivirus implementieren”
■ Dateien erkennen die “AAAA” enthalten
■ Was passiert wenn AAAA verschleiert ist
● Unterprobleme/”Teile-Und-Herrsche”
○ Computer fernsteuern
■ Bildschirm aufnehmen, alle 5s, versenden
■ Verbindung aufbauen
■ Tastenanschläge weiterleiten
● Ziel: Quelltext schreiben und ausführen können
● Editor: z.B: Sublime (http://www.sublimetext.com/)
● Compiler (Quelltext -> Ausführbaren Datei)
● Interpreter (Anweisungen beim Programmstart übersetzen)
● Wie kann ich das Programm starten?
Hello World Installiere Voraussetzungen<
>>> print("Hello world")
Hello World!
public class HelloWorld
{
public static void main (String[] args)
{
System.out.println("Hello World!");
}
}
C++/Java: Keine gute EinstiegssprachePython
Variablen
>>> (1 + 4) * 2
10
>>> x = 1
>>> x
1
>>> x = x + 4
>>> x *= 2
>>> x
10
a = int(input(“Seitenlänge?”))
A = a * a
u = 4 * a
print (“Fläche:”, A)
print (“Umfang:”, u)
● Veränderbarer Platzhalter für Werte
● Adresse im Speicher
Typen (10 == “10”)?
Funktionen (parameter)
def bereche_flaeche(a)
return a * a
def berechne_umfang(a)
return 4 * a
a = int(input(“Seitenlänge?”))
print (“Fläche:”, berechne_flaeche(a))
print (“Umfang:”, bereche_umfang(a))
● In Teilprobleme zerlegen, auf eine Sache konzentrieren
● Quelltextabschnitte benennen, wiederverwenden
int bereche_flaeche(int a)
{
return a*a
}
C++/Java: Klammern statt Einrückung
Funktionen II
def bereche_flaeche(a)
return a * a
def berechne_umfang(a)
return 4 * a
a = int(input(“Seitenlänge?”))
print (“Fläche:”, berechne_flaeche(a))
print (“Umfang:”, bereche_umfang(a))
print (“Doppelte Seitenfläche => Fläche:”, berechne_flaeche(2 * a))
print (“Doppelte Seitenfläche => Umfang:”, bereche_umfang(2 * a))
● Wiederverwendung von Code mit Funktionen möglich
Eingebaute Funktionen
mein_string = “ ICH bIn Groß ”
print(mein_string.strip().lower())
# ”ich bin groß” <- Kommentar
● Vorher schauen ob Funktion schon mit der
Standardbibliothek mitkommen
Schleifen
Wiederholen von Anweisungen
namen = “Alex,Trevor,Alice”.split(“,”)
for name in namen:
print(“Willkommen “ + name)
total = 0
for i in 1, 1, 2, 3, 5, 7, 11, 13:
print(i)
total += i
print(total) #43
Verzweigungen if-Ausdrücke
def rechner(a, b, op):
if op == "+":
return a + b
elif op == "-":
return a - b
else:
return a
total = 0
while True:
op = input("+/-?")
i = int(input("i?"))
total = rechner(total, i, op)
print (total)
● Testen von Variablen auf
Inhalte
○ <,>, ==, (i % 2 == 0)
○ str.endswith(),str.islower()
● Wahrheitswert (Boolean)
○ True, False
Listen
def quadriere(liste):
b = []
for a in liste:
b.append(a*a)
return b
quadriere([1, 2, 3, 4, 5])
liste = [0,1,2,3,4,5]
b = [a*a for a in liste] # Kürzere Schreibweise: List comprehension
b[5] # Direkter Zugriff auf das 6. Element = 25
(Zwischen-)ergebnisse aufsammeln
Lerntipps
● Selber tippen trainiert Muskelgedächtnis
● Mit Freunden programmieren
● Hilfe suchen (online/offline)
● Spaß
OpenTechSchool Konzepte ausführlicher https:
//opentechschool.github.io/python-beginners/de/index.html
CodeCombat
Mulltiplayer Programmierspiel (http://codecombat.com/)
“Die Programmierstunde”
https://code.org/learnhttp://lightbot.com/
Let’s Code - Programmiervideos
Java für Einsteiger - https://open.hpi.de/courses/javaeinstieg2015
Python - https://open.hpi.de/courses/pythonjunior2014
khanacademy.org: Zeichnen mit JavaScript
https://de.khanacademy.org/video?lang=de&format=lite&v=h25CyONlPdM
Youtube: Android Apps programmieren (JaDaHB1)
https://www.youtube.com/playlist?list=PL13I0cBsOJUc0OTlv09DG7_m2T0Si0Wbx
Projektideen
● Text: Wörter zählen, Palindrom-Check, Cäsar-
Chiffre/Enigma
● Datei/Netzwerk: Verzeichnis auflisten, Datei
erkennen/ablehnen, Passwort-Check, Webserver der
immer die gleiche Webseite ausliefert
● Spiele: Hangman, Pong
Programmieren lernen - Communities
OpenTechSchool:
http://learn.opentechschool.org/ (D/Eng...)
Coder Dojos:
https://zen.coderdojo.com/
Internet:
https://www.reddit.com/r/learnprogramming/wiki/faq (Eng)
Pause
Zwischenfragen?
Versionierung
● Das Backup der Programmierenden
● “Wie war nochmal der Stand den ich gestern
hatte?”
● Automatisches Zusammenführen von
Änderungen
Versionskontrolle mit Git
https://try.github.io/
Dictionaries Zuordnung speichern
fak = {0:1, 1:1, 2:2, 3:6, 4:24, 5:120}
def fakultaet(n):
if n == 0:
return 1
if n in fak:
return fak[n]
fak[n] = fakultaet(n-1) * n
return fak[n]
Zuordnung Index -> Wert
Gebe alle Fakultäten bis 1000 aus
Wikipedia [De]: Fakultät (Mathematik)
5! = 4! * 5
Algorithmen & Datenstrukturen
● Deutsche Sprache> 5 Mio
Wörter
● Immer die Wörterliste
durchlaufen zu dauert lange!…
vorsichtigem
vorsichtiger
vorsichtigere
vorsichtigerem
vorsichtigerer
vorsichtigeres
vorsichtiges
vorsichtigstem
vorsichtigsten
vorsichtigster
vorsichtshalber
vorsieht
vorsingen
...
Algorithmen & Datenstrukturen
● Trie (Prefixbaum) speichern
Wörterbücher effizienter
● Schneller durchsuchbar
● Braucht weniger Speicher
https://de.wikipedia.org/wiki/Trie#/media/File:Trie.svg
Algorithmen & Datenstrukturen
Übungen:
Bundeswettbewerb Informatik (alte Aufgaben) https:
//www.bwinf.de/
USA Computing Olympiad (Automatisierte Bewertung)
http://usaco.org/
Frameworks
● Rails maßgeschneidert für den Anwendungsfall
dynamischer Webseitenbau
● Code in vorgefertigtes Schema (Modell, View, Controller)
● “Wissen wo was hinkommt”
● Rails for Zombies (http://railsforzombies.org)

Mais conteúdo relacionado

Destaque

AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 

Destaque (20)

AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 

Wie fange ich programmieren an?

  • 1. Wie fange ich mit dem Programmieren an? Jugend hackt, 9.7.2015 Hubert Hesse (@hubx)
  • 2. Vom Problem zum Programm ● Eingabe/Ausgabe (Spezifikation) ● Vereinfachen ○ “Ich will ein Antivirus implementieren” ■ Dateien erkennen die “AAAA” enthalten ■ Was passiert wenn AAAA verschleiert ist ● Unterprobleme/”Teile-Und-Herrsche” ○ Computer fernsteuern ■ Bildschirm aufnehmen, alle 5s, versenden ■ Verbindung aufbauen ■ Tastenanschläge weiterleiten
  • 3. ● Ziel: Quelltext schreiben und ausführen können ● Editor: z.B: Sublime (http://www.sublimetext.com/) ● Compiler (Quelltext -> Ausführbaren Datei) ● Interpreter (Anweisungen beim Programmstart übersetzen) ● Wie kann ich das Programm starten? Hello World Installiere Voraussetzungen< >>> print("Hello world") Hello World! public class HelloWorld { public static void main (String[] args) { System.out.println("Hello World!"); } } C++/Java: Keine gute EinstiegssprachePython
  • 4. Variablen >>> (1 + 4) * 2 10 >>> x = 1 >>> x 1 >>> x = x + 4 >>> x *= 2 >>> x 10 a = int(input(“Seitenlänge?”)) A = a * a u = 4 * a print (“Fläche:”, A) print (“Umfang:”, u) ● Veränderbarer Platzhalter für Werte ● Adresse im Speicher Typen (10 == “10”)?
  • 5. Funktionen (parameter) def bereche_flaeche(a) return a * a def berechne_umfang(a) return 4 * a a = int(input(“Seitenlänge?”)) print (“Fläche:”, berechne_flaeche(a)) print (“Umfang:”, bereche_umfang(a)) ● In Teilprobleme zerlegen, auf eine Sache konzentrieren ● Quelltextabschnitte benennen, wiederverwenden int bereche_flaeche(int a) { return a*a } C++/Java: Klammern statt Einrückung
  • 6. Funktionen II def bereche_flaeche(a) return a * a def berechne_umfang(a) return 4 * a a = int(input(“Seitenlänge?”)) print (“Fläche:”, berechne_flaeche(a)) print (“Umfang:”, bereche_umfang(a)) print (“Doppelte Seitenfläche => Fläche:”, berechne_flaeche(2 * a)) print (“Doppelte Seitenfläche => Umfang:”, bereche_umfang(2 * a)) ● Wiederverwendung von Code mit Funktionen möglich
  • 7. Eingebaute Funktionen mein_string = “ ICH bIn Groß ” print(mein_string.strip().lower()) # ”ich bin groß” <- Kommentar ● Vorher schauen ob Funktion schon mit der Standardbibliothek mitkommen
  • 8. Schleifen Wiederholen von Anweisungen namen = “Alex,Trevor,Alice”.split(“,”) for name in namen: print(“Willkommen “ + name) total = 0 for i in 1, 1, 2, 3, 5, 7, 11, 13: print(i) total += i print(total) #43
  • 9. Verzweigungen if-Ausdrücke def rechner(a, b, op): if op == "+": return a + b elif op == "-": return a - b else: return a total = 0 while True: op = input("+/-?") i = int(input("i?")) total = rechner(total, i, op) print (total) ● Testen von Variablen auf Inhalte ○ <,>, ==, (i % 2 == 0) ○ str.endswith(),str.islower() ● Wahrheitswert (Boolean) ○ True, False
  • 10. Listen def quadriere(liste): b = [] for a in liste: b.append(a*a) return b quadriere([1, 2, 3, 4, 5]) liste = [0,1,2,3,4,5] b = [a*a for a in liste] # Kürzere Schreibweise: List comprehension b[5] # Direkter Zugriff auf das 6. Element = 25 (Zwischen-)ergebnisse aufsammeln
  • 11. Lerntipps ● Selber tippen trainiert Muskelgedächtnis ● Mit Freunden programmieren ● Hilfe suchen (online/offline) ● Spaß OpenTechSchool Konzepte ausführlicher https: //opentechschool.github.io/python-beginners/de/index.html
  • 14. Let’s Code - Programmiervideos Java für Einsteiger - https://open.hpi.de/courses/javaeinstieg2015 Python - https://open.hpi.de/courses/pythonjunior2014 khanacademy.org: Zeichnen mit JavaScript https://de.khanacademy.org/video?lang=de&format=lite&v=h25CyONlPdM Youtube: Android Apps programmieren (JaDaHB1) https://www.youtube.com/playlist?list=PL13I0cBsOJUc0OTlv09DG7_m2T0Si0Wbx
  • 15. Projektideen ● Text: Wörter zählen, Palindrom-Check, Cäsar- Chiffre/Enigma ● Datei/Netzwerk: Verzeichnis auflisten, Datei erkennen/ablehnen, Passwort-Check, Webserver der immer die gleiche Webseite ausliefert ● Spiele: Hangman, Pong
  • 16. Programmieren lernen - Communities OpenTechSchool: http://learn.opentechschool.org/ (D/Eng...) Coder Dojos: https://zen.coderdojo.com/ Internet: https://www.reddit.com/r/learnprogramming/wiki/faq (Eng)
  • 18. Versionierung ● Das Backup der Programmierenden ● “Wie war nochmal der Stand den ich gestern hatte?” ● Automatisches Zusammenführen von Änderungen Versionskontrolle mit Git https://try.github.io/
  • 19. Dictionaries Zuordnung speichern fak = {0:1, 1:1, 2:2, 3:6, 4:24, 5:120} def fakultaet(n): if n == 0: return 1 if n in fak: return fak[n] fak[n] = fakultaet(n-1) * n return fak[n] Zuordnung Index -> Wert Gebe alle Fakultäten bis 1000 aus Wikipedia [De]: Fakultät (Mathematik) 5! = 4! * 5
  • 20. Algorithmen & Datenstrukturen ● Deutsche Sprache> 5 Mio Wörter ● Immer die Wörterliste durchlaufen zu dauert lange!… vorsichtigem vorsichtiger vorsichtigere vorsichtigerem vorsichtigerer vorsichtigeres vorsichtiges vorsichtigstem vorsichtigsten vorsichtigster vorsichtshalber vorsieht vorsingen ...
  • 21. Algorithmen & Datenstrukturen ● Trie (Prefixbaum) speichern Wörterbücher effizienter ● Schneller durchsuchbar ● Braucht weniger Speicher https://de.wikipedia.org/wiki/Trie#/media/File:Trie.svg
  • 22. Algorithmen & Datenstrukturen Übungen: Bundeswettbewerb Informatik (alte Aufgaben) https: //www.bwinf.de/ USA Computing Olympiad (Automatisierte Bewertung) http://usaco.org/
  • 23. Frameworks ● Rails maßgeschneidert für den Anwendungsfall dynamischer Webseitenbau ● Code in vorgefertigtes Schema (Modell, View, Controller) ● “Wissen wo was hinkommt” ● Rails for Zombies (http://railsforzombies.org)