In [1]:
#练习1

import random,math
n=int(input('请输入整数数量:'))
m=int(input('请输入整数值的下界:'))
k=int(input('请输入整数值的上界:'))
i=0
total=0

while i<=n:
    number=random.randint(m,k)
    total+=number
    i+=1
    
print('整数均值的平方根:',math.sqrt(total/n))


请输入整数数量:3
请输入整数值的下界:1
请输入整数值的上界:3
整数均值的平方根: 1.8257418583505538

In [1]:
#练习2
import random,math
n=int(input('请输入整数数量:'))
m=int(input('请输入整数值的下界:'))
k=int(input('请输入整数值的上界:'))
i=0
total1=0
total2=0

while i<n:
    total1+=math.log(random.randint(m,k))
    total2+=(1/math.log(random.randint(m,k)))
    i+=1
    
print('西格玛log(随机整数)为:',total1) 
print('西格玛1/log(随机整数)为:',total2)


请输入整数数量:3
请输入整数值的下界:50
请输入整数值的上界:100
西格玛log(随机整数)为: 12.81835678203268
西格玛1/log(随机整数)为: 0.6982819846027477

In [3]:
#练习3

import random
n=int(input('请输入相加整数的个数:'))
a=random.randint(1,9)
i=0
total=0

while i<n:
    total+=(10**i)*a
    i+=1
    
print(total)


请输入相加整数的个数:2
77