Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.10 KB | None | 0 0
  1. class HelloWorld:
  2.  
  3.     def makeNames(self, firstName, lastName):
  4.        
  5.         self.firstName = firstName
  6.         self.lastName = lastName
  7.  
  8.    
  9.     def display(self):
  10.         return self.firstName + ' ' + self.lastName
  11.  
  12.     # Send a little message
  13.     def hiYou(self):
  14.         # print a little message to the STDOUT
  15.         # in python 3 must use print()
  16.         print('Nice to meet you, ' + self.firstName + ' ' + self.lastName + '. Hope you are ok?')
  17.        
  18.         mood = input("Are you ok? (y or n): ")
  19.         if mood == 'n' or 'no':
  20.             print("Oh sorry to hear that!\n")
  21.         elif mood == 'y' or "yes":
  22.             print("Great, thats nice to hear!\n")
  23.         else:
  24.             print("Error! Sorry I don't know that responce")
  25.        
  26.  
  27. name = HelloWorld()
  28. # Get user input rather then hard code the name??
  29. name.makeNames(input("Please enter a first name: "), input("Now enter a last name: "))
  30. # Just make sure its showing the names we have used
  31. name.display()
  32.  
  33. # Now print our message out
  34. name.hiYou()
  35.  
  36. OUTPUT:
  37. All the if, elif and else statments worked as expected
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement