Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class HelloWorld:
- def makeNames(self, firstName, lastName):
- self.firstName = firstName
- self.lastName = lastName
- def display(self):
- return self.firstName + ' ' + self.lastName
- # Send a little message
- def hiYou(self):
- # print a little message to the STDOUT
- # in python 3 must use print()
- print('Nice to meet you, ' + self.firstName + ' ' + self.lastName + '. Hope you are ok?')
- mood = input("Are you ok? (y or n): ")
- if mood == 'n' or 'no':
- print("Oh sorry to hear that!\n")
- elif mood == 'y' or "yes":
- print("Great, thats nice to hear!\n")
- else:
- print("Error! Sorry I don't know that responce")
- name = HelloWorld()
- # Get user input rather then hard code the name??
- name.makeNames(input("Please enter a first name: "), input("Now enter a last name: "))
- # Just make sure its showing the names we have used
- name.display()
- # Now print our message out
- name.hiYou()
- OUTPUT:
- All the if, elif and else statments worked as expected
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement