Olli Graf
2 years ago
35 changed files with 263 additions and 0 deletions
@ -0,0 +1,5 @@ |
|||
|
|||
|
|||
for zahl in range(1,11,2): |
|||
print(zahl) |
|||
|
@ -0,0 +1,9 @@ |
|||
PI = 3.1415 |
|||
r=10 |
|||
def berechne_flaecheninhalt(): |
|||
|
|||
a = PI * r**2 |
|||
return a |
|||
|
|||
flaeche = berechne_flaecheninhalt() |
|||
print(f"Der Flächeninhalt beträgt: {flaeche}") |
@ -0,0 +1,9 @@ |
|||
import math |
|||
#PI = 3.1415 |
|||
def berechne_flaecheninhalt(r): |
|||
|
|||
a = math.pi * r**2 |
|||
return a |
|||
|
|||
flaeche = berechne_flaecheninhalt(10) |
|||
print(f"Der Flächeninhalt beträgt: {flaeche}") |
@ -0,0 +1,14 @@ |
|||
#math Package importieren |
|||
import math |
|||
#PI = 3.1415 |
|||
|
|||
# berechnet den Flächeninhalt eines Kreises |
|||
# mit dem Radius r |
|||
# Parameter: r - Radius des Kreises |
|||
def berechne_flaecheninhalt(r): |
|||
|
|||
a = math.pi * r**2 |
|||
return a |
|||
|
|||
flaeche = berechne_flaecheninhalt(10) |
|||
print(f"Der Flächeninhalt beträgt: {flaeche}") |
@ -0,0 +1,7 @@ |
|||
PI = 3.1415 |
|||
r=10 |
|||
|
|||
a = PI * r*r |
|||
|
|||
print(f'Der Flächeninhalt beträgt: {a}') |
|||
|
@ -0,0 +1,9 @@ |
|||
PI = 3.1415 |
|||
|
|||
def berechne_flaecheninhalt(r): |
|||
|
|||
a = PI * r**2 |
|||
return a |
|||
|
|||
flaeche = berechne_flaecheninhalt(10) |
|||
print(f"Der Flächeninhalt beträgt: {flaeche}") |
@ -0,0 +1,7 @@ |
|||
# coding = 'utf-8' |
|||
|
|||
s1 = 'Homer' |
|||
s2 = '1969' |
|||
s3 = 'Dies ist ein ganzer Satz.' |
|||
s4 = 'Auf den Alkohol - Der Beginn und die Lösung sämtlicher Lebenprobleme. (Homer Simpson)' |
|||
|
@ -0,0 +1,5 @@ |
|||
import math |
|||
|
|||
|
|||
print(f'Pi ist {math.pi}') |
|||
print(f'Pi ist {math.pi:.2f}') |
@ -0,0 +1 @@ |
|||
print('Homer'.lower().find('home'.lower())) |
@ -0,0 +1,12 @@ |
|||
|
|||
def find_in_string(s, c): |
|||
|
|||
for pos in range(0,len(s)): |
|||
if(s[pos] == c): |
|||
return pos |
|||
return -1 |
|||
|
|||
|
|||
print(find_in_string('Homer','e')) |
|||
print(find_in_string('Homer','n')) |
|||
|
@ -0,0 +1,5 @@ |
|||
|
|||
|
|||
print('Homer'.find('e')) |
|||
print('Homer'.find('n')) |
|||
|
@ -0,0 +1,2 @@ |
|||
print('Homer'.find('Home')) |
|||
print('Homer'.find('home')) |
@ -0,0 +1,6 @@ |
|||
a=5 |
|||
b=10 |
|||
|
|||
produkt = a * b |
|||
|
|||
print(f'Das Produkt aus {a} und {b} ist {produkt}') |
@ -0,0 +1,7 @@ |
|||
s = 'Dies ist ein ganzer Satz.' |
|||
|
|||
print(f'zerlegt= {s.split()}') |
|||
|
|||
werte = '1,2,3,4,5,6,7,8,9' |
|||
|
|||
print(f'werteliste = {werte.split(",")}') |
@ -0,0 +1,3 @@ |
|||
print('Homer'.lower()) |
|||
print('Homer'.upper()) |
|||
print('homer'.capitalize()) |
@ -0,0 +1,5 @@ |
|||
s = 'Homer' |
|||
|
|||
for pos in range(0,len(s)): |
|||
print(s[pos]) |
|||
|
@ -0,0 +1,3 @@ |
|||
s1 = 'Homer' |
|||
|
|||
print(len(s1)) |
@ -0,0 +1,5 @@ |
|||
s= ' mit Leerzeichen ' |
|||
|
|||
s = s.strip() |
|||
print(f'*{s}*') |
|||
|
@ -0,0 +1 @@ |
|||
print('dr. nick riviera'.title()) |
@ -0,0 +1,23 @@ |
|||
# encoding utf-8 |
|||
|
|||
kfz = { |
|||
'W':'Wuppertal', |
|||
'HH':'Hamburg', |
|||
'D':'Düsseldorf', |
|||
'DO':'Dortmund', |
|||
'H':'Hannover', |
|||
'M':'München'} |
|||
|
|||
for key in kfz: |
|||
print(f' Kennzeichen {key} -> Stadt {kfz[key]}') |
|||
|
|||
print() |
|||
for key, stadt in kfz.items(): |
|||
|
|||
print(f' Kennzeichen {key} -> Stadt {stadt}') |
|||
|
|||
items = kfz.items() |
|||
keys = kfz.keys() |
|||
|
|||
print(items) |
|||
print(keys) |
@ -0,0 +1,12 @@ |
|||
# encoding utf-8 |
|||
|
|||
kfz = { |
|||
'W':'Wuppertal', |
|||
'HH':'Hamburg', |
|||
'D':'Düsseldorf', |
|||
'DO':'Dortmund', |
|||
'H':'Hannover', |
|||
'M':'München'} |
|||
|
|||
print(kfz) |
|||
print(kfz['W']) |
@ -0,0 +1,7 @@ |
|||
namen = ["Homer", "Marge", "Bart"] |
|||
|
|||
|
|||
namen.append('Lisa') |
|||
namen.append('Maggie') |
|||
|
|||
print(namen) |
@ -0,0 +1,9 @@ |
|||
zahlen1 = ['0','1','4','3','2','5'] |
|||
zahlen2 = ['8','7','9','6'] |
|||
|
|||
zahlen1.extend(zahlen2) |
|||
|
|||
print(f'komplett:{zahlen1}') |
|||
zahlen1.sort() |
|||
del zahlen1[3] |
|||
print(f'nach del:{zahlen1}') |
@ -0,0 +1,6 @@ |
|||
zahlen1 = ['0','1','2','3','4','5'] |
|||
zahlen2 = ['6','7','8','9'] |
|||
|
|||
zahlen1.extend(zahlen2) |
|||
|
|||
print(zahlen1) |
@ -0,0 +1,4 @@ |
|||
namen = ["Homer", "Marge", "Bart"] |
|||
|
|||
for ind in range(0,len(namen)): |
|||
print(f'{ind}: {namen[ind]}') |
@ -0,0 +1,5 @@ |
|||
namen = ["Homer", "Marge", "Bart"] |
|||
|
|||
print(namen[0]) |
|||
print(namen[1]) |
|||
print(namen[2]) |
@ -0,0 +1,8 @@ |
|||
zahlen1 = ['0','1','4','3','2','5'] |
|||
zahlen2 = ['8','7','9','6'] |
|||
|
|||
zahlen1.extend(zahlen2) |
|||
|
|||
print(f'unsortiert:{zahlen1}') |
|||
zahlen1.sort() |
|||
print(f'sortiert:{zahlen1}') |
@ -0,0 +1,3 @@ |
|||
coords = (51.2562,7.1508) |
|||
|
|||
print(coords) |
Binary file not shown.
@ -0,0 +1,9 @@ |
|||
class Anschrift: |
|||
def __init__(self, strasse, hausnummer, plz, ort): |
|||
self.strasse = strasse |
|||
self.hausnummer = hausnummer |
|||
self.plz = plz |
|||
self.ort = ort |
|||
|
|||
def __str__(self): |
|||
return self.strasse + ' ' + self.hausnummer + '\n' + self.plz + ' ' + self.ort |
@ -0,0 +1,5 @@ |
|||
class Person: |
|||
# Konstruktor |
|||
def __init__(self,vorname, name): |
|||
self.vorname = vorname |
|||
self.name = name |
@ -0,0 +1,16 @@ |
|||
from anschrift import Anschrift |
|||
|
|||
class Person: |
|||
# Konstruktor |
|||
def __init__(self,vorname, name,strasse,hausnummer, plz,ort): |
|||
self.vorname = vorname |
|||
self.name = name |
|||
self.anschrift = Anschrift(strasse,hausnummer,plz,ort) |
|||
|
|||
|
|||
def format(self): |
|||
|
|||
return self.vorname + ' ' + self.name |
|||
def __str__(self): |
|||
return self.format() + '\n' + str(self.anschrift) |
|||
|
@ -0,0 +1,4 @@ |
|||
from person import Person |
|||
|
|||
p = Person('Olli','Graf') |
|||
print(p.vorname) |
@ -0,0 +1,34 @@ |
|||
class Fahrzeug: |
|||
def __init__(self, marke, modell, farbe): |
|||
self.marke = marke |
|||
self.modell = modell |
|||
self.farbe = farbe |
|||
|
|||
def __str__(self): |
|||
return f'{self.marke} {self.modell} {self.farbe})' |
|||
|
|||
#Klasse Auto erbt von Fahrzeug |
|||
class Auto(Fahrzeug): |
|||
def __init__(self, marke, modell, farbe, ps): |
|||
super().__init__(marke, modell, farbe) |
|||
self.ps = ps |
|||
|
|||
def __str__(self): |
|||
return f'{super().__str__()} mit {self.ps} PS' |
|||
|
|||
#Klasse Fahhrad erbt von Fahrzeug |
|||
class Fahrrad(Fahrzeug): |
|||
def __init__(self, marke, modell, farbe): |
|||
super().__init__(marke, modell, farbe) |
|||
|
|||
def __str__(self): |
|||
return super().__str__() |
|||
|
|||
|
|||
bond = Auto('Aston Martin','DB5','grau','286') |
|||
mcfly = Auto('Delorean', 'DMC-12','grau','132') |
|||
eliot = Fahrrad('Kuwahara','ET-1','weiß') |
|||
|
|||
print(str(bond)) |
|||
print(str(mcfly)) |
|||
print(str(eliot)) |
Loading…
Reference in new issue