#Python program to demonstrate constructors
# declaration of class
class myClass:
def __init__(self,fName,lName): # Constructor
# initialization of variable
self.FirstName = fName
self.LastName = lName
def fName(self):
return self.FirstName
def lName(self):
return self.LastName
mcls = myClass("blk","CapHax")
print("First Name : " + mcls.fName())
print("Last Name : " + mcls.lName())
print()
input("Press Enter to exit.")
If you have a great ability of thinking, imagination and visualisation than you have to codes your thinking and visualisation.
Tuesday, 19 June 2018
Python program to demonstrate constructors
Subscribe to:
Post Comments (Atom)
Featured post
To add 'ing' at the end of a given string (length should be at least 3). If the given string already ends with 'ing' then add 'ly' instead. If the string length of the given string is less than 3, leave it unchanged. <br/>Sample String : 'abc' <br/> Expected Result : 'abcing' <br/> Sample String : 'string'
#To add 'ing' at the end of a given string (length should be at least 3). If the #given string already ends with 'ing' then...
Popular Posts
-
#To add 'ing' at the end of a given string (length should be at least 3). If the #given string already ends with 'ing'...
-
# Write a program that accepts a comma separated sequence of words as input # and prints the words in a comma-separated sequence after...
-
# To implement Queue using list queueList = [] def enQueue(ele='\0'): if ele!='\0': queueList.append(...
No comments:
Post a Comment