Last active
December 31, 2015 03:28
-
-
Save imbyron/7927349 to your computer and use it in GitHub Desktop.
本程序会从1~n中随机取m个数,其中1<=m<=n
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
#!/usr/bin/python | |
#coding:utf-8 | |
#author:byron | |
#blog:http://jiabin.tk | |
import random | |
def m_n(): | |
print("本程序会从1~n中随机取m个数,1<=m<=n") | |
n = int(input("输入n的值:")) | |
m = int(input("输入m的值:")) | |
if 1 <= m <= n: | |
random_num = random.sample(list(range(1,n+1)),m) | |
print(random_num) | |
else: | |
print("="*40) | |
print('请确认1<=m<=n') | |
print('='*40) | |
m_n() | |
m_n() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment