找回密码
 中文实名注册
楼主: admin

【Python作业】第三单元 第7课 小熊摘桃 综合项目

[复制链接]

7

主题

62

帖子

1128

积分

金牌会员

Rank: 6Rank: 6

积分
1128
发表于 2021-12-11 11:43:18 | 显示全部楼层
tree = 0
total = 0
while True:
    tree = tree + 1
    total = total + tree
    print(tree)
    print(total)
    if total >= 120:
        break
论坛我最帅
回复

使用道具 举报

3

主题

18

帖子

1484

积分

金牌会员

Rank: 6Rank: 6

积分
1484
发表于 2021-12-11 11:40:01 | 显示全部楼层

回帖奖励 +40 金钱

tree = 0
total = 0

while True:
    tree = tree + 1
    if tree % 3 !=0
    total = total + tree
    print(tree)
    print(total)
    if total >= 120(tree)
    print('第' + str(tree) + '棵的时候摘啦')
回复

使用道具 举报

0

主题

29

帖子

86

积分

注册会员

Rank: 2

积分
86
发表于 2021-12-11 11:39:08 | 显示全部楼层

回帖奖励 +40 金钱

tree = 0
total = 0
while True:
    tree = tree + 1
    if tree % 3!=0:
        total = total + tree
    print(tree)
    print(total)
    if total >= 120:
        print('第'+str(tree)+'棵的时候摘够了')
        break
回复

使用道具 举报

4

主题

47

帖子

735

积分

高级会员

Rank: 4

积分
735
发表于 2021-12-11 11:37:11 | 显示全部楼层

回帖奖励 +40 金钱

tree = 0
total = 0
while True:
    tree = tree + 1
    if tree % 3!=0:
        total = total + tree
    print(tree)
    print(total)
    if total >= 120:
        print('第'+str(tree)+'棵的时候摘够了')
        break
回复

使用道具 举报

8

主题

80

帖子

3559

积分

论坛元老

Rank: 8Rank: 8

积分
3559
发表于 2021-12-11 11:30:15 | 显示全部楼层

回帖奖励 +40 金钱

本帖最后由 许睿辰 于 2021-12-11 11:43 编辑
  1. <div class="blockcode"><blockquote>tree = 0
  2. total = 0
  3. while True:
  4.     tree = tree + 1
  5.     if tree % 3 != 0:
  6.         total = total + tree
  7.     print(tree)
  8.     print(total)
  9.     if total >= 120:
  10.         print('第' + str(tree) + '棵的时候摘够了')
  11.         break
复制代码

回复

使用道具 举报

1

主题

20

帖子

867

积分

高级会员

Rank: 4

积分
867
发表于 2021-12-11 11:29:59 | 显示全部楼层

回帖奖励 +40 金钱

tree = 0
total = 0
while True:
    tree = tree + 1
    if tree % 3 != 0:
        total = total + tree
    print(tree)
    print(total)
    if total >= 120:
        print('第'+str(tree)+'棵的时候摘够啦')
        break

回复

使用道具 举报

4

主题

134

帖子

5209

积分

版主

Rank: 7Rank: 7Rank: 7

积分
5209
发表于 2021-12-11 11:29:34 | 显示全部楼层

回帖奖励 +40 金钱

tree = 0
total = 0
while True:
    tree += 1
    if tree % 3 != 0:#把除以3等于0的数(3的倍数)排除
        total = total + tree
    if total >= 120:
        print(f'第{tree}棵的时候摘够啦')
        break

回复

使用道具 举报

7

主题

62

帖子

1128

积分

金牌会员

Rank: 6Rank: 6

积分
1128
发表于 2021-12-11 11:29:22 | 显示全部楼层

回帖奖励 +40 金钱

tree = 0
total = 0
while True:
    tree = tree + 1
    if tree % 3 != 0:
        total = total + tree
    if total >= 120:
        print('第' + str(tree) + '棵的时候摘够了')
        break
论坛我最帅
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 中文实名注册

本版积分规则

小黑屋|东台市机器人学会 ( 苏ICP备2021035350号-1;苏ICP备2021035350号-2;苏ICP备2021035350号-3 )

GMT+8, 2024-5-17 12:51 , Processed in 0.045674 second(s), 24 queries .

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表