You are on page 1of 1

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()

You might also like