SHARE
TWEET

Untitled

a guest Sep 17th, 2019 74 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. class Assignment:
  3.  
  4.   def __init__(self, assignment_number):
  5.    
  6.     self.assignment_number = assignment_number
  7.  
  8.   def right_justify(self):
  9.     print("This is Assignment Number:3." + str(self.assignment_number) + '\n') #this is sloppy, might as well use format later lol
  10.     word = input(str("Please input a word to right justify: "))
  11.     print(word.rjust((70 - len(word))))
  12.  
  13.   def do_twice(self, f, value):
  14.     f(value)
  15.     f(value)
  16.  
  17.   def do_four(self, f, value):
  18.     """
  19.     #this would be an illegal move lol (Pdf says 2 statements )
  20.     for i in range(4):
  21.       f(value)
  22.     """
  23.     self.do_twice(f, value)
  24.     self.do_twice(f, value)
  25.  
  26.  
  27. def do_me_twice(value):
  28.   #the for loop below is compressed since it print's lorem ipsum
  29.   try:
  30.     if str(value) != 'spam': #lol :>
  31.       print('This only prints the word spam')
  32.     else:
  33.       print(value)
  34.   except:
  35.     pass
  36.    
  37. if __name__ == '__main__':
  38.     while True:
  39.       try:
  40.         ass_number = int(input("Enter a number from 1-3: "))
  41.         #Assignment number :> hehehe
  42.         if ass_number > 3:
  43.           print("I SAID A NUMBER FROM 1-3: ")
  44.         elif ass_number == 1:
  45.           Assignment(ass_number).right_justify()
  46.  
  47.         elif ass_number == 2:
  48.           print("This is Assignment Number:3.2 \n")
  49.           Assignment(ass_number).do_twice(do_me_twice, 'spam')
  50.           print("\n This is from do_quad/do_four \n")
  51.           Assignment(ass_number).do_four(do_me_twice, 'spam')
  52.          
  53.         elif ass_number == 3:
  54.           self.right_justify()
  55.  
  56.          
  57.       except Exception as inst:
  58.           print("Like my life, something went wrong: ")
  59.           print(str(inst))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top