def std_dev(list) : sum = 0 for p in list: sum += p.age avg = sum/len(list) # variance is average of squares of difference of each number and their average square_sum = 0; for p in list: square_sum +=...


Write a class called Person that has twoprivate data members - the person's name and age. It should have an init method that takes two values and uses them to initialize the data members. It should have a get_age method.


Does the code have a get_age method?


def std_dev(list) :<br>sum = 0<br>for p in list:<br>sum += p.age<br>avg = sum/len(list)<br># variance is average of squares of difference of each number and their average<br>square_sum = 0;<br>for p in list:<br>square_sum += (p.age-avg)**2<br>var = square_sum/len(list)<br># standard deviation is root of variance<br>std = var**0.5<br>return std<br>class Person:<br>def<br>_init_(self, name, age):<br>self.name = name<br>self.age = age<br>pl = Person(

Extracted text: def std_dev(list) : sum = 0 for p in list: sum += p.age avg = sum/len(list) # variance is average of squares of difference of each number and their average square_sum = 0; for p in list: square_sum += (p.age-avg)**2 var = square_sum/len(list) # standard deviation is root of variance std = var**0.5 return std class Person: def _init_(self, name, age): self.name = name self.age = age pl = Person("John", 36) p2 = Person("Rick", 49) p3 = Person("Kylie", 28) person_list = [p1,p2,p3] answer = std_dev(person_list) print("standard daviation is : ", answer)

Jun 05, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here