Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
bellcode
/
lesson3-1-1_DIY1
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
1b07da2e
authored
Apr 20, 2024
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
c66a449e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
22 deletions
diy1.py
diy1.py
View file @
1b07da2e
# 利用write()帮助悟空给诺依回信吧~
import
turtle
screen
=
turtle
.
Screen
()
screen
.
bgcolor
(
"light blue"
)
len
=
screen
.
textinput
(
"100"
,
"100"
)
len
=
int
(
len
)
pen
=
turtle
.
Pen
()
pen
.
write
(
"你好
\n
SB."
,
font
=
(
"Times"
,
30
,
"normal"
))
pen
.
hideturtle
()
len
=
60
pen
.
penup
()
pen
.
goto
(
100
,
100
)
pen
.
pendown
()
pen
.
pensize
(
5
)
pen
.
pencolor
(
"red"
)
pen
.
left
(
45
)
pen
.
forward
(
2
*
len
)
pen
.
circle
(
len
,
180
)
pen
.
right
(
90
)
pen
.
circle
(
len
,
180
)
pen
.
forward
(
2
*
len
)
turtle
.
done
()
'''
n=int(input()) # 假设n=5
ren=list(range(1,n+1)) # 将所有的人都放入一个列表中
count=0 # 用来计算报数
while len(ren)>1: #当列表中至少有2人的时候进行循环
new_ren=ren[:] #把原来的列表复制到新列表中,用来限制for循环的次数
for i in range(0,len(new_ren)): # 从第一个人开始报数
count=count+1 # 每报一次,count加1
if count
%3
==0: # 如果报到3
ren.remove(new_ren[i]) #把报到3的人从原列表中删除,进行下一轮循环
print(new_ren[1])
format格式化字符串:
此方法是使用一个字符串作为模板,使用{}作为占位符,
通过传入的参数替换占位符,就得到格式化后的字符串。
'''
#print('我叫{},今年{}岁'.format('王鼎文',11))
# split()
# sort()
# join()
n
=
input
()
list
=
n
.
split
(
','
)
new_list
=
[]
# 用来保存转换为整型的数字
for
i
in
list
:
new_list
.
append
(
int
(
i
))
new_list
.
sort
(
reverse
=
True
)
a
=
[
str
(
i
)
for
i
in
new_list
]
print
(
','
.
join
(
a
))
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment