Python random.randint(a , b)與tuple, set, issubset(), issuperset()

加入好友
加入社群
Python random.randint(a , b)與tuple, set, issubset(), issuperset() - 儲蓄保險王

#Python random與tuple, set, issubset(), issuperset()

import random
lst=[]
for i in range(1,11):
randNum = random.randint(1,100)
lst.append(randNum)
print(lst)

tp=tuple(x for x in lst)
print(tp)

Python random.randint(a , b)與tuple, set, issubset(), issuperset() - 儲蓄保險王

 

Python random.randint(a , b)與tuple, set, issubset(), issuperset() - 儲蓄保險王

def operation(set11,set22):
print()
print(“set1 is a subset of set2:”\
,set11.issubset(set22))
print(“set1 is a superset of set2:”\
,set11.issuperset(set22))

def inputData(set11):
#set11={} #input時已經設定好空set
while True:
a = eval(input())
if a != -9999:
set11.add(a)
else:break
return set11

def main():
print(“Input set1 data: “)
set1=set()
inputData(set1)

print(“Input set2 data: “)
set2=set()
inputData(set2)

print(“set1:”,set1)
print(“set2:”,set2)
operation(set1,set2)

main()

Python random.randint(a , b)與tuple, set, issubset(), issuperset() - 儲蓄保險王

 

加入好友
加入社群
Python random.randint(a , b)與tuple, set, issubset(), issuperset() - 儲蓄保險王

儲蓄保險王

儲蓄險是板主最喜愛的儲蓄工具,最喜愛的投資理財工具則是ETF,最喜愛的省錢工具則是信用卡

You may also like...

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *