python3循环_Python-循环运行3次

所以我有这个任务,我有一个问题,关于一个我不知道怎么做的部分,你们能帮我吗?def main():

# Please see the comments

largest = 0

for index in range(3): # Enter the value(s) in the parenthesis to run the loop 3 times

number1 = int(input("Please enter the first number: "))

number2 = int(input("Please enter the second number: "))

number3 = int(input("Please enter the third number: "))

# insert call to function find_largest after this comment.

# find_largest will take in three parameters and will return the largest of the 3 numbers

result = find_largest(number1, number2, number3)

# insert the statement to print the three numbers entered and the largest number after this comment.

print("The numbers you entered were, \n", [number1, number2, number3])

print ("The largest of the numbers you entered is", result)

def find_largest(a, b, c):

# insert parameters in the parenthesis

# Write the code for this function here.

# find_largest will take in three parameters and will return the largest of the 3 numbers

# These three numbers are passed in as parameters from the main function

# Hint: if and elif - no loop needed here

if (a > b) and (a > c):

largest = a

elif (b > a) and (b > c):

largest = b

else:

largest = c

return largest

main() # this is the call to main() that will make the program run

所以,我的问题是:for index in range(3): # Enter the value(s) in the parenthesis to run the loop 3 times

我不知道要添加什么,所以循环在找到最大的数字后再运行2次

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值