In [10]:
def computer(x, y, t):
total = 0
i = 0
while i < t:
import random
number = random.randint(x, y)
total = total + number
i = i + 1
aver = total/t
import math
squareroot = math.sqrt(aver)
print(squareroot)
n = int(input('请输入随机数个数n '))
m = int(input('请输入整数下限m '))
k = int(input('请输入整数上限k '))
computer(m, k, n)
In [ ]:
In [16]:
def computer(x, y, t):
total = 0
i = 0
while i < t:
import random
number = random.randint(x, y)
import math
log = math.log(number)
total = total + log
i = i + 1
print(total)
n = int(input('请输入随机数个数n '))
m = int(input('请输入整数下限m '))
k = int(input('请输入整数上限k '))
computer(m, k, n)
In [18]:
def computer(x, y, t):
total = 0
i = 0
while i < t:
import random
number = random.randint(x, y)
import math
log = math.log(number)
total = total + 1/log
i = i + 1
print(total)
n = int(input('请输入随机数个数n '))
m = int(input('请输入整数下限m '))
k = int(input('请输入整数上限k '))
computer(m, k, n)
In [15]:
def computer(t):
import random
x = random.randint(1,9)
i = 0
total = 0
while i < t:
y = x * 10**i
total = total + y*(t-i)
i = i + 1
print('s的值是',total)
n = int(input('请输入共有几个数相加'))
computer(n)
In [ ]:
def win():
print('你赢了哈哈哈哈哈哈')
def lose():
print('你输了盒盒盒盒盒盒')
def game_over():
print('游戏结束')
def show_team():
print('没有team')
def show_instruction():
print('''请玩家心里想一个1——1000的数字,并按照提示输入电脑可猜测次数,等待电脑提示开始游戏。
游戏开始后,请按照提示输入,知道游戏结束。''')
def menu():
print(''' =====游戏菜单=====
1.游戏说明
2.开始游戏
3.退出游戏
4.制作团队
=====游戏菜单=====''')
def guess_game():
max_times = int(input('请输入一共可以猜测的次数'))
import random
x = random.randint(1,1000)
guess_times = 0
while guess_times < max_times:
print('电脑猜测的数字是: ', x)
print(''' 1.抱歉,你猜大了
2.抱歉,你猜小了
3.恭喜你!你猜对了!!!''')
choice = int(input('请输入你的选择'))
guess_times += 1
print('电脑还有',max_times-guess_times,'次机会')
if choice == 1:
import random
x = random.randint(1,x)
elif choice == 2:
import random
x = random.randint(x,1000)
elif choice == 3:
win()
break
else:
lose()
def main():
while True:
menu()
choice = int(input('请输入你的选择'))
if choice == 1:
show_instruction()
elif choice == 2:
guess_game()
elif choice == 3:
game_over()
break
else:
show_team()
if __name__ =='__main__':
main()