QUIZ 5
COMP9021 PRINCIPLES OF PROGRAMMING
$ python3 quiz_5.py Input a nonnegative integer: 0 The encoded set is: {} The derived set is encoded as: 0 It is: {} $ python3 quiz_5.py Input a nonnegative integer: 1 The encoded set is: {0} The derived set is encoded as: 1 It is: {0} $ python3 quiz_5.py Input a nonnegative integer: 2 The encoded set is: {-1} The derived set is encoded as: 2 It is: {-1} $ python3 quiz_5.py Input a nonnegative integer: 3 The encoded set is: {-1, 0} The derived set is encoded as: 2 It is: {-1} $ python3 quiz_5.py Input a nonnegative integer: 4 The encoded set is: {1} The derived set is encoded as: 4 It is: {1} $ python3 quiz_5.py Input a nonnegative integer: 5 The encoded set is: {0, 1} The derived set is encoded as: 5 It is: {0, 1} $ python3 quiz_5.py Input a nonnegative integer: 6 The encoded set is: {-1, 1} The derived set is encoded as: 3 It is: {-1, 0} $ python3 quiz_5.py Input a nonnegative integer: 7 The encoded set is: {-1, 0, 1} The derived set is encoded as: 3 It is: {-1, 0}
Date: Session 2, 2018.
2 COMP9021 PRINCIPLES OF PROGRAMMING
$ python3 quiz_5.py Input a nonnegative integer: 100 The encoded set is: {-3, 1, 3} The derived set is encoded as: 44 It is: {-3, -2, 1} $ python3 quiz_5.py Input a nonnegative integer: 123 The encoded set is: {-3, -2, -1, 0, 2, 3} The derived set is encoded as: 2722 It is: {-6, -5, -4, -3, -1} $ python3 quiz_5.py Input a nonnegative integer: 1234 The encoded set is: {-4, -1, 2, 3, 5} The derived set is encoded as: 1697 It is: {-5, -4, -3, 0, 5}