-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathevolation.py
More file actions
27 lines (27 loc) · 1015 Bytes
/
evolation.py
File metadata and controls
27 lines (27 loc) · 1015 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import matplotlib.pyplot as plt
print("🌟 Star Evolution Simulator")
print("---------------------------")
while True:
try:
mass = float(input("Enter the star's mass (in Solar masses, M☉): "))
if mass <= 0:
print("Mass cannot be zero or negative! Please enter again.")
continue
break
except ValueError:
print("Invalid input! Please enter a number.")
main_sequence_years = 1e10 * (mass ** -2.5)
red_giant_years = main_sequence_years * 0.1
if mass < 8:
final_stage = "White Dwarf"
elif mass < 20:
final_stage = "Neutron Star"
else:
final_stage = "Black Hole"
stages = ["Main Sequence", "Red Giant", "Final Stage"]
durations = [main_sequence_years, red_giant_years, 1]
cumulative = [0, main_sequence_years, main_sequence_years + red_giant_years]
print("\n🔭 Estimated Life Cycle:")
print(f"Main Sequence Phase: {main_sequence_years:.2e} years")
print(f"Red Giant Phase: {red_giant_years:.2e} years")
print(f"Final Stage: {final_stage}")