Professional Documents
Culture Documents
##############################
class Point:
def __init__(self, x, y):
self.x = x
self.y = y
def move(self):
print("move")
def draw(self):
print("draw")
class Person:
def __init__(self, name):
self.name = name
def talk(self):
print(f"Hi, I am {self.name}")
####################
class Star:
def __init__(self, name, solar_masses, color):
self.name = name
self.mass = solar_masses
self.color = color
def star_class(self):
if self.color == "red" or self.color == "RED":
print(f'The star {self.name} is a Red Giant.')
elif self.color == "blue" or self.color == "BLUE":
print(f'The star {self.name} is a Blue Giant.')
elif self.color == "white" or self.color == "WHITE":
print(f'The star {self.name} is a White Dwarf.')
elif self.color == "yellow" or self.color == "YELLOW":
print(f'The star {self.name} is a Yellow K1 Star.')
else:
print("This is not a star category")
cond = True
name = input("Introduceti numele stelei: ")
a = 1
c = "red"
while cond:
try:
cond = False
a = float(input("Enter the mass of the star in solar masses. "))
except ValueError:
print("Mass must be a number.")
cond = True
b = str(input("Enter the star color. "))
while b.upper() != "RED" and b.upper() != "BLUE" and b.upper() != "WHITE" and
b.upper() != "YELLOW":
print("IEnter the star color red, blue, yellow or white.")
b = str(input())
vega = Star(name, a, b)
vega.star_class()
name = input("Introduceti numele celei de-a doua stele. ")
orion = Star(name, a, c)
c = str(input(f"Enter {orion.name} Star color. "))
orion = Star(name, a, c)
orion.star_class()
######################################
class Point:
def __init__(self, x, y):
self.distance = self.distance
self.x = x
self.y = y
def distance(self):
self.distance = (self.x * self.x + self.y * self.y) ** 0.5
print(f"Distanta dintre punctul ({self.x}, {self.y}) si (0,0) este:
{round(self.distance,2)}")
##############################
class Mamifere:
def __init__(self, name):
self.name = name
def walk(self):
print(f"{self.name} can walk.")
class Dogs(Mamifere):
def bark(self):
print(f"{self.name} shits.")
class Cats(Mamifere):
pass
pasare = Mamifere("Bija")
pasare.walk()
caine = Dogs("Cucu")
caine.bark()
customer = {"1": "One", "2": "Two", "3": 'Three', "4": 'Four', "5": 'Five', "6":
'Six', "7": 'Seven', "8": 'Eight',
"9": "Nine", "0": 'Zero'}
############################################################
###################################################
customer = {
"name": "Ion Vasile",
"age": 30,
"is_verified": True
}
customer['birthdate'] = '1 ianuarie 1980'
print(customer["name"])
print(customer.get('name', 'default_value_ceva_daca_name_nu_exista'))