Created
September 15, 2020 06:51
-
-
Save EdwinTai/e6f6fe9a0d084507e6a732edd6cfada0 to your computer and use it in GitHub Desktop.
python random number usage
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
def _3d1():#方法一,直接顯示 | |
return print(str(random.randint(0, 9)) + " " + str(random.randint(0, 9)) + " " + str(random.randint(0, 9))) | |
def _3d2():#方法二,一次抽一顆 | |
result = list() | |
_3d_ticket = set() | |
while len(_3d_ticket) < 3: | |
number = random.randint(0,9) | |
_3d_ticket.add(number) | |
for ball in _3d_ticket: | |
result.append(str(ball)) | |
return print(result) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment