Answer:
class PersonInfo:
def __init__(self):
self.num_kids = 0
def inc_num_kids(self):
self.num_kids += 1
person1 = PersonInfo()
print('Kids:', person1.num_kids)
person1.inc_num_kids()
print('New baby, kids now:', person1.num_kids)
Explanation:
Line 1 of the code, we define the class PersonInfo. Line 3 of the code is the function that will increment the member data num_kids.
If you have icloud then you can transfer them.
Answer:
D, most likely thats what I was taught .
Answer:
Explanation:
Since the array is not provided, I created a Python function that takes in the array and loops through it counting all of the words that are longer than 5. Then it returns the variable longer_than_five. To test this function I created an array of words based on the synapse of Pride and Prejudice. The output can be seen in the attached picture below.
def countWords(p_and_p_words):
longer_than_five = 0
for word in p_and_p_words:
if len(word) > 5:
longer_than_five += 1
return longer_than_five
Answer:
a) 4 processes
b) 2 resources
c) R1: 2 instances
R2: 2 instances
d) R2
e) R1
f) R1
g) No resource
h) R1
i) R2
j) R2
k) No
l)No deadlock
Explanation:
You need to know that the resources that are required by the processes for completion are shown by the request edge and the resources allocated are shown by the allocation edge. And thus, we can find what resources are allocated to the process, and required for the completion accordingly. And here again, the cycle is created, and hence deadlock may or may not occur. However, we see that resources have multiple instances and get freed on time. And hence, deadlock does not occur.
Like,
P4 uses R2 and free one instance of R2.
P3 then uses one instance of R2 and free R2.
P3 then uses one instance of R3 and free R3.
P1 uses one instance of R1 and free R1 one instance
P1 then uses R2 and free R2.
P2 uses R1 and free R1.
Hence, all the processes are complete and deadlock does not occur.