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
Helppppp meeee eeeeeee eee
zlopas [31]

Answer:

Thats the gas petal i believe so the accelerator

Explanation:

3 0
3 years ago
Read 2 more answers
Windows uses a memory-management technique known as ________ to monitor which applications you frequently use and preloads them
ad-work [718]
Windows uses a memory-management technique known as SuperFetch to monitor which applications you frequently use and preloads them into your system memory.
This technique is designed to speed up app launching by preloading certain apps based on the usage patterns of the user.

4 0
3 years ago
When applying a filter to a text layer, how can you ensure that the types editability is not lost
yarga [219]

Answer:

Convert the layer into a smart object.

Explanation:

7 0
4 years ago
You have a computer at home. The computer is connected to the Internet through a dial-up connection. Every time you connect to t
worty [1.4K]

Hiya!

When you connect to the internet (especially through a dial-up connection), your computer must make the request for network resources. This is usually done through a Modem, a device designed to establish and split the connection among your devices.

Fun fact; a dial up connection uses the same radio frequencies that you would use to talk on the phone; and they're in the audible spectrum. When you start up that connection, the reason all those funny noises happen is because it's "talking" to your ISP over those lines.

Hope this helps!

3 0
3 years ago
What are the steps of active listening?
SashulF [63]
1 prepare mentally
2 pay attention
3 allow the speaker to talk without interruption until he is done
4 provide feedback
5 repeat the feedback until you and the communicator are satisfied that the message was conveyed well
7 0
3 years ago
Other questions:
  • You have an executive who needs her print jobs handled above those of others. how would you accomplish this advanced printing co
    8·1 answer
  • Why do most programmers indent the conditionally executed statements in a decision structure?
    7·1 answer
  • Please answer these questions! Will mark Brainliest!!
    7·1 answer
  • You realize your computer has been infected with malware. The program has been copying itself repeatedly, using up resources. Wh
    10·1 answer
  • A<br> is a reduced-size version of a graphic image used to help recognize and organize pictures.
    5·1 answer
  • Write a partial class that shows a class constant and an instance method. Write an instance method that converts feet to inches
    9·1 answer
  • Develop Swimlane Activity diagram for Assignment announcement and submission system.
    6·1 answer
  • What critical-thinking tool is being used when asking the question, Is this information specific enough?
    9·1 answer
  • What is the output of the following code:
    12·1 answer
  • Write aemail to brother for laptop for vitrual classes​
    7·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!