-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdiscretemath2.py
More file actions
28 lines (21 loc) · 771 Bytes
/
Copy pathdiscretemath2.py
File metadata and controls
28 lines (21 loc) · 771 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# to output cartesian products
# initialize sets Set1, Set2, and Set3
Set1 = {'a', 'b', 'c'}
Set2 = {'*', '+'}
Set3 = {'A', 'B', 'C', 'D'}
#Block 1: lists the elements in the Cartesian Product Set1 x Set2
for x in sorted(Set1):
for y in sorted(Set2):
print( '(' + x + ',' + y + ')' )
print('\n')
#Block 2: Put your code here to list the elements in the Cartesian Product Set2 x Set1
for x in sorted(Set2):
for y in sorted(Set1):
print( '(' + x + ',' + y + ')' )
print('\n')
#Block 3: Put your code here to list the elements in the Cartesian Product Set1 x Set2 x Set3
for x in sorted(Set1):
for y in sorted(Set2):
for z in sorted(Set3):
print( '(' + x + ',' + y + ',' + z + ')' )
print('\n')