Last active
April 29, 2019 11:33
-
-
Save tspycher/f7d6a07b0e4b99fd7d2b95af1a5cfbd7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name = "Hubert" | |
class Thing(): | |
attributes = { | |
"size": 12, | |
"weigth": 20, | |
"name": "a thing" | |
} | |
@property | |
def name(self): | |
global name | |
return name | |
def create_string(self, y:int=20): | |
nums = "" | |
for n in range(y): | |
nums += str(n) | |
return nums | |
def division(self, a:float, b:float) -> float: | |
try: | |
return a / b | |
except Exception as e: | |
return 0 | |
def get_attribute(self, name): | |
for k,v in self.__class__.attributes.items(): | |
if k == name: | |
return v | |
def get_a_list(self): | |
x = [1,2,3,4,5] | |
for y in x: | |
if y == 1: | |
x.append(6) | |
return x | |
x = Thing() | |
print(x.create_string(10)) | |
print(x.name) | |
print(x.division(10, 5)) | |
print(x.get_attribute("name")) | |
print(x.get_a_list()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment