Quiz 6b Question 7————An Introduction to Interactive Programming in Python



Question 7

Convert the following English description into code.

  1. Initialize n to be 1000. Initialize numbers to be a list of numbers from 2 to n, but not including n.
  2. With results starting as the empty list, repeat the following as long as numbers contains any numbers.
    • Add the first number in numbers to the end of results.
    • Remove every number in numbers that is evenly divisible by (has no remainder when divided by) the number that you had just added to results.

How long is results?

To test your code, when n is instead 100, the length of results is 25.

代码:

lis = list(range(2,1000))
print lis[0]
res =[]
print len(res)
res.append(lis[0])
while len(lis)>1:
    for i in lis:
        if i % res[-1]==0:
            lis.remove(i)
    res.append(lis[0])
print lis

print len(res)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
no main manifest attribute, in quiz-0.0.1-SNAPSHOT.jar 是一个报错信息,表示在quiz-0.0.1-SNAPSHOT.jar包的清单文件(MANIFEST.MF)中缺少了主清单属性。 解决这个问题的方法是在pom文件中添加以下配置: ``` <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build> ``` 这个配置会在打包过程中自动生成并添加主清单属性,确保jar包能够正确运行。 同时,需要确保MANIFEST.MF文件夹和MANIFEST.MF文件位于项目的根目录下,才能够在本地使用java -jar命令运行jar包或在Docker容器中启动。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [no main manifest attribute, in app-1.0-SNAPSHOT.jar](https://blog.csdn.net/YonJarLuo/article/details/128530264)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"] - *2* [no main manifest attribute, in schoolspringboot-0.0.1-SNAPSHOT.jar](https://blog.csdn.net/weixin_52236586/article/details/131679246)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"] - *3* [start-0.0.1-SNAPSHOT.jar](https://download.csdn.net/download/qq_38807606/12268407)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"] [ .reference_list ]

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值