Raspithek
2 years ago
34 changed files with 196 additions and 0 deletions
@ -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,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