add dictionary task solution
This commit is contained in:
parent
856f1a4e33
commit
fb50f09bc9
@ -10,3 +10,4 @@ class Ship:
|
||||
# Ein Schiff ist lohnenswert, wenn der verbleibende Tiefgang nach Abzug
|
||||
# des Gewichts der Besatzung mehr als 20 Einheiten beträgt.
|
||||
return (self.draft - (self.crew * 1.5)) > 20
|
||||
|
||||
12
codewars/Interactive Dictionary.py
Normal file
12
codewars/Interactive Dictionary.py
Normal file
@ -0,0 +1,12 @@
|
||||
class Dictionary:
|
||||
def __init__(self):
|
||||
self.words = {}
|
||||
|
||||
def newentry(self, word, definition):
|
||||
self.words[word] = definition
|
||||
|
||||
def look(self, key):
|
||||
if key in self.words:
|
||||
return self.words[key]
|
||||
else:
|
||||
return f"Can't find entry for {key}"
|
||||
@ -0,0 +1,15 @@
|
||||
class Block:
|
||||
def __init__(self, dims):
|
||||
self.width = dims[0]
|
||||
self.length = dims[1]
|
||||
self.height = dims[2]
|
||||
def get_width(self):
|
||||
return self.width
|
||||
def get_length(self):
|
||||
return self.length
|
||||
def get_height(self):
|
||||
return self.height
|
||||
def get_volume(self):
|
||||
return self.width * self.length * self.height
|
||||
def get_surface_area(self):
|
||||
return 2 * (self.width * self.length + self.width * self.height + self.length * self.height)
|
||||
@ -3,3 +3,4 @@ def even_or_odd(number):
|
||||
return "Even"
|
||||
else:
|
||||
return "Odd"
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user