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
Llana [10]
3 years ago
14

Create a Person Class that:

Computers and Technology
1 answer:
alekssr [168]3 years ago
6 0

Answer:

See explaination

Explanation:

#Create a person class

class Person:

#Constructor

def __init__(self,firstName,lastName,age,gender):

if firstName=="":

raise Exception('First name should not be empty')

self.firstName=firstName

if lastName=="":

raise Exception('Last name should not be empty')

self.lastName=lastName

if(age<0 or age>100):

raise Exception('Age should be within range 0-100')

self.age=age

if(gender!='M' and gender!='F' and gender!='T'):

raise Exception('Gender should be M/F/T')

self.gender=gender

#Create a student class as a subclass of Person

class Student(Person):

#constructor

def __init__(self,firstName,lastName,age,gender,gpa):

Person.__init__(self,firstName,lastName,age,gender)

if(gpa<0 or gpa>4):

raise Exception('GPA should be 0-4')

self.gpa=gpa

#Function to display graduation status

def gradStatus(self):

print('Getting There!!')

#Create a graduate class as a subclass of Student

class Graduate(Student):

#constructor

def __init__(self,firstName,lastName,age,gender,gpa,gradYear,jobStatus):

Student.__init__(self,firstName,lastName,age,gender,gpa)

if(not gradYear.isdigit()):

raise Exception('Graduation year should be integer')

self.gradYear=gradYear

if(jobStatus!='Y' and jobStatus!='N'):

raise Exception('Job status should be Y/N')

self.jobStatus=jobStatus

#Function to display graduation status

def gradStatus(self):

print('I am Finished!!')

#Function to calculate total graduate student

def totalGraduates(graduate):

return len(graduate)

#Average gpa

def avgGpa(graduate):

sum=0

for grad in graduate:

sum+=grad.gpa

return sum/len(graduate)

#Average age

def avgAge(graduate):

avg=0

count=0

for grad in graduate:

if grad.gender=='M' or grad.gender=='F':

avg+=grad.age

count+=1

return avg/count

#Total Number of Male and Female Graduated Students who have jobs.

def totalJob(graduate):

count=0

for grad in graduate:

if grad.jobStatus=='Y':

count+=1

return count

#Test method

def main():

#Create 5 graduates

graduate=[]

graduate.append(Graduate("Adorn",'Antony',20,'M',3.0,"2011",'Y'))

graduate.append(Graduate("Amelia",'Anus',20,'F',3.5,'2011','Y'))

graduate.append(Graduate("Bambi",'Antony',20,'F',3,'2011','N'))

graduate.append(Graduate("Stephen",'Josh',20,'M',2,'2011','N'))

graduate.append(Graduate("Milli",'Markos',20,'F',4,'2011','Y'))

#Total Number of Graduated Students (use a dunder method to display this).

print('Total Number of Graduated Students: ',totalGraduates(graduate))

#Average GPA of all Graduated Students

print('Average GPA of all Graduated Students: %.2f'%avgGpa(graduate))

#Average Age of the Male and the Female Graduated Students

print('Average age of the Male and the Female Graduated Students: %.2f'%avgAge(graduate))

#Total Number of Male and Female Graduated Students who have jobs.

print('Total Number of Male and Female Graduated Students who have jobs: ',totalJob(graduate))

main()

You might be interested in
Which statement describes a mobile device feature? Docking stations can add some functionality to mobile devices such as video o
pogonyaev

Answer:

<em>The statement that describes a mobile device feature is docking stations can add some functionality to mobile devices such as video output.</em>

Explanation:

Because a docking station is a device that connects a mobile to multiple peripherals. It provides a single connection point that allows a mobile to function like a desktop computer.

8 0
4 years ago
Using your idea about how to solve this DUI problem, list two actions you can take that will make more people aware of this issu
s2008m [1.1K]
Drunk driving seems to be a big problem with teens because they are usually not experienced in driving. Once they drink and drive they have a false sense of invincibility and make poor decisions behind the wheel. In order to keep the numbers of drunk teen crashes declining, there should be testimonial videos of the people that have been affected by drunk drivers.

Another idea is, one group trying to end drunk driving. It's mission is to end drunk driving, help fight drugged driving, support the victims of these violent crimes, and prevent underage drinking.

Hope I helped !!!!^_~!!!
8 0
4 years ago
Which two benefits can be expected from KCS adoption if universal Containers wants to implement best practices for its customer
drek231 [11]

Answer:

B. A knowledge article life cycle that evolves based on usage and demand.

Explanation:

As new information is gathered on the product and the type of issues that customers encounters, the knowledge article can be updated to inform the customer on how to handle their problem.

3 0
4 years ago
Describe two benefits of the community of replacing the printed copy with an online version.
DiKsa [7]

Answer:

less costs

Explanation:

saves more money

easy to use for everyone

6 0
3 years ago
Cool fchgjvkugyftdycfhgjkliugytbnhmjku
alexandr1967 [171]

Answer:

the cats face XD

Explanation:

3 0
3 years ago
Other questions:
  • What’s a sign you should talk to an adult about your online time
    14·2 answers
  • What does the e in email stand for
    8·2 answers
  • Which of the following is a step in paraphrasing?
    14·2 answers
  • Create a cell reference in a formula by typing in the cell name or
    7·2 answers
  • How to can you avoid becoming a victim of identity theft?
    10·1 answer
  • C. What is the computer memory? What is the role of the memory in a computer?​
    14·1 answer
  • It is used to show the program and files that are open.
    12·1 answer
  • What three actions happen when you cloak a folder or file?
    6·1 answer
  • Jacob holds a Computer Hacking Forensic Investigator (CHFI) certification. Which of the following responsibilities should Jacob
    12·1 answer
  • I don't want my large video files using up all my hard drive space . can i archive my videos in on dvds or blu rays?
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!