SlideShare a Scribd company logo
1 of 1
Download to read offline
Python
Python ist	eine	klar	strukturierte	Programmier-
sprache,	die	verschiedene	Programmiermodelle	
(imperativ,	funktional,	objektorientiert)	unterstützt	
und	über	eine	umfangreiche	Standard-Bibliothek	verfügt.	Python-Code	ist	sehr	gut	lesbar	und	
wartbar,	da	die	Sprache	eine	einfache,	elegante	Syntax	mit	Einrückung	verwendet.

Grundeigenschaften von Python                            •	Der	Rückgabewerte	kann	ein	Tupel	sein
•	Stark	typisiert	mit	dynamischer	Typisierung            def example(a_list, an_int=2,
                                                                     a_string=“A Default String“):
•	Case	sensitive	(d.h.	var	≠	VAR)
                                                             a_list.append(“A new item“)
•	Objektorientiert	(d.h.	alles	ist	ein	Objekt)               an_int = 4
Syntax                                                       return a_list, an_int, a_string

•	Blöcke	werden	durch	Einrückung	definiert	und	Aus- Klassen
  drücke,	die	Einrückung	erwarten,	enden	mit	„:“	        •	Mehrfachvererbung	wird	unterstützt
•	Kommentarzeilen	beginnen	mit	„#“                       •	Private	Variablen	und	Methoden	beginnen	mit	zwei	
•	Wertzuweisung	erfolgt	mit	Gleichheitszeichen	(„=“)       Unterstrichen	(z.B.	der	Konstruktor	„__init__“)
•	Test	auf	Gleichheit	mit	zwei	Gleichheitszeichen	(„==“) class MyClass:
>>> mystring = “Hello “                                      common = 10
>>> mystring += “World“                                      def __init__(self):
>>> print mystring                                               self.myvariable = 3
Hello World                                                  def myfunction(self, arg1, arg2):
                                                                 return self.myvariable
Datentypen
                                                         Bibliotheken und Module
•	Verfügbare	Datenstrukturen	sind	Listen,	Tupel	und	
                                                         •	Es	gibt	viele	leistungsfähige	Module,	z.B.	Matplotlib
  Dictionaries	
                                                         from pylab import * # matplotlib
•	Zugriff	auf	Array-Bereiche	mit	Doppelpunkt	(„;“)
>>> mylist = [“List item 1“, 2, 3.14]                    x = arange(0, 2, 0.01)
>>> mylist[0] = “New item 1“                             y = 2 * sin(2 * pi * (x - 1 / 4))
>>> mydict = {“key1“: “value1“, 2: 3, “pi“: 3.14}
>>> mydict[“pi“] = 3.15                                  plot(x, y)
>>> mytupel = (1, 2, 3)                                  xlabel(‘x-axis‘)
>>> print mylist[0:2]                                    ylabel(‘y-axis‘)
[‘List item 1‘, 2]                                       title(r‘$y=2sin (2pi(x-1/4))$‘)
>>> print mylist[1:]                                     show()
[2, 3.14]

Strings
•	Haben	einfache	oder	doppelte	Anführungszeichen
•	Unicode	wird	unterstützt	(Syntax:	u“Unicode	String“)
•	Wertersetzung	in	Strings	durch	den	Operator	„%“	
>>> print “Number: %s String: %s“ % (17, 3 * “-“)
Number: 17 String: ---

Funktionen
•	Werden	definiert	durch	das	Schlüsselwort	„def“     Alle	Informationen	zu	Python	gibt	es	unter
•	Optionale	und	Schlüsselwort-Argumente	sind	erlaubt http://www.python.org


                                            Python User Group Köln
                                            http://www.pycologne.de

More Related Content

Similar to Python

C Sharp Einfuehrung Teil 2
C Sharp Einfuehrung Teil 2C Sharp Einfuehrung Teil 2
C Sharp Einfuehrung Teil 2DraphonyGames
 
Battle of the Languages: Java und Python im Wettstreit beim Lösen von Program...
Battle of the Languages: Java und Python im Wettstreit beim Lösen von Program...Battle of the Languages: Java und Python im Wettstreit beim Lösen von Program...
Battle of the Languages: Java und Python im Wettstreit beim Lösen von Program...gedoplan
 
Python crash-kurs
Python crash-kursPython crash-kurs
Python crash-kursklausbremer
 
An Introduction to Ruby
An Introduction to RubyAn Introduction to Ruby
An Introduction to RubyJonathan Weiss
 
Funktionales Programmieren mit Clojure
Funktionales Programmieren mit ClojureFunktionales Programmieren mit Clojure
Funktionales Programmieren mit ClojureDr. Christian Betz
 
Nigh Session Scala
Nigh Session ScalaNigh Session Scala
Nigh Session Scalaadesso AG
 
Fundamentale Muster in Java
Fundamentale Muster in JavaFundamentale Muster in Java
Fundamentale Muster in Javatutego
 
Eine Reise durch den PostgreSQL Optimizer
Eine Reise durch den PostgreSQL OptimizerEine Reise durch den PostgreSQL Optimizer
Eine Reise durch den PostgreSQL Optimizerpsoo1978
 

Similar to Python (11)

C Sharp Einfuehrung Teil 2
C Sharp Einfuehrung Teil 2C Sharp Einfuehrung Teil 2
C Sharp Einfuehrung Teil 2
 
Scala Workshop
Scala WorkshopScala Workshop
Scala Workshop
 
Battle of the Languages: Java und Python im Wettstreit beim Lösen von Program...
Battle of the Languages: Java und Python im Wettstreit beim Lösen von Program...Battle of the Languages: Java und Python im Wettstreit beim Lösen von Program...
Battle of the Languages: Java und Python im Wettstreit beim Lösen von Program...
 
Python crash-kurs
Python crash-kursPython crash-kurs
Python crash-kurs
 
An Introduction to Ruby
An Introduction to RubyAn Introduction to Ruby
An Introduction to Ruby
 
Funktionales Programmieren mit Clojure
Funktionales Programmieren mit ClojureFunktionales Programmieren mit Clojure
Funktionales Programmieren mit Clojure
 
Nigh Session Scala
Nigh Session ScalaNigh Session Scala
Nigh Session Scala
 
Unixkurs 06 - Shellskripte
Unixkurs 06 - ShellskripteUnixkurs 06 - Shellskripte
Unixkurs 06 - Shellskripte
 
Fundamentale Muster in Java
Fundamentale Muster in JavaFundamentale Muster in Java
Fundamentale Muster in Java
 
Eine Reise durch den PostgreSQL Optimizer
Eine Reise durch den PostgreSQL OptimizerEine Reise durch den PostgreSQL Optimizer
Eine Reise durch den PostgreSQL Optimizer
 
Windows Powershell
Windows PowershellWindows Powershell
Windows Powershell
 

More from Andreas Schreiber

Provenance-based Security Audits and its Application to COVID-19 Contact Trac...
Provenance-based Security Audits and its Application to COVID-19 Contact Trac...Provenance-based Security Audits and its Application to COVID-19 Contact Trac...
Provenance-based Security Audits and its Application to COVID-19 Contact Trac...Andreas Schreiber
 
Visualization of Software Architectures in Virtual Reality and Augmented Reality
Visualization of Software Architectures in Virtual Reality and Augmented RealityVisualization of Software Architectures in Virtual Reality and Augmented Reality
Visualization of Software Architectures in Virtual Reality and Augmented RealityAndreas Schreiber
 
Provenance as a building block for an open science infrastructure
Provenance as a building block for an open science infrastructureProvenance as a building block for an open science infrastructure
Provenance as a building block for an open science infrastructureAndreas Schreiber
 
Raising Awareness about Open Source Licensing at the German Aerospace Center
Raising Awareness about Open Source Licensing at the German Aerospace CenterRaising Awareness about Open Source Licensing at the German Aerospace Center
Raising Awareness about Open Source Licensing at the German Aerospace CenterAndreas Schreiber
 
Open Source Licensing for Rocket Scientists
Open Source Licensing for Rocket ScientistsOpen Source Licensing for Rocket Scientists
Open Source Licensing for Rocket ScientistsAndreas Schreiber
 
Interactive Visualization of Software Components with Virtual Reality Headsets
Interactive Visualization of Software Components with Virtual Reality HeadsetsInteractive Visualization of Software Components with Virtual Reality Headsets
Interactive Visualization of Software Components with Virtual Reality HeadsetsAndreas Schreiber
 
Provenance for Reproducible Data Science
Provenance for Reproducible Data ScienceProvenance for Reproducible Data Science
Provenance for Reproducible Data ScienceAndreas Schreiber
 
Visualizing Provenance using Comics
Visualizing Provenance using ComicsVisualizing Provenance using Comics
Visualizing Provenance using ComicsAndreas Schreiber
 
Nachvollziehbarkeit mit Hinblick auf Privacy-Verletzungen
Nachvollziehbarkeit mit Hinblick auf Privacy-VerletzungenNachvollziehbarkeit mit Hinblick auf Privacy-Verletzungen
Nachvollziehbarkeit mit Hinblick auf Privacy-VerletzungenAndreas Schreiber
 
Reproducible Science with Python
Reproducible Science with PythonReproducible Science with Python
Reproducible Science with PythonAndreas Schreiber
 
A Provenance Model for Quantified Self Data
A Provenance Model for Quantified Self DataA Provenance Model for Quantified Self Data
A Provenance Model for Quantified Self DataAndreas Schreiber
 
Tracking after Stroke: Doctors, Dogs and All The Rest
Tracking after Stroke: Doctors, Dogs and All The RestTracking after Stroke: Doctors, Dogs and All The Rest
Tracking after Stroke: Doctors, Dogs and All The RestAndreas Schreiber
 
High Throughput Processing of Space Debris Data
High Throughput Processing of Space Debris DataHigh Throughput Processing of Space Debris Data
High Throughput Processing of Space Debris DataAndreas Schreiber
 
Bericht von der QS15 Conference & Exposition
Bericht von der QS15 Conference & ExpositionBericht von der QS15 Conference & Exposition
Bericht von der QS15 Conference & ExpositionAndreas Schreiber
 
Telemedizin: Gesundheit, messbar für jedermann
Telemedizin: Gesundheit, messbar für jedermannTelemedizin: Gesundheit, messbar für jedermann
Telemedizin: Gesundheit, messbar für jedermannAndreas Schreiber
 
Quantified Self mit Wearable Devices und Smartphone-Sensoren
Quantified Self mit Wearable Devices und Smartphone-SensorenQuantified Self mit Wearable Devices und Smartphone-Sensoren
Quantified Self mit Wearable Devices und Smartphone-SensorenAndreas Schreiber
 

More from Andreas Schreiber (20)

Provenance-based Security Audits and its Application to COVID-19 Contact Trac...
Provenance-based Security Audits and its Application to COVID-19 Contact Trac...Provenance-based Security Audits and its Application to COVID-19 Contact Trac...
Provenance-based Security Audits and its Application to COVID-19 Contact Trac...
 
Visualization of Software Architectures in Virtual Reality and Augmented Reality
Visualization of Software Architectures in Virtual Reality and Augmented RealityVisualization of Software Architectures in Virtual Reality and Augmented Reality
Visualization of Software Architectures in Virtual Reality and Augmented Reality
 
Provenance as a building block for an open science infrastructure
Provenance as a building block for an open science infrastructureProvenance as a building block for an open science infrastructure
Provenance as a building block for an open science infrastructure
 
Raising Awareness about Open Source Licensing at the German Aerospace Center
Raising Awareness about Open Source Licensing at the German Aerospace CenterRaising Awareness about Open Source Licensing at the German Aerospace Center
Raising Awareness about Open Source Licensing at the German Aerospace Center
 
Open Source Licensing for Rocket Scientists
Open Source Licensing for Rocket ScientistsOpen Source Licensing for Rocket Scientists
Open Source Licensing for Rocket Scientists
 
Interactive Visualization of Software Components with Virtual Reality Headsets
Interactive Visualization of Software Components with Virtual Reality HeadsetsInteractive Visualization of Software Components with Virtual Reality Headsets
Interactive Visualization of Software Components with Virtual Reality Headsets
 
Provenance for Reproducible Data Science
Provenance for Reproducible Data ScienceProvenance for Reproducible Data Science
Provenance for Reproducible Data Science
 
Visualizing Provenance using Comics
Visualizing Provenance using ComicsVisualizing Provenance using Comics
Visualizing Provenance using Comics
 
Quantified Self Comics
Quantified Self ComicsQuantified Self Comics
Quantified Self Comics
 
Nachvollziehbarkeit mit Hinblick auf Privacy-Verletzungen
Nachvollziehbarkeit mit Hinblick auf Privacy-VerletzungenNachvollziehbarkeit mit Hinblick auf Privacy-Verletzungen
Nachvollziehbarkeit mit Hinblick auf Privacy-Verletzungen
 
Reproducible Science with Python
Reproducible Science with PythonReproducible Science with Python
Reproducible Science with Python
 
Python at Warp Speed
Python at Warp SpeedPython at Warp Speed
Python at Warp Speed
 
A Provenance Model for Quantified Self Data
A Provenance Model for Quantified Self DataA Provenance Model for Quantified Self Data
A Provenance Model for Quantified Self Data
 
Open Source im DLR
Open Source im DLROpen Source im DLR
Open Source im DLR
 
Tracking after Stroke: Doctors, Dogs and All The Rest
Tracking after Stroke: Doctors, Dogs and All The RestTracking after Stroke: Doctors, Dogs and All The Rest
Tracking after Stroke: Doctors, Dogs and All The Rest
 
High Throughput Processing of Space Debris Data
High Throughput Processing of Space Debris DataHigh Throughput Processing of Space Debris Data
High Throughput Processing of Space Debris Data
 
Bericht von der QS15 Conference & Exposition
Bericht von der QS15 Conference & ExpositionBericht von der QS15 Conference & Exposition
Bericht von der QS15 Conference & Exposition
 
Telemedizin: Gesundheit, messbar für jedermann
Telemedizin: Gesundheit, messbar für jedermannTelemedizin: Gesundheit, messbar für jedermann
Telemedizin: Gesundheit, messbar für jedermann
 
Big Python
Big PythonBig Python
Big Python
 
Quantified Self mit Wearable Devices und Smartphone-Sensoren
Quantified Self mit Wearable Devices und Smartphone-SensorenQuantified Self mit Wearable Devices und Smartphone-Sensoren
Quantified Self mit Wearable Devices und Smartphone-Sensoren
 

Python

  • 1. Python Python ist eine klar strukturierte Programmier- sprache, die verschiedene Programmiermodelle (imperativ, funktional, objektorientiert) unterstützt und über eine umfangreiche Standard-Bibliothek verfügt. Python-Code ist sehr gut lesbar und wartbar, da die Sprache eine einfache, elegante Syntax mit Einrückung verwendet. Grundeigenschaften von Python • Der Rückgabewerte kann ein Tupel sein • Stark typisiert mit dynamischer Typisierung def example(a_list, an_int=2, a_string=“A Default String“): • Case sensitive (d.h. var ≠ VAR) a_list.append(“A new item“) • Objektorientiert (d.h. alles ist ein Objekt) an_int = 4 Syntax return a_list, an_int, a_string • Blöcke werden durch Einrückung definiert und Aus- Klassen drücke, die Einrückung erwarten, enden mit „:“ • Mehrfachvererbung wird unterstützt • Kommentarzeilen beginnen mit „#“ • Private Variablen und Methoden beginnen mit zwei • Wertzuweisung erfolgt mit Gleichheitszeichen („=“) Unterstrichen (z.B. der Konstruktor „__init__“) • Test auf Gleichheit mit zwei Gleichheitszeichen („==“) class MyClass: >>> mystring = “Hello “ common = 10 >>> mystring += “World“ def __init__(self): >>> print mystring self.myvariable = 3 Hello World def myfunction(self, arg1, arg2): return self.myvariable Datentypen Bibliotheken und Module • Verfügbare Datenstrukturen sind Listen, Tupel und • Es gibt viele leistungsfähige Module, z.B. Matplotlib Dictionaries from pylab import * # matplotlib • Zugriff auf Array-Bereiche mit Doppelpunkt („;“) >>> mylist = [“List item 1“, 2, 3.14] x = arange(0, 2, 0.01) >>> mylist[0] = “New item 1“ y = 2 * sin(2 * pi * (x - 1 / 4)) >>> mydict = {“key1“: “value1“, 2: 3, “pi“: 3.14} >>> mydict[“pi“] = 3.15 plot(x, y) >>> mytupel = (1, 2, 3) xlabel(‘x-axis‘) >>> print mylist[0:2] ylabel(‘y-axis‘) [‘List item 1‘, 2] title(r‘$y=2sin (2pi(x-1/4))$‘) >>> print mylist[1:] show() [2, 3.14] Strings • Haben einfache oder doppelte Anführungszeichen • Unicode wird unterstützt (Syntax: u“Unicode String“) • Wertersetzung in Strings durch den Operator „%“ >>> print “Number: %s String: %s“ % (17, 3 * “-“) Number: 17 String: --- Funktionen • Werden definiert durch das Schlüsselwort „def“ Alle Informationen zu Python gibt es unter • Optionale und Schlüsselwort-Argumente sind erlaubt http://www.python.org Python User Group Köln http://www.pycologne.de