<jupyter_start><jupyter_text>Level Up! Your Scientific Coding Level 3: Object-oriented ProgrammingThis example was created by <NAME> during the Level 3 webinar. For the full example, see his repository at https://github.com/BCampforts/python_corona_simulation, forked from https://github.com/paulvangentcom/python_corona_simulation.<jupyter_code>class Virus:
    def __init__(self, name,infection_chance,infection_range,recovery_duration):
        self.name = name
        self.infection_chance = infection_chance
        self.infection_range = infection_range       
        
    def documentSelf(self):
        print('The name of this virus = ' + self.name)
        print('The infection chance = ' + str(self.infection_chance))  
        
    def infect(self):
        pass 
# v1 = Virus()
# v1.name = 'virus1'
# v1.infection_chance=0.1
# v1.infection_range=0.2
# v1.recovery_duration=10

# v2 = Virus()
# v2.name = 'SARS_CoV_2'
# v2.infectionChance=0.3
# v2.infection_range=0.4
# v2.recovery_duration=20

v1= Virus('virus1',0.1,0.2,10)
v2= Virus('SARS_CoV_2',0.3,0.4,20)
v1.documentSelf()
v2.documentSelf()
v2.documentSelf()
class LethalVirus(Virus):
    
    def __init__(self, name,infection_chance,infection_range,recovery_duration,mortality_rate):
        self.name = name
        self.infection_chance = infection_chance
        self.infection_range = infection_range
        self.recovery_duration = recovery_duration   
        self.mortality_rate = mortality_rate
        
    def documentMortality(self):
        print('The mortality of this virus = ' + str(self.mortality_rate))
        
    def recover_or_die(self):
        pass 
v2 = LethalVirus('SARS_CoV_2',0.3,0.4,20,0.01)
v2.documentSelf()
v2.documentMortality()
type(v2)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10841332580463016, 'fraction_numerical': 0.033314511575381144, 'mean_word_length': 3.7506702412868633, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '197145', 'license': 'MIT', 'n_tokens_mistral': 652, 'n_tokens_neox': 607, 'n_words': 108, 'path': 'createVirus.ipynb', 'repo_name': 'csdms/level-up', 'size': '1783'}