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
The scheme function (mult2-diff Ist) should take one argument, a list of numbers, and results in multiplying each number in the
JulijaS [17]

Answer:

The solution code is written in Python.

  1. def mult2_diff(lst):
  2.    num_list = []
  3.    for x in lst:
  4.        num_list.append(x * 2)
  5.    diff = num_list[0]
  6.    for i in range(1, len(num_list)):
  7.        diff = diff - num_list[i]
  8.    
  9.    print(diff)

Explanation:

Firstly, based on the requirement stated in the question, define a function <em>mult2_diff() </em>that takes one argument, <em>lst</em>, which is a list of numbers (Line 1).

This function is expected to multiply each number in the list by two and then followed with computing the difference. To do so, let's try to attempt the first function task, multiplying numbers.  Create a new list, num_list, to hold the multiplied numbers (Line 2). Use a for loop to traverse through each number in the input list, <em>lst</em>, and multiply each of them by two and add it to the <em>num_list </em>(Line 4-5).

To attempt the second function task, create another variable, <em>diff</em>, to hold the value of calculated difference between the numbers in the <em>num_list</em>. Initialize <em>diff </em>with the first number in the <em>num_list</em>. Use a another for-loop to traverse through each number in the num_list starting with second index, <em>1</em>, and calculate the difference between the <em>diff </em>and the current number extracted from the <em>num_list </em>through indexing.

At last print the output of <em>diff</em> (Line 11).

6 0
3 years ago
A formal log-on procedure is the operating system’s last line of defense against unauthorized access.
Elina [12.6K]
The answer is A. true
7 0
3 years ago
When the tcp\ip translates a network layer address into a data link layer address (after not finding an entry for the network la
Pavel [41]
When the network stack translates an IP address (network address) to a MAC address (data link address) it sends a broadcast using ARP to all devices on the subnet asking who has the specified IP address.  The device with that IP address will then respond with it's MAC address to the ARP message's source.

With this in mind the answer to your question would either be broadcast or ARP request depending on what you have been learning in class.
6 0
2 years ago
Play among us with me
omeli [17]

Answer:

cool

Explanation:oof

8 0
2 years ago
Read 2 more answers
Word processing software allows users to do which of the following: format text design pages share documents mail merge document
Sergio039 [100]
Well most word processing softwares allow you to do many things to a document, if you use google documents or microsoft word i'm pretty sure you can do all of those things
5 0
3 years ago
Read 2 more answers
Other questions:
  • Using a database of precomputed hashes from sequentially calculated passwords called a(n) __________, an attacker can simply loo
    14·1 answer
  • You want to plug a keyboard into the back of a computer. you know that you need to plug the keyboard cable into a ps/2 port. whi
    9·1 answer
  • The identification of critical information is a key part of the OPSEC process because: a) It is required by the JTF commander to
    13·1 answer
  • You can create a database using one of the many templates available or by creating a new ______ database.
    9·1 answer
  • A lever has an effort arm that is 8 meters long and the residence (load) arm that is 1.5 meters long, how much effort is needed
    7·1 answer
  • When performing conflict management, it is important to identify your;
    6·1 answer
  • An
    9·1 answer
  • Which of the following must be configured in certain applications to help ensure data aggregation and data isolation are impleme
    15·1 answer
  • If there are over 1,000 websites about a certain topic, the information is reliable. A. True B. False
    12·1 answer
  • HOW TO GET RID OF THESE LINES?? PLS WILL GIVE BRAINLIEST
    8·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!