Python Class And Methods

Python class and methods are defined as shown in the code below.

#
# Python class and methods
#
class myClass():
  def method1(self):
    print("method1")

  def method2(self, someString):
    print("method2 " + someString)

def main():
  c = myClass()
  c.method1()
  c.method2("Hello World!")

  
if __name__ == "__main__":
  main()


--------------------------------------------
#Output
method1
method2 Hello World!

Comments

Popular posts from this blog

How to write to a file in Kotlin

Python Tkinter example