Research breakthrough possible @S-Logix pro@slogix.in

Office Address

Social List

To create simple python program to display student result in python3.

Description

To create simple python program to display student result in python3.

Process

   Create Student class.

   Declare the methods details, _print and loop.

   Create object for student class.

   Pass the arguments.

  Call the methods in the class.

Sample Code

#Student class
class Student():

#Details method to get the student marks and name
def details(self,mark1,mark2,mark3,name):
self.m1=mark1
self.m2=mark2
self.m3=mark3
self.n=name

#printing the marks and name
def _print(self):
print(“Enter the mark1:”,self.m1)
print(“Enter the mark2:”,self.m2)
print(“Enter the mark3:”,self.m3)
print(“Enter the name:”,self.n)

#loop method to check whether student is pass or fail
def loop(self,passmark=40):
self.pm=passmark
if(self.m1>=self.pm):
print( “Pass”)
else:
print( “Fail”)

if(self.m2>=self.pm):
print( “Pass”)
else:
print( “Fail”)

if(self.m3>=self.pm):
print( “Pass”)
else:
print( “Fail”)

#Object creation
s=Student()

#passing arguments
s.details(30,40,50,’sathish’)

#method calling
s._print()
s.loop()

Screenshots
To create simple python program to display student result in python3