3.8.1: Basic inheritance.   Set course_student's last_name to Smith, age_years to 20, and id_num to 9999. Sample output for the given program:Name: Smith, Age: 20, ID: 9999   class PersonData: def __init__(self): self.last_name = '' self.age_years = 0 def set_name(self, user_name): self.last_name = user_name def set_age(self, num_years): self.age_years = num_years # Other parts omitted def print_all(self): output_str = 'Name: ' + self.last_name + ', Age: ' + str(self.age_years) return output_str class StudentData(PersonData): def __init__(self): PersonData.__init__(self) # Call base class constructor self.id_num = 0 def set_id(self, student_id): self.id_num = student_id def get_id(self): return self.id_num course_student = StudentData() ''' Your solution goes here ''' print('%s, ID: %s' % (course_student.print_all(), course_student.get_id()))

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
100%
3.8.1: Basic inheritance.
 
Set course_student's last_name to Smith, age_years to 20, and id_num to 9999. Sample output for the given program:Name: Smith, Age: 20, ID: 9999
 

class PersonData:
def __init__(self):
self.last_name = ''
self.age_years = 0

def set_name(self, user_name):
self.last_name = user_name

def set_age(self, num_years):
self.age_years = num_years

# Other parts omitted

def print_all(self):
output_str = 'Name: ' + self.last_name + ', Age: ' + str(self.age_years)
return output_str


class StudentData(PersonData):
def __init__(self):
PersonData.__init__(self) # Call base class constructor
self.id_num = 0

def set_id(self, student_id):
self.id_num = student_id

def get_id(self):
return self.id_num


course_student = StudentData()

''' Your solution goes here '''

print('%s, ID: %s' % (course_student.print_all(), course_student.get_id()))

entry level cyb x
E Home
Gradebook
zy Section 3.8 - C X
O (234) ITS128 F X
2 python - LAB:
b Search results X
* Search Results X
G 3.8.1: Basic inh x
+
i learn.zybooks.com/zybook/CYB_135_54915392/chapter/3/section/8?content_resource_id=33453629
= zyBooks My library > CYB/135: Object-Oriented Security Scripting home > 3.8: Derived classes
E zyBooks catalog
? Help/FAQ
Kenneth Schultz -
Check
Show answer
Feedback?
CHALLENGE
3.8.1: Basic inheritance.
АCTIVITY
Set course_student's last_name to Smith, age_years to 20, and id_num to 9999. Sample output for the given program:
Name: Smith, Age: 20, ID: 9999
346682.2019644.gx3zgy7
18
19 class StudentData (PersonData):
1 test
def _init_(self):
PersonData._init_(self)
20
passed
21
# Call base class constructor
22
self.id num = 0
23
All tests
passed
def set_id(self, student_id):
self.id_num = student_id
24
25
26
def get_id(self):
return self.id_num
27
28
29
30
31 course_student = StudentData()
32
33 ' Your solution goes here '''
34
35 print('%s, ID: %s' % (course_student.print_all(), course_student.get_id()))
Run
X Test aborted
Exited with
code 1
return
9:27 PM
O Type here to search
77°F Cloudy
9/17/2021
Transcribed Image Text:entry level cyb x E Home Gradebook zy Section 3.8 - C X O (234) ITS128 F X 2 python - LAB: b Search results X * Search Results X G 3.8.1: Basic inh x + i learn.zybooks.com/zybook/CYB_135_54915392/chapter/3/section/8?content_resource_id=33453629 = zyBooks My library > CYB/135: Object-Oriented Security Scripting home > 3.8: Derived classes E zyBooks catalog ? Help/FAQ Kenneth Schultz - Check Show answer Feedback? CHALLENGE 3.8.1: Basic inheritance. АCTIVITY Set course_student's last_name to Smith, age_years to 20, and id_num to 9999. Sample output for the given program: Name: Smith, Age: 20, ID: 9999 346682.2019644.gx3zgy7 18 19 class StudentData (PersonData): 1 test def _init_(self): PersonData._init_(self) 20 passed 21 # Call base class constructor 22 self.id num = 0 23 All tests passed def set_id(self, student_id): self.id_num = student_id 24 25 26 def get_id(self): return self.id_num 27 28 29 30 31 course_student = StudentData() 32 33 ' Your solution goes here ''' 34 35 print('%s, ID: %s' % (course_student.print_all(), course_student.get_id())) Run X Test aborted Exited with code 1 return 9:27 PM O Type here to search 77°F Cloudy 9/17/2021
entry level cyb x
E Home
Gradebook
zy Section 3.8 - C X
O (234) ITS128 F X
2 python - LAB:
b Search results X
* Search Results X
G 3.8.1: Basic inh x
+
i learn.zybooks.com/zybook/CYB_135_54915392/chapter/3/section/8?content_resource_id=33453629
= zyBooks My library > CYB/135: Object-Oriented Security Scripting home > 3.8: Derived classes
E zyBooks catalog
? Help/FAQ
Kenneth Schultz -
Check
Show answer
Feedback?
CHALLENGE
3.8.1: Basic inheritance.
АCTIVITY
Set course_student's last_name to Smith, age_years to 20, and id_num to 9999. Sample output for the given program:
Name: Smith, Age: 20, ID: 9999
346682.2019644.qx3zqy7
1 class PersonData:
def _init_(self):
self.last_name =
self.age_years = 0
2
1 test
passed
3
4
5
All tests
def set_name (self, user_name):
self.last_name
passed
7
= user_name
8
def set_age(self, num_years):
self.age_years = num_years
10
11
12
# Other parts omitted
13
def print_all(self):
output_str = 'Name: ' + self.last_name +
return output_str
14
Age: '+ str(self.age_years)
15
16
17
18
Run
X Test aborted
Exited with
code 1
return
9:27 PM
O Type here to search
77°F Cloudy
9/17/2021
Transcribed Image Text:entry level cyb x E Home Gradebook zy Section 3.8 - C X O (234) ITS128 F X 2 python - LAB: b Search results X * Search Results X G 3.8.1: Basic inh x + i learn.zybooks.com/zybook/CYB_135_54915392/chapter/3/section/8?content_resource_id=33453629 = zyBooks My library > CYB/135: Object-Oriented Security Scripting home > 3.8: Derived classes E zyBooks catalog ? Help/FAQ Kenneth Schultz - Check Show answer Feedback? CHALLENGE 3.8.1: Basic inheritance. АCTIVITY Set course_student's last_name to Smith, age_years to 20, and id_num to 9999. Sample output for the given program: Name: Smith, Age: 20, ID: 9999 346682.2019644.qx3zqy7 1 class PersonData: def _init_(self): self.last_name = self.age_years = 0 2 1 test passed 3 4 5 All tests def set_name (self, user_name): self.last_name passed 7 = user_name 8 def set_age(self, num_years): self.age_years = num_years 10 11 12 # Other parts omitted 13 def print_all(self): output_str = 'Name: ' + self.last_name + return output_str 14 Age: '+ str(self.age_years) 15 16 17 18 Run X Test aborted Exited with code 1 return 9:27 PM O Type here to search 77°F Cloudy 9/17/2021
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education