热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

python3循环_Python循环运行3次

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

所以我有这个任务,我有一个问题,关于一个我不知道怎么做的部分,你们能帮我吗?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次



推荐阅读
author-avatar
Jason
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有