-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathunit_nine.py
More file actions
30 lines (25 loc) · 882 Bytes
/
unit_nine.py
File metadata and controls
30 lines (25 loc) · 882 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
29
30
"""stage = 1
for stage in range(1,10):
multiplier = 1
for multiplier in range(1,10):
product = stage * multiplier
print(f"{stage} x {multiplier} = {product}")
num_list = [1,2,3]
for row in num_list :
for col in num_list :
for col2 in num_list :
print("{} {} {}".format(row, col, col2))"""
def product_set(set1, set2):
res = set()
for i in set1:
for j in set2:
res = res | {(i, j)} # Productset using double for loop
return res
def exp(input_set, exponent): # A function that performs powers on input_set
res = input_set # res initialization
for _ in range(exponent - 1): # Repeated for (exponent-1) to become a power
res = product_set(res, input_set)
return res
A = {1, 3}
A3 = exp(A, 3) # Perform 3 powers on set A
print(A3)