Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Assignment:
- def __init__(self, assignment_number):
- self.assignment_number = assignment_number
- def right_justify(self):
- print("This is Assignment Number:3." + str(self.assignment_number) + '\n') #this is sloppy, might as well use format later lol
- word = input(str("Please input a word to right justify: "))
- print(word.rjust((70 - len(word))))
- def do_twice(self, f, value):
- f(value)
- f(value)
- def do_four(self, f, value):
- """
- #this would be an illegal move lol (Pdf says 2 statements )
- for i in range(4):
- f(value)
- """
- self.do_twice(f, value)
- self.do_twice(f, value)
- def do_me_twice(value):
- #the for loop below is compressed since it print's lorem ipsum
- try:
- if str(value) != 'spam': #lol :>
- print('This only prints the word spam')
- else:
- print(value)
- except:
- pass
- if __name__ == '__main__':
- while True:
- try:
- ass_number = int(input("Enter a number from 1-3: "))
- #Assignment number :> hehehe
- if ass_number > 3:
- print("I SAID A NUMBER FROM 1-3: ")
- elif ass_number == 1:
- Assignment(ass_number).right_justify()
- elif ass_number == 2:
- print("This is Assignment Number:3.2 \n")
- Assignment(ass_number).do_twice(do_me_twice, 'spam')
- print("\n This is from do_quad/do_four \n")
- Assignment(ass_number).do_four(do_me_twice, 'spam')
- elif ass_number == 3:
- self.right_justify()
- except Exception as inst:
- print("Like my life, something went wrong: ")
- print(str(inst))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement