當前位置: 首頁>>代碼示例>>Python>>正文


Python person.Person方法代碼示例

本文整理匯總了Python中person.Person方法的典型用法代碼示例。如果您正苦於以下問題:Python person.Person方法的具體用法?Python person.Person怎麽用?Python person.Person使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在person的用法示例。


在下文中一共展示了person.Person方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _create_population

# 需要導入模塊: import person [as 別名]
# 或者: from person import Person [as 別名]
def _create_population(self, initial_infected):
        # TODO: Finish this method!  This method should be called when the simulation
        # begins, to create the population that will be used. This method should return
        # an array filled with Person objects that matches the specifications of the
        # simulation (correct number of people in the population, correct percentage of
        # people vaccinated, correct number of initially infected people).
        population = []
        infected_count = 0
        while len(population) != pop_size:
            if infected_count !=  initial_infected:
                # TODO: Create all the infected people first, and then worry about the rest.
                # Don't forget to increment infected_count every time you create a
                # new infected person!
                pass
            else:
                # Now create all the rest of the people.
                # Every time a new person will be created, generate a random number between
                # 0 and 1.  If this number is smaller than vacc_percentage, this person
                # should be created as a vaccinated person. If not, the person should be
                # created as an unvaccinated person.
                pass
            # TODO: After any Person object is created, whether sick or healthy,
            # you will need to increment self.next_person_id by 1. Each Person object's
            # ID has to be unique!
        return population 
開發者ID:Product-College-Courses,項目名稱:CS-1-Programming-Fundamentals,代碼行數:27,代碼來源:simulation.py

示例2: _infect_newly_infected

# 需要導入模塊: import person [as 別名]
# 或者: from person import Person [as 別名]
def _infect_newly_infected(self):
        # TODO: Finish this method! This method should be called at the end of
        # every time step.  This method should iterate through the list stored in
        # self.newly_infected, which should be filled with the IDs of every person
        # created.  Iterate though this list.
        # For every person id in self.newly_infected:
        #   - Find the Person object in self.population that has this corresponding ID.
        #   - Set this Person's .infected attribute to True.
        # NOTE: Once you have iterated through the entire list of self.newly_infected, remember
        # to reset self.newly_infected back to an empty list! 
開發者ID:Product-College-Courses,項目名稱:CS-1-Programming-Fundamentals,代碼行數:12,代碼來源:simulation.py

示例3: updateRecord

# 需要導入模塊: import person [as 別名]
# 或者: from person import Person [as 別名]
def updateRecord():
    key=entries['key'].get()
    if key in db:
        record=db[key]
    else:
        from person import Person
        record=Person(name='?',age='?')
    for field in fieldnames:
        setattr(record,field,eval(entries[field].get()))
    db[key]=record

# if __name__=='__main__': 
開發者ID:lzhaoyang,項目名稱:python_programing,代碼行數:14,代碼來源:peoplegui.py

示例4: __init__

# 需要導入模塊: import person [as 別名]
# 或者: from person import Person [as 別名]
def __init__(self, mother, doctor):
        """Initialize a Birth object."""
        super(Birth, self).__init__(sim=mother.sim)
        self.town = mother.town
        self.biological_mother = mother
        self.mother = mother
        self.biological_father = mother.impregnated_by
        self.father = self.mother.spouse if self.mother.spouse and self.mother.spouse.male else self.biological_father
        self.subject = Person(sim=mother.sim, birth=self)
        if self.father and self.father is not self.biological_father:
            self.adoption = Adoption(subject=self.subject, adoptive_parents=(self.father,))
        if self.biological_father is self.mother.spouse:
            self.mother.marriage.children_produced.add(self.subject)
        self.doctor = doctor
        # Update the sim's listing of all people's birthdays
        try:
            mother.sim.birthdays[(self.month, self.day)].add(self.subject)
        except KeyError:
            mother.sim.birthdays[(self.month, self.day)] = {self.subject}
        self._name_baby()
        self._update_mother_attributes()
        if self.mother.town:
            self._take_baby_home()
        if self.mother.occupation:
            self._have_mother_potentially_exit_workforce()
        if self.doctor:  # There won't be a doctor if the birth happened outside the town
            self.hospital = doctor.company
            self.nurse = {
                position for position in self.hospital.employees if
                position.__class__.__name__ == 'Nurse'
            }
            self.doctor.baby_deliveries.add(self)
        else:
            self.hospital = None
            self.nurses = set() 
開發者ID:james-owen-ryan,項目名稱:talktown,代碼行數:37,代碼來源:life_event.py

示例5: setUp

# 需要導入模塊: import person [as 別名]
# 或者: from person import Person [as 別名]
def setUp(self):
        # test data
        self.first_name = "Marcus"
        self.last_name = "Willock"
        self.birthday = date(1988, 1, 19)
        self.gender = "male"
        self.likes = ["Python", "Golang"]
        self.dislikes = ["Waking up early", "reality tv"]

        # creating a Marcus clones!
        self.person = Person(self.first_name,
                             self.last_name,
                             self.birthday,
                             self.gender,
                             self.likes,
                             self.dislikes)

        self.relationship1 = "alter_ego"
        self.relationship2 = "hater"
        self.gender1 = "male"
        self.gender2 = "female"
        self.add_greeting1 = (self.relationship1, self.gender1, self.say_hi)
        self.add_greeting2 = (self.relationship1, self.gender2, self.say_hi)
        self.add_greeting3 = (self.relationship2, self.gender1, self.say_hi)
        self.add_greetings = [self.add_greeting1,
                              self.add_greeting2,
                              self.add_greeting3]

        self.greetings = Greetings(self.default_greeting) 
開發者ID:crazcalm,項目名稱:python-go-hello-to-the-world,代碼行數:31,代碼來源:test_greetings.py


注:本文中的person.Person方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。