This commit is contained in:
alstergym
2026-09-18 09:14:16 +02:00
parent ce085e53eb
commit f98f2fa7ec
14 changed files with 199 additions and 16 deletions
+1 -15
View File
@@ -95,12 +95,6 @@ ipython_config.py
# install all needed dependencies. # install all needed dependencies.
#Pipfile.lock #Pipfile.lock
# UV
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
#uv.lock
# poetry # poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more # This is especially recommended for binary packages to ensure reproducibility, and is more
@@ -113,10 +107,8 @@ ipython_config.py
#pdm.lock #pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control. # in version control.
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control # https://pdm.fming.dev/#use-with-ide
.pdm.toml .pdm.toml
.pdm-python
.pdm-build/
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/ __pypackages__/
@@ -168,9 +160,3 @@ cython_debug/
# option (not recommended) you can uncomment the following to ignore the entire idea folder. # option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/ #.idea/
# Ruff stuff:
.ruff_cache/
# PyPI configuration file
.pypirc
+1 -1
View File
@@ -1,2 +1,2 @@
# Objektorientiertes-Programmieren # Objektorientierung
+27
View File
@@ -0,0 +1,27 @@
import random
def auswertung():
while True:
try:
zahl = int(input("Dein Tipp: "))
return zahl
except ValueError:
print("Gib eine ganze Zahl ein")
geheimzahl = random.randint(1, 100)
versuche = 0
print("Errate eine Zahl")
while True:
tipp = auswertung()
versuche += 1
if tipp < geheimzahl:
print("Zu klein!")
elif tipp > geheimzahl:
print("Zu groß")
else:
print("Richtig!")
print("Du hast" , versuche , "Versuche gebraucht.")
break
+8
View File
@@ -0,0 +1,8 @@
import random
count = 0
for i in range(0,99):
x = random.randint(1, 6)
if x == 6:
count = count + 1
print(count)
+32
View File
@@ -0,0 +1,32 @@
class Kart:
def __init__ (self, v_max, name, farbe, tempo, drift): #erster Parameter muss self sein #Konstruktor
self.v_max = v_max
self.name = name
self.farbe = farbe
self.tempo = tempo
self.drift = drift
def __str__(self):
return "Das Kart heißt: " + self.name
def beschleunigen(self):
self.tempo = self.tempo + 10
def rammen(self, boom):
self.tempo = self.tempo - self.tempo
boom.tempo = boom.tempo - boom.tempo
class Item:
def __init__ (self, name, tempo):
self.name = name
self.tempo = tempo
self.tempo2 = tempo
def __str__(self):
return "Das Item heißt" + self.name
def stoppen(self):
self.tempo = self.tempo - self.tempo
def boost(self):
self.tempo2 = self.tempo2 *2
+33
View File
@@ -0,0 +1,33 @@
class Konto(object):
def __init__(self, nummer):
self.__nr = nummer
self.__stand = 0.0
self.__inhaber = None
self.__minimum = -1000.0
def einzahlen(self, betrag):
self.__stand = self.__stand + betrag
def auszahlen(self, betrag):
if self.__stand - betrag >= self.__minimum:
self.__stand = self.__stand - betrag
else:
print("Auszahlung nicht möglich!")
def getNr(self):
return print(f"Die Kontonummer ist: {self.__nr}")
def getStand(self):
return print(f"Die Kontonstand ist: {self.__stand}")
def setStand(self, stand):
if stand >= self.__minimum:
self.__stand = stand
else:
print("Initialisierung nicht möglich!")
def getMinimum(self):
return self.__minimum
def setMinimum(self, minimum):
self.__minimum = minimum
+35
View File
@@ -0,0 +1,35 @@
class Schlange(object):
def __init__(self):
self.__liste = []
self.__anzahl = 0
def istLeer(self):
if self.__anzahl == 0:
return True
else:
return False
def mitLetztem(self, element):
self.__liste = self.__liste + [element]
self.__anzahl = self.__anzahl + 1
def ohneErstes(self):
if not self.istLeer():
self.__liste = self.__liste[1:] #1: => bis zum letzten Element
self.__anzahl = self.__anzahl - 1
def erstes(self):
if self.istLeer():
return None
else:
return self.__liste[0]
def anzahlElemente(self):
return self.__anzahl
def getSchlange(self):
return self.__liste
def setSchlange(self, liste):
self.__liste = liste
self.__anzahl = len(self.liste)
+6
View File
@@ -0,0 +1,6 @@
from konto import Konto
k = Konto(3)
k.getNr()
k.setStand(500.0)
k.getStand()
+6
View File
@@ -0,0 +1,6 @@
from schlange import Schlange
s = Schlange()
#s.liste = s.liste + [3]
print(s.istLeer())
s.mitLetztem(3)
print(s.istLeer())
+31
View File
@@ -0,0 +1,31 @@
from kart import Kart
from kart import Item
#Definition der Karts/Erzeugung des Objekts
kart1 = Kart(300, "bluey", "blue", 120, 200)
print(kart1)
print(kart1.farbe)
kart1.beschleunigen()
print(kart1.tempo)
print(kart1.drift)
kart2 = Kart(500, "lene", "rosa", 320, 200)
print(kart2)
print(kart2.farbe)
kart2.beschleunigen()
print(kart2.tempo)
print(kart2.drift)
#Interaktion zweier Objekte kart1 & kart2
kart1.rammen(kart2)
print(kart1.tempo)
print(kart2.tempo)
item1 = Item("Stopp", 120)
print(item1.name)
item1.stoppen()
print(item1.tempo)
item1.boost()
print(item1.tempo2)
+5
View File
@@ -0,0 +1,5 @@
class Knoten:
def __init__(self, data):
self.data = data
self.next = None
+5
View File
@@ -0,0 +1,5 @@
from knoten import Knoten
class Liste:
def __init__(self):
self.head = None
+7
View File
@@ -0,0 +1,7 @@
from knoten import Knoten
knoten1 = Knoten(3)
knoten2 = Knoten(5)
knoten1.next = knoten2
print(knoten1.next.data)
print(knoten2.data)
+2
View File
@@ -0,0 +1,2 @@
import random