Define the instance method inc_num_kids() for PersonInfo. inc_num_kids increments the member data num_kids. Sample output for the given program with one call to inc_num_kids():

Microsoft Visual C#
7th Edition
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Joyce, Farrell.
Chapter9: Using Classes And Objects
Section: Chapter Questions
Problem 19RQ
icon
Related questions
Question
100%
Define the instance method inc_num_kids() for PersonInfo. inc_num_kids increments the member data num_kids.
Sample output for the given program with one call to inc_num_kids ():
Kids: 0
New baby, kids now: 1
Learn how our autograder works
487180.3542414.qx3zqy7
1 class PersonInfo:
2
345 ∞9
definit__(self):
self.num_kids = 0
# FIXME: Write inc_num_kids(self)
6 def inc_num_kids(self):
7
self.num_kids += 1
8 person1 = PersonInfo()
10 print (f Kids: {person1.num_kids}')
11 person1.inc_num_kids()
12 print (f'New baby, kids now: {person1.num_kids}')
Run X Not all tests passed
X Test aborted
Exited with return code 1.
Traceback (most recent call last):
File "main.py", line 11, in <module>
personl.inc_num_kids ()
AttributeError: 'PersonInfo' object has no attribute 'inc_num_kids'
Transcribed Image Text:Define the instance method inc_num_kids() for PersonInfo. inc_num_kids increments the member data num_kids. Sample output for the given program with one call to inc_num_kids (): Kids: 0 New baby, kids now: 1 Learn how our autograder works 487180.3542414.qx3zqy7 1 class PersonInfo: 2 345 ∞9 definit__(self): self.num_kids = 0 # FIXME: Write inc_num_kids(self) 6 def inc_num_kids(self): 7 self.num_kids += 1 8 person1 = PersonInfo() 10 print (f Kids: {person1.num_kids}') 11 person1.inc_num_kids() 12 print (f'New baby, kids now: {person1.num_kids}') Run X Not all tests passed X Test aborted Exited with return code 1. Traceback (most recent call last): File "main.py", line 11, in <module> personl.inc_num_kids () AttributeError: 'PersonInfo' object has no attribute 'inc_num_kids'
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 5 steps with 2 images

Blurred answer
Knowledge Booster
Developing computer interface
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,