Python 在while循环中同时给出1000个答案

Python 在while循环中同时给出1000个答案,python,python-3.x,Python,Python 3.x,(当我在学校工作时,我已经开始讨厌了) 我现在的问题是,我需要创建一个程序,向用户询问篮球投掷准确度的百分比。并模拟1000次投掷-对于每个答案,它给出命中或未命中的结果 如果用户按百分比输入45,则程序工作的示例 throwing_accuracy = int(input("Enter throwing percentage")): 45 #Somewhere here would be while : 1. Throw hit 2. Throw hit 3. Throw hit 5. Th

(当我在学校工作时,我已经开始讨厌了)

我现在的问题是,我需要创建一个程序,向用户询问篮球投掷准确度的百分比。并模拟1000次投掷-对于每个答案,它给出命中或未命中的结果

如果用户按百分比输入45,则程序工作的示例

throwing_accuracy = int(input("Enter throwing percentage")): 45

#Somewhere here would be while :
1. Throw hit
2. Throw hit
3. Throw hit
5. Throw missed
#.........#
999. Throw hit
1000. Throw hit
   #And then prints also a result how many hits there were
There were 458 hits

程序必须使用
构建,而
时,我阅读了一些可以使用
if
else
语句的提示,应该
从随机导入randint
,因为如果randint(1100)可以编写如下程序:

import random
percentage_accuracy = int(input("Input throwing accuracy here: "))
hits = 0
throws = 1
while throws <= 1000:
    if random.randint(1, 100) <= percentage_accuracy:
        hits += 1
        print("{}: Hit".format(x))
    else:
        print("{}: Miss".format(x))
    throws += 1
print("")
print("Player results:")
print("{} Hits".format(hits))
print("{} Misses".format(1000-hits))
而不是:

throws = 1
while throws <= 1000:
    throws += 1
throws=1

你试过什么?你具体需要什么帮助?@Carcigenicate-我只知道这个程序应该如何工作,但不知道如何构建它……这对这里来说太广泛了。此站点用于帮助您处理现有的、已损坏的代码。如果您需要一般帮助,Reddit的
r/learnprogramming
可能是一个查看的好地方。不过请注意,您访问的大多数地方都会要求您具体说明需要哪些帮助。“我如何开始这个”是相当广泛的,即使是在重点广泛的网站上。欢迎来到StackOverflow。请按照您创建此帐户时的建议,阅读并遵循帮助文档中的发布指南,在这里申请。StackOverflow不是设计、编码、研究或教程资源。然而,如果你遵循你在网上找到的任何资源,进行诚实的编码尝试,并遇到问题,你就会有一个很好的例子发表。你离目标不远,看看你的其他线程,仔细阅读解决方案,你最终会得到它
throws = 1
while throws <= 1000:
    throws += 1