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
klasskru [66]
4 years ago
10

Define the instance method inc_num_kids() for PersonInfo. inc_num_kids increments the member data num_kids. Sample output for th

e given program with one call to inc_num_kids():

Computers and Technology
1 answer:
kow [346]4 years ago
7 0

Answer:

This is the instance method inc_num_kids()

def inc_num_kids(self):

       self.num_kids += 1

Explanation:

The first line is the definition of function inc_num_kids() which has a parameter self. self is basically an instance of  class PersonInfo

self.num_kids += 1 this statement incremented the data member num_kids by 1. This means that the instance method inc_num_kids, using instance self, increments the value of num_kids data member by 1.

The complete program is as following:

class PersonInfo:  #class name PersonInfo

   def __init__(self):   #constructor of the class

       self.num_kids = 0  # data member num_kids

   def inc_num_kids(self):  # method inc_num_kids

       self.num_kids += 1  #increments num_kids by 1

person1 = PersonInfo()  #creates object person of class PersonInfo

print('Kids:', person1.num_kids)  # prints num_kids value before increment

person1.inc_num_kids()  #calls inc_num_kids method to increment num_kids

print('New baby, kids now:', person1.num_kids) #prints the value of num_kids after increment by inc_num_kids method

The person1 object first access the initial value of num_kids initialized by the constructor. So the first value of num_kids is 0. self.num_kids = 0  This statement assigns the value 0 to num_kids data member. Next the method inc_num_kids() using the object person1. Now when this method is called the value of data member num_kids is incremented to 1.

So previously the value was 0 which now increments by 1 and becomes 1. Last print statement displays this new value which is incremented by the inc_num_kids() method.

Hence the output is:

Kids: 0

New baby, kids now: 1

The program along with its output is attached.

You might be interested in
Microsoft Paint can be described as a digital sketch pad ?
alexira [117]
Yes I can be be a digital sketch pad

HOPE THIS HELPS!!!!!!!
4 0
3 years ago
Match each command group under Picture Tools to the appropriate tasks.
FrozenT [24]

Answer:

look at the attachment for correct answers.

6 0
3 years ago
Write a C Program to Print the initial letter of Name Ferdous
Murrr4er [49]

Answer:

The answer to this question is given below in the explanation section.

Explanation:

The question is about writing a C program that prints the initial letter of Name Ferdous.

Therefore, below is the given complete code that prints the first letter of the name Ferdous.

<em>#include <stdio.h> </em><em>/*import strandard input/output library*/</em>

<em>#include<string.h></em><em> /*import string library to handle string type of data*/</em>

<em> </em>

<em>int main(void) </em><em> /*started the program execution- program entry point*/</em>

<em>{ </em>

<em>char *str = "Firdous";</em><em>   /*char to pointer str contains string "Firdous"*/</em>

<em>int len = strlen(str);  </em><em> /*this line of code is not neccary, but if you print other character for example last character of the name then you can use it*/</em>

<em>printf("First Letter of the name is: %c", str[0]); </em><em>  /*print first letter of the name*/</em>

<em>} </em><em>  /**program terminated*/</em>

5 0
3 years ago
Select the correct answer.
storchak [24]

Answer:

B. Planning

Explanation:

I believe the developer establishes the project goals in the planning phase.

6 0
4 years ago
What is a typical grace period for a credit card...
Schach [20]
It is 20 to 25 days so c is correct
6 0
3 years ago
Read 2 more answers
Other questions:
  • Once you've connected to a data source, which button would you select to add a first name to your form letter?
    6·2 answers
  • Can somebody help me with this problem
    10·1 answer
  • Which skill refers to the ability to visualize and implement possible business solutions to problems?
    6·1 answer
  • An ARP broadcast is sent to the special MAC address _______.
    9·1 answer
  • E-mail is an temporary message medium.<br> a. True<br> b. False
    5·2 answers
  • Which View option allows you to view your document as it would appear when posted online?
    8·1 answer
  • Define a method printFeetInchShort, with int parameters numFeet and numInches, that prints using ' and " shorthand. End with a n
    7·2 answers
  • The purpose of the ________ in a database system is to receive requests from applications and to translate those requests into r
    12·1 answer
  • The following Mic1 microcode excerpt shows support for a possible 7 bit opcode, 8 bit integer argument machine instruction (orga
    14·1 answer
  • Write a C++ function, smallestIndex, that takes as parameters an int array and its size and returns the index of the first occur
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!