Write a Student class to get the desired output as shown below. 1. Create a Student class and a class variable called ID initialized with 0. 2. Create a constructor that takes 4 parameters: name, department, age and cgpa. 3. Write a get_details() method to represent all the details of a Student 4. Write a class method from_String() that takes 1 parameter which includes name, department, age and cgpa all four attributes in string.

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%
Write a Student class to get the desired output as shown below.
1. Create a Student class and a class variable called ID initialized with 0.
2. Create a constructor that takes 4 parameters: name, department, age and cgpa.
3. Write a get_details() method to represent all the details of a Student
4. Write a class method from_String() that takes 1 parameter which includes
name, department, age and cgpa all four attributes in string.
#Write your code here for subtasks 1-6.
OUTPUT
ID: 1
s1 = Student("Samin", "CSE", 21, 3.91)
s1.get_details()
print("--
s2 = Student("Fahim", "ECE", 21, 3.85)
s2.get_details()
print("-
s3 = Student("Tahura", "EEE", 22, 3.01)
s3.get_details()
print("-
s4 = Student.from_String("Sumaiya-BBA-23-3.96")
s4.get_details()
Name: Samin
Department: CSE
Age: 21
CGPA: 3.91
----")
----")
ID: 2
Name: Fahim
%3D
Department: ECE
Age: 21
CGPA: 3.85
-")
%3D
ID: 3
Name: Tahura
Department: EEE
Age: 22
CGPA: 3.01
# Write the answer of subtask 5 here
# Write the answer of subtask 6 here
ID: 4
#You are not allowed to change the code above Name: Sumaiya
Department: BBA
Age: 23
CGPA: 3.96
5. Explain the difference between a class variable and an instance variable. Print
your answer at the very end of your code.
6. What is the difference between an instance method and class method? Print your
answer at the very end
Transcribed Image Text:Write a Student class to get the desired output as shown below. 1. Create a Student class and a class variable called ID initialized with 0. 2. Create a constructor that takes 4 parameters: name, department, age and cgpa. 3. Write a get_details() method to represent all the details of a Student 4. Write a class method from_String() that takes 1 parameter which includes name, department, age and cgpa all four attributes in string. #Write your code here for subtasks 1-6. OUTPUT ID: 1 s1 = Student("Samin", "CSE", 21, 3.91) s1.get_details() print("-- s2 = Student("Fahim", "ECE", 21, 3.85) s2.get_details() print("- s3 = Student("Tahura", "EEE", 22, 3.01) s3.get_details() print("- s4 = Student.from_String("Sumaiya-BBA-23-3.96") s4.get_details() Name: Samin Department: CSE Age: 21 CGPA: 3.91 ----") ----") ID: 2 Name: Fahim %3D Department: ECE Age: 21 CGPA: 3.85 -") %3D ID: 3 Name: Tahura Department: EEE Age: 22 CGPA: 3.01 # Write the answer of subtask 5 here # Write the answer of subtask 6 here ID: 4 #You are not allowed to change the code above Name: Sumaiya Department: BBA Age: 23 CGPA: 3.96 5. Explain the difference between a class variable and an instance variable. Print your answer at the very end of your code. 6. What is the difference between an instance method and class method? Print your answer at the very end
Expert Solution
steps

Step by step

Solved in 2 steps with 5 images

Blurred answer
Knowledge Booster
Unreferenced Objects
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
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