找回密码
 中文实名注册
查看: 219|回复: 6

严思宇

[复制链接]

1

主题

12

帖子

3165

积分

论坛元老

Rank: 8Rank: 8

积分
3165
发表于 2023-11-4 15:09:06 | 显示全部楼层 |阅读模式

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


回复

使用道具 举报

1

主题

12

帖子

3165

积分

论坛元老

Rank: 8Rank: 8

积分
3165
 楼主| 发表于 2023-12-2 15:10:42 | 显示全部楼层
本帖最后由 严思宇 于 2023-12-2 15:12 编辑


import random


total = 0


def cal():
    global total
    box = random.choice(['石头','黄金','钻石'])
    if box=='石头':
        total = total + 20
    elif box=='黄金':
        total = total + 100
    else:
        total = total + 500






cal()
cal()

cal()
print(total)



回复

使用道具 举报

1

主题

12

帖子

3165

积分

论坛元老

Rank: 8Rank: 8

积分
3165
 楼主| 发表于 2023-12-23 15:13:38 | 显示全部楼层
[Python] 纯文本查看 复制代码
beads = input("")
feet = input("")
beads = input(beads)
feet = input(feet)

if feet % 2 == 0 and heads * 2 <=feet <= heads *4:
    for chicken in range(heads + 1):
    rabbit = heads - chirken
    if chicken *2 + rabbit *4 == feet:
        print(f'有{chicken}只鸡,有{rabbit}只兔))

else:
    print("数据有误,")
回复

使用道具 举报

1

主题

12

帖子

3165

积分

论坛元老

Rank: 8Rank: 8

积分
3165
 楼主| 发表于 2023-12-30 14:56:42 | 显示全部楼层

import turtle
import random

turtle.speed(0)
turtle.hideturtle()
turtle.pensize(2)



turtle.colormode(255)

colors = [(236,113,95),(23,25,23),(45,48,45),(56,56,236),(39,34,34

for i in range(100):

    turtle.pencolor(random.choice(colors))
    turtle.forward(i+1)
    turtle.left(58)


回复

使用道具 举报

1

主题

12

帖子

3165

积分

论坛元老

Rank: 8Rank: 8

积分
3165
 楼主| 发表于 2024-1-6 14:53:28 | 显示全部楼层
import turtle

def draw_rect(color):
    turtle.fillcolor(color)
    turtle.begin_fill()
    for i in range(2):
        turtle.forward(50)
        turtle.left(90)
        turtle.forward(300)
        turtle.left(90)
    turtle.end_fill()

color_list = ['red','blue','green','yellow','pink','gray']

for i in color_list:
    draw_rect(i)
    turtle.forward(50)


turtle.done   
回复

使用道具 举报

1

主题

12

帖子

3165

积分

论坛元老

Rank: 8Rank: 8

积分
3165
 楼主| 发表于 2024-1-6 14:54:31 | 显示全部楼层

import turtle

def draw_rect(color):
    turtle.fillcolor(color)
    turtle.begin_fill()
    for i in range(2):
        turtle.forward(50)
        turtle.left(90)
        turtle.forward(300)
        turtle.left(90)
    turtle.end_fill()

color_list = ['red','blue','green','yellow','pink','gray'

for i in color_list:
    draw_rect(i)
    turtle.forward(50)


turtle.done   



回复

使用道具 举报

1

主题

12

帖子

3165

积分

论坛元老

Rank: 8Rank: 8

积分
3165
 楼主| 发表于 2024-1-13 14:47:14 | 显示全部楼层
import random
import turtle
turtle. setup(800, 600)
tutu = turtle.Turtle()
tutu.speed(0)
turtle.colormods(255)

def draw _circle(r):
    R = random.randint(0,255)
    G = random.randint(0, 255)
    B = random.randint(0, 255)
    tutu.fillcolor(R, G, B)
    tutu.begin_fill()
    tutu.circle(r)
    tutu.end_fill()


r = 120
for i in range(36):
    draw_circle(r)
    r = r - 3
    tutu.left(25)
turtle.done()



回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-4-27 14:33 , Processed in 0.039910 second(s), 28 queries .

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

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