Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions gb-python-ls6-1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import time


class TrafficLight:

def running(self):
while True:
self.__color = "red"
print(f"{self.__color}")
time.sleep(7)
self.__color = "yellow"
print(f"{self.__color}")
time.sleep(2)
self.__color = "green"
print(f"{self.__color}")
time.sleep(7)

t = TrafficLight()
t.running()
12 changes: 12 additions & 0 deletions gb-python-ls6-2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

class Road:
def __init__(self, length, width):
self._length = length
self._width = width

def mass_calculation(self, weight=25, thickness=5):
return f'Asphalt mass: {(self._length * self._width * weight * thickness) / 1000} tons'


road = Road(5000, 20)
print(road.mass_calculation())
19 changes: 19 additions & 0 deletions gb-python-ls6-3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
class Worker:
def __init__(self, name, surname, position, wage, bonus):
self.name = name
self.surname = surname
self.position = position
self._income = {"profit": wage, "bonus": bonus}


class Position(Worker):
def get_full_name(self):
return f"{self.name} {self.surname}"

def get_full_profit(self):
return f"{sum(self._income.values())}"

manager = Position("Micky", "Mouse", "CEO", 200000, 25000)
print(manager.get_full_name())
print(manager.position)
print(manager.get_full_profit())
31 changes: 31 additions & 0 deletions gb-python-ls6-5.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
class Stationery:
def __init__(self, title="Something that can draw"):
self.title = title

def draw(self):
print(f"Just start drawing! {self.title}")


class Pen(Stationery):
def draw(self):
print(f"Start write with {self.title} pen!")


class Pencil(Stationery):
def draw(self):
print(f"Start decorate with {self.title} pencil!")


class Marker(Stationery):
def draw(self):
print(f"Start highlight with {self.title} marker!")


stat = Stationery()
stat.draw()
pen = Pen("Big")
pen.draw()
pencil = Pencil("Faber-Castell")
pencil.draw()
marker = Marker("Erich Krause")
marker.draw()