1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Rama09 [41]
3 years ago
6

Define the method object 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
Computers and Technology
1 answer:
CaHeK987 [17]3 years ago
7 0

Answer:

The answer to this question can be given as:

Program:

#define class.

class PersonInfo:

   def __init__(self):  #constructor

       self.num_kids = 0

   def inc_num_kids(self):   #define function inc_num_kids()

       self.num_kids = self.num_kids + 1  

       return self.num_kids  #return value.

p= PersonInfo()      # creating object  

print('Kids:', p.num_kids)  #print value

p.inc_num_kids() #call function

print('New baby, kids now:', p.num_kids) #print value

Output:

Kids: 0

New baby, kids now: 1

Explanation:

The description of the above python program as follows:

  • In this program firstly we define the class that is PersonInfo. In this class we define the constructor that is def __init__() and one function that is  def inc_num_kids().
  • The constructor is called automatically when the class object is created. In this constructor, we use the self as a parameter that is used to access variables that belong to class.
  • In the constructor, we define the variable that is "num_kids". We assign value to a variable that is "0" and use the self for holding reference to the variable.
  • Then we define the function. In this function, we increment the value of the variable by 1 and return its value.
  • Then we create a class object that is p and call the function and print its value.  

You might be interested in
Which statement does not describe the guidelines for the use of text in presentation programs?
olganol [36]
Choice a
have a great day

7 0
3 years ago
Who uses super computer
Delvig [45]
Aerospace, petroleum, and automotive industries
3 0
2 years ago
Which of the following is a group of computer systems and computing hardware devices linked together through various communicati
Art [367]
Digital network, as it refers to the series of connected and linked computing devices into a network as described in this question.
6 0
1 year ago
Explain what will happen if we continue to use fossil fuels at the rate we are now and what impacts it will have on the planet.
Westkost [7]

Answer:

At the point when non-renewable energy sources are singed, they discharge carbon dioxide and other ozone depleting substances, which thusly trap heat in our air, making them the essential supporters of an Earth-wide temperature boost and environmental change. At the point when we consume oil, coal, and gas, we don't simply meet our vitality needs—we drive the current an unnatural weather change emergency also. Non-renewable energy sources produce huge amounts of carbon dioxide when consumed. Carbon discharges trap heat in the air and lead to environmental change.

7 0
3 years ago
In a linux script, the line ____ is important because it identifies the file as a script.
igor_vitrenko [27]
The closest line to that would be the first line:


#!/bin/bash

echo "Hello World!"


BTW, the "#!" is referred to as a she-bang. When those are the first characters executed, the (requires an absolute path) program that follows is launched, and the rest of this file is given to it as data. To run this like a program, the execute permissions need to be set ( chmod 0755 script.sh ).
8 0
2 years ago
Other questions:
  • You have a Bluetooth headset that integrates with your computer so that you can talk to partners through Microsoft Lync. This is
    6·2 answers
  • A musical compact disc is an example of
    13·1 answer
  • Most graphics software uses a process called pixel _________ to create new pixels by averaging the colors of nearby pixels.â
    6·1 answer
  • In Word, a red wavy underline indicates a/an
    15·1 answer
  • If you see ________________________ in a cell, it means the column is not wide enough to display the cell content. Select one: a
    15·1 answer
  • Does anyone know about the progressive era?
    15·2 answers
  • Draw a flow chart that accepts mass and volume as input from the user. The flow chart should compute and display the density of
    8·1 answer
  • Hardware refers to programs and protocols used on a computer system.<br><br> True<br> False
    8·2 answers
  • What would be the total width of the div in the code below?
    11·2 answers
  • Eun-Joo is working on a circuit board. There is no electrical current flowing through a certain switch on the circuit board.
    9·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!