import math class Sirkel: def __init__(self, radius) -> None: self._radius = radius def diameter(self) -> float: return self._radius*2 def omkrets(self) -> float: return self.diameter()*math.pi # Kan ogs? skrive: # return self.diameter()*3.14 def areal(self) -> float: return (self._radius**2) * math.pi # print(f"{Sirkel(3).areal():.2f}") class Student: def __init__(self, alder, uni) -> None: self._uni = uni self._alder = alder self._emner = None def taEmne(self, emne): pass # class Hund: # def __init__(self) -> None: # self._farge = "bl?" # def endreFarge(self, farge): # self._farge = farge # def printFarge(self): # print(self._farge) # hund1 = Hund() # hund2 = hund1 # hund2.endreFarge("lilla") # # hund1.printFarge() # tall1 = 5 # tall2 = tall1 # tall2 += 10 # # print(tall1) # # print(tall2) # streng1 = "hei" # streng2 = streng1 # streng2 = streng1.capitalize() # print(streng1) # print(streng2) # liste1 = [1, 2, 3, 4, 5] # liste2 = liste1 # liste2[2] = 6 # print(liste1) class Blomst: def __init__(self, art, hoyde): self._art = art self._hoyde = hoyde self._status = True self._dager_siden_vanning = 0 def hent_status(self): return self._status def skriv_ut_info(self): string = "Art: " + self._art string += "\nHoyde: " + str(self._hoyde) if self._status: string += "\nBlomsten har det: Bra" else: string += "\nBlomsten har det: D?rlig" string += "\nDager siden vanning: " + str(self._dager_siden_sanning) print(string) def neste_dag(self): self._dager_siden_vanning += 1 if self._dager_siden_vanning > 3: self._status = False if self._status: self._hoyde += 1 def vann(self): if self._dager_siden_vanning < 3: self._status = False else: self._status = True self._dager_siden_vanning = 0