Autres atomes
This commit is contained in:
parent
055ae67702
commit
f7212eb184
1 changed files with 35 additions and 4 deletions
39
main.py
39
main.py
|
|
@ -62,10 +62,6 @@ class Hydrogen(Atom):
|
|||
raise TypeError("Le nombre de neutrons de l'hydrogène doit être un entier entre 0 et 2")
|
||||
super().__init__(name, neutron_number)
|
||||
|
||||
def type_neutron_number():
|
||||
if type(self.neutron_number) != int:
|
||||
return "Le nombre de neutron d'est pas un entier"
|
||||
|
||||
@classmethod
|
||||
def atomic_number(cls):
|
||||
return 1
|
||||
|
|
@ -81,3 +77,38 @@ print(deuterium) # [1/2]H
|
|||
|
||||
'''
|
||||
|
||||
# Carbone
|
||||
|
||||
class Carbon(Atom):
|
||||
def __init__(self, name="Carbon", neutron_number=6):
|
||||
if not isinstance(neutron_number, int) or not 6 <= neutron_number <= 8:
|
||||
raise TypeError("Le nombre de neutrons du carbone doit être un entier entre 6 et 8")
|
||||
super().__init__(name, neutron_number)
|
||||
|
||||
@classmethod
|
||||
def atomic_number(cls):
|
||||
return 6
|
||||
|
||||
@classmethod
|
||||
def symbol(cls):
|
||||
return "C"
|
||||
|
||||
# Oxygène
|
||||
|
||||
class Oxygen(Atom):
|
||||
def __init__(self, name="Oxygen", neutron_number=8):
|
||||
if not isinstance(neutron_number, int) or not 6 <= neutron_number <= 20:
|
||||
raise TypeError("Le nombre de neutrons de l'oxygène doit être un entier entre 6 et 20")
|
||||
super().__init__(name, neutron_number)
|
||||
|
||||
@classmethod
|
||||
def atomic_number(cls):
|
||||
return 8
|
||||
|
||||
@classmethod
|
||||
def symbol(cls):
|
||||
return "O"
|
||||
|
||||
print(Hydrogen())
|
||||
print(Carbon())
|
||||
print(Oxygen())
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue