Computer Tips and Tricks

Saturday, October 10, 2020

write a python program for creating a class Student with method and constructor

class student:

  def __init__(self,name,age):

        self.name=name

        self.age=age


  def myfunc(self,a,b):

        a=a+b

        return a


p1=student("john",23)

print("My names is",p1.name)

d=p1.myfunc(2,3)

print("sum is",d)

Posted by vamsinath at 8:40 AM
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest

No comments:

Post a Comment

Newer Post Older Post Home
Subscribe to: Post Comments (Atom)

About Me

vamsinath
View my complete profile

Blog Archive

  • ▼  2020 (63)
    • ▼  October (12)
      • write python turtle program to draw letter E
      • write python turtle program for creating Archimede...
      • write a python program for creating a class Studen...
      • write a python program for creating class person w...
      • write a java program for demonstration of Finally ...
      • write a java program for exception propagation
      • write a java program for creating own exception
      • write a java program creating static variables?
      • write a java program using throw keyword ?
      • write a java program for generating arithmetic exc...
      • write a java program demonstrating relationship be...
      • write a java program for exhibiting multiple inher...
    • ►  August (24)
    • ►  May (26)
    • ►  April (1)
  • ►  2019 (1)
    • ►  February (1)
Simple theme. Powered by Blogger.