In: Computer Science
For the second exercise determine the union, intersection and
difference of the square and cube of integers ranging from 1 to
100. Sets are clearly the way to go here. You can use Math
functions to generate the sets for the square and cube for the
Integers.
The following functionality should be available for the user via a
simple interface:
1. Display the Square and Cube for Integers ranging from 1 to
100
2. Search the sets for a specific Integer and display the Square
and Cube values
3. Display the Union of Square and Cube sets
4. Display the Intersection of Square and Cube sets
5. Display the Difference of Square and Cube sets
6. Exit the program
If an Integer is not found an appropriate message should be
displayed
The program should continue to allow selections until the program
is exited.
Hints:
1. Use Sets and their associated union(), interaction() and
difference() methods 2. Create and use functions as often as
possible 3. Use comments to document your code
Please find the python program in the 4 screenshots given below:
==============================
OUTPUT
==============================
1. Display the Square and Cube for Integers ranging from 1 to
100
2. Search the sets for a specific Integer and display the Square
and Cube values
3. Display the Union of Square and Cube sets
4. Display the Intersection of Square and Cube sets
5. Display the Difference of Square and Cube sets
6. Exit the program
Enter your choice:1
Square of 1 is: 1
Square of 2 is: 4
Square of 3 is: 9
Square of 4 is: 16
Square of 5 is: 25
Square of 6 is: 36
Square of 7 is: 49
Square of 8 is: 64
Square of 9 is: 81
Square of 10 is: 100
Square of 11 is: 121
Square of 12 is: 144
Square of 13 is: 169
Square of 14 is: 196
Square of 15 is: 225
Square of 16 is: 256
Square of 17 is: 289
Square of 18 is: 324
Square of 19 is: 361
Square of 20 is: 400
Square of 21 is: 441
Square of 22 is: 484
Square of 23 is: 529
Square of 24 is: 576
Square of 25 is: 625
Square of 26 is: 676
Square of 27 is: 729
Square of 28 is: 784
Square of 29 is: 841
Square of 30 is: 900
Square of 31 is: 961
Square of 32 is: 1024
Square of 33 is: 1089
Square of 34 is: 1156
Square of 35 is: 1225
Square of 36 is: 1296
Square of 37 is: 1369
Square of 38 is: 1444
Square of 39 is: 1521
Square of 40 is: 1600
Square of 41 is: 1681
Square of 42 is: 1764
Square of 43 is: 1849
Square of 44 is: 1936
Square of 45 is: 2025
Square of 46 is: 2116
Square of 47 is: 2209
Square of 48 is: 2304
Square of 49 is: 2401
Square of 50 is: 2500
Square of 51 is: 2601
Square of 52 is: 2704
Square of 53 is: 2809
Square of 54 is: 2916
Square of 55 is: 3025
Square of 56 is: 3136
Square of 57 is: 3249
Square of 58 is: 3364
Square of 59 is: 3481
Square of 60 is: 3600
Square of 61 is: 3721
Square of 62 is: 3844
Square of 63 is: 3969
Square of 64 is: 4096
Square of 65 is: 4225
Square of 66 is: 4356
Square of 67 is: 4489
Square of 68 is: 4624
Square of 69 is: 4761
Square of 70 is: 4900
Square of 71 is: 5041
Square of 72 is: 5184
Square of 73 is: 5329
Square of 74 is: 5476
Square of 75 is: 5625
Square of 76 is: 5776
Square of 77 is: 5929
Square of 78 is: 6084
Square of 79 is: 6241
Square of 80 is: 6400
Square of 81 is: 6561
Square of 82 is: 6724
Square of 83 is: 6889
Square of 84 is: 7056
Square of 85 is: 7225
Square of 86 is: 7396
Square of 87 is: 7569
Square of 88 is: 7744
Square of 89 is: 7921
Square of 90 is: 8100
Square of 91 is: 8281
Square of 92 is: 8464
Square of 93 is: 8649
Square of 94 is: 8836
Square of 95 is: 9025
Square of 96 is: 9216
Square of 97 is: 9409
Square of 98 is: 9604
Square of 99 is: 9801
Square of 100 is: 10000
Cube of 1 is: 1
Cube of 2 is: 8
Cube of 3 is: 27
Cube of 4 is: 64
Cube of 5 is: 125
Cube of 6 is: 216
Cube of 7 is: 343
Cube of 8 is: 512
Cube of 9 is: 729
Cube of 10 is: 1000
Cube of 11 is: 1331
Cube of 12 is: 1728
Cube of 13 is: 2197
Cube of 14 is: 2744
Cube of 15 is: 3375
Cube of 16 is: 4096
Cube of 17 is: 4913
Cube of 18 is: 5832
Cube of 19 is: 6859
Cube of 20 is: 8000
Cube of 21 is: 9261
Cube of 22 is: 10648
Cube of 23 is: 12167
Cube of 24 is: 13824
Cube of 25 is: 15625
Cube of 26 is: 17576
Cube of 27 is: 19683
Cube of 28 is: 21952
Cube of 29 is: 24389
Cube of 30 is: 27000
Cube of 31 is: 29791
Cube of 32 is: 32768
Cube of 33 is: 35937
Cube of 34 is: 39304
Cube of 35 is: 42875
Cube of 36 is: 46656
Cube of 37 is: 50653
Cube of 38 is: 54872
Cube of 39 is: 59319
Cube of 40 is: 64000
Cube of 41 is: 68921
Cube of 42 is: 74088
Cube of 43 is: 79507
Cube of 44 is: 85184
Cube of 45 is: 91125
Cube of 46 is: 97336
Cube of 47 is: 103823
Cube of 48 is: 110592
Cube of 49 is: 117649
Cube of 50 is: 125000
Cube of 51 is: 132651
Cube of 52 is: 140608
Cube of 53 is: 148877
Cube of 54 is: 157464
Cube of 55 is: 166375
Cube of 56 is: 175616
Cube of 57 is: 185193
Cube of 58 is: 195112
Cube of 59 is: 205379
Cube of 60 is: 216000
Cube of 61 is: 226981
Cube of 62 is: 238328
Cube of 63 is: 250047
Cube of 64 is: 262144
Cube of 65 is: 274625
Cube of 66 is: 287496
Cube of 67 is: 300763
Cube of 68 is: 314432
Cube of 69 is: 328509
Cube of 70 is: 343000
Cube of 71 is: 357911
Cube of 72 is: 373248
Cube of 73 is: 389017
Cube of 74 is: 405224
Cube of 75 is: 421875
Cube of 76 is: 438976
Cube of 77 is: 456533
Cube of 78 is: 474552
Cube of 79 is: 493039
Cube of 80 is: 512000
Cube of 81 is: 531441
Cube of 82 is: 551368
Cube of 83 is: 571787
Cube of 84 is: 592704
Cube of 85 is: 614125
Cube of 86 is: 636056
Cube of 87 is: 658503
Cube of 88 is: 681472
Cube of 89 is: 704969
Cube of 90 is: 729000
Cube of 91 is: 753571
Cube of 92 is: 778688
Cube of 93 is: 804357
Cube of 94 is: 830584
Cube of 95 is: 857375
Cube of 96 is: 884736
Cube of 97 is: 912673
Cube of 98 is: 941192
Cube of 99 is: 970299
Cube of 100 is: 1000000
1. Display the Square and Cube for Integers ranging from 1 to
100
2. Search the sets for a specific Integer and display the Square
and Cube values
3. Display the Union of Square and Cube sets
4. Display the Intersection of Square and Cube sets
5. Display the Difference of Square and Cube sets
6. Exit the program
Enter your choice:2
Enter a value to check in Actual Set115
The number 115 is NOT found!
1. Display the Square and Cube for Integers ranging from 1 to
100
2. Search the sets for a specific Integer and display the Square
and Cube values
3. Display the Union of Square and Cube sets
4. Display the Intersection of Square and Cube sets
5. Display the Difference of Square and Cube sets
6. Exit the program
Enter your choice:2
Enter a value to check in Actual Set43
The number 43 is found!
Square is: 1849
Cube is: 79507
1. Display the Square and Cube for Integers ranging from 1 to
100
2. Search the sets for a specific Integer and display the Square
and Cube values
3. Display the Union of Square and Cube sets
4. Display the Intersection of Square and Cube sets
5. Display the Difference of Square and Cube sets
6. Exit the program
Enter your choice:3
Set after union is
{1024, 1, 4096, 9216, 4, 512, 13824, 32768, 64000, 9, 262144, 8,
804357, 16, 529, 3600, 4624, 357911, 25, 27, 36, 195112, 2601,
132651, 9261, 49, 97336, 7225, 970299, 3136, 64, 576, 1089, 6724,
1600, 2116, 5184, 7744, 9801, 205379, 658503, 125000, 81, 54872,
8281, 29791, 6241, 35937, 100, 625, 830584, 121, 125, 4225, 512000,
1156, 8836, 941192, 3721, 144, 1681, 2704, 5776, 79507, 2197,
636056, 4761, 2209, 676, 226981, 17576, 169, 3249, 2744, 250047,
1728, 9409, 85184, 274625, 196, 438976, 5832, 1225, 6859, 5329,
216, 729, 300763, 225, 19683, 1764, 7396, 405224, 6889, 614125,
7921, 46656, 238328, 2809, 256, 2304, 6400, 3844, 4356, 287496,
15625, 784, 1296, 8464, 10000, 157464, 857375, 289, 912673, 3364,
4900, 5929, 3375, 4913, 681472, 1331, 1849, 68921, 328509, 592704,
9025, 8000, 140608, 324, 24389, 841, 1000000, 456533, 343, 1369,
2401, 2916, 5476, 884736, 74088, 361, 185193, 175616, 27000, 42875,
3969, 110592, 900, 9604, 12167, 39304, 4489, 571787, 148877,
103823, 400, 1936, 7056, 7569, 373248, 117649, 10648, 3481, 389017,
6561, 314432, 1444, 8100, 753571, 729000, 5041, 59319, 474552, 441,
216000, 961, 21952, 778688, 2500, 6084, 551368, 8649, 704969, 3025,
343000, 50653, 484, 166375, 1000, 2025, 493039, 1521, 531441,
421875, 91125, 5625}
1. Display the Square and Cube for Integers ranging from 1 to
100
2. Search the sets for a specific Integer and display the Square
and Cube values
3. Display the Union of Square and Cube sets
4. Display the Intersection of Square and Cube sets
5. Display the Difference of Square and Cube sets
6. Exit the program
Enter your choice:4
Set after intersection is
{4096, 1, 64, 729}
1. Display the Square and Cube for Integers ranging from 1 to
100
2. Search the sets for a specific Integer and display the Square
and Cube values
3. Display the Union of Square and Cube sets
4. Display the Intersection of Square and Cube sets
5. Display the Difference of Square and Cube sets
6. Exit the program
Enter your choice:5
Set after difference is
{1024, 9216, 4, 9, 16, 529, 3600, 4624, 25, 36, 2601, 49, 7225,
3136, 576, 1089, 1600, 6724, 2116, 5184, 7744, 9801, 81, 8281,
6241, 100, 625, 121, 4225, 1156, 8836, 3721, 144, 1681, 2704, 5776,
4761, 2209, 676, 169, 3249, 9409, 196, 1225, 5329, 225, 1764, 7396,
6889, 7921, 2809, 256, 2304, 6400, 3844, 4356, 10000, 784, 8464,
1296, 289, 3364, 4900, 5929, 1849, 9025, 324, 841, 1369, 2401,
2916, 5476, 361, 3969, 900, 9604, 4489, 7056, 1936, 7569, 400,
3481, 6561, 1444, 8100, 5041, 441, 961, 2500, 6084, 8649, 3025,
484, 2025, 1521, 5625}
1. Display the Square and Cube for Integers ranging from 1 to
100
2. Search the sets for a specific Integer and display the Square
and Cube values
3. Display the Union of Square and Cube sets
4. Display the Intersection of Square and Cube sets
5. Display the Difference of Square and Cube sets
6. Exit the program
Enter your choice:6
Thank you!