adding all files done so far

This commit is contained in:
2019-07-10 20:18:31 +01:00
parent 13c0e9cb4d
commit e3ac390e8b
76 changed files with 8644 additions and 0 deletions

View File

@@ -0,0 +1,13 @@
class Celsius(object):
"""docstring for Celsius"""
def __init__(self, temperature=0):
super(Celsius, self).__init__()
self.temperature = temperature
@classmethod
def from_fahrenheit(cls, temperature=32):
temperature = (temperature - 32) / (9 / 5)
return cls(temperature)
def to_fahrenheit(self):
return (self.temperature * 1.8) + 32

View File

@@ -0,0 +1,26 @@
class P:
def __init__(self, x):
print('init')
self._x = x
@property
def x(self):
print('get')
return self._x
@x.setter
def x(self, x):
print('set')
if x < 0:
self._x = 0
elif x > 1000:
self._x = 1000
else:
self._x = x
def double(self):
return self.x * 2
def overwrite(self):
self.x = 20

View File

@@ -0,0 +1,32 @@
class Robot:
def __init__(self, name, build_year, lk=0.5,
lp=0.5):
self.name = name
self.build_year = build_year
self.__potential_physical = lk
self.__potential_psychic = lp
@property
def condition(self):
s = self.__potential_physical + self.__potential_psychic
if s <= -1:
return "I feel miserable!"
elif s <= 0:
return "I feel bad!"
elif s <= 0.5:
return "Could be worse!"
elif s <= 1:
return "Seems to be okay!"
else:
return "Great!"
def printer(self):
return self.condition
def __get__(self, instance, owner):
return 'get'
x = Robot("Marvin", 1979, 0.2, 0.4)
y = Robot("Caliban", 1993, -0.4, 0.3)