In [5]:
import random,math
n=int(input('请输入随机数字的个数,以回车键结束'))
m=int(input('请输入一个大于0的整数,作为神秘整数的下界,回车结束。'))
k=int(input('请输入一个大于0的整数,作为神秘整数的上界,回车结束。'))
h=0
total=0
while h<n:
    total+=random.randint(m,k)
    h+=1
print(math.sqrt(total))


请输入随机数字的个数,以回车键结束4
请输入一个大于0的整数,作为神秘整数的下界,回车结束。0
请输入一个大于0的整数,作为神秘整数的上界,回车结束。10
4.358898943540674

In [7]:
import random,math
n=int(input('请输入随机数字的个数,以回车键结束'))
m=int(input('请输入一个大于0的整数,作为神秘整数的下界,回车结束。'))
k=int(input('请输入一个大于0的整数,作为神秘整数的上界,回车结束。'))
h=0
total=0
total1=0
while h<n:
    b=random.randint(m,k)
    total+=math.log(b,10)
    s=math.log(b,10)
    total1+=1/s
    h+=1
print(total)
print(total1)


请输入随机数字的个数,以回车键结束4
请输入一个大于0的整数,作为神秘整数的下界,回车结束。0
请输入一个大于0的整数,作为神秘整数的上界,回车结束。12
3.079181246047624
5.376737814455543

In [10]:
n=int(input('请输入随机数字相加的个数,以回车键结束'))
a=random.randint(1,9)
h=0
s=0
p=1
while h<n:
    total=p*a
    s+=total
    p=p*10+1
    h=h+1
print(s)


请输入随机数字相加的个数,以回车键结束5
49380

In [ ]: