小编use*_*472的帖子

Python随机数多次

import random

def main():
    uinput()

def uinput():
    times = int(input('How many numbers do you want generated?'))
    number1 = int(input('Put in the first number:' ))
    number2 = int(input('Put in the second number:'))
    rnumber = random.randint(number1, number2)
    print (rnumber)



main()
Run Code Online (Sandbox Code Playgroud)

我在 Python 中乱搞,我希望我的程序生成随机数。如您所见,我已经完成了此操作。我要做的下一件事是让它生成多个随机数,具体取决于“用户”想要生成的数字数量。我该怎么做呢?我假设需要一个循环。

python random numbers

1
推荐指数
1
解决办法
1万
查看次数

Python 3,将数据从一个函数传递到另一个函数

def main():
    uInput()
    calc()
def uInput():
    value1 = int(input('Please put in the first number'))
    value2 = int(input('Please put in your second number'))
    return value1
    return value2
def calc(value1,value2):    
    finalNumber = value1 + value2
    print (finalNumber)
main()
Run Code Online (Sandbox Code Playgroud)

我正在使用 python,并且正在尝试制作一个简单的计算器程序。我试图将输入值从 uInput 模块传递到 calc 模块。它一直说缺少两个必需的位置参数。你只能将一个变量从一个模块传递给另一个模块吗?

python function python-3.x

0
推荐指数
1
解决办法
1万
查看次数

标签 统计

python ×2

function ×1

numbers ×1

python-3.x ×1

random ×1