3. 完成下面的代码填空,绘制五角星。 from import # 设置绘图区域500*500,窗口位于屏幕中心 penup() # 提起笔移动,不绘制图形,用于另起一个地方绘制 (-100, 50) # 将画笔移动到指定坐标位置 pendown() # 画笔移动时绘制图形 # 设置画笔和画刷为红色 begin_fill() # 准备开始填充图形 for i in range(5): forward(200) # 向当前画笔方向移动200个像素长度 right(144) # 顺时针移动144度 end_fill() # 填充完成 # 隐藏箭头 done()
时间: 2023-06-14 16:07:49 浏览: 173
```python
from turtle import *
setup(500, 500)
setpos(0, 0)
penup()
goto(-100, 50)
pendown()
pencolor('red')
fillcolor('red')
begin_fill()
for i in range(5):
forward(200)
right(144)
end_fill()
hideturtle()
done()
```
相关问题
import random x = [random.randint(0,100) for i in range(20)] print(x) y = x[0:10] y.sort() #**********begin1********** x[______] = y #**********end1********** y = x[10:20] y.sort(reverse=True) #**********begin2********** x[______] = y #**********end2********** print(x)
以下是填空的代码:
```python
import random
x = [random.randint(0,100) for i in range(20)]
print(x)
y = x[0:10]
y.sort()
#**********begin1**********
x[0:10] = y
#**********end1**********
y = x[10:20]
y.sort(reverse=True)
#**********begin2**********
x[10:20] = y
#**********end2**********
print(x)
```
这个程序中,我们首先生成了一个长度为 20,元素在 0 到 100 之间随机选取的列表 `x`。然后,我们将 `x` 列表中的前 10 个元素赋值给列表 `y`,并对 `y` 进行升序排序。接着,我们将排好序的 `y` 列表赋值给 `x` 列表中的前 10 个元素。
下面,我们对 `x` 列表中的后 10 个元素做同样的操作。我们将 `x` 列表中的后 10 个元素赋值给列表 `y`,并对 `y` 进行降序排序。最后,我们将排好序的 `y` 列表赋值给 `x` 列表中的后 10 个元素。
最后,我们通过 `print()` 函数输出排好序的 `x` 列表。
使用input()函数,输入一个绝对路径和若干个文件类型的扩展名(均以逗号分隔),传入函数 get_file( ),返回输出此路径下所有(不包括子文件夹)符合若干文件类型扩展名的文件引用名。 请完善填空。 注意:除要求填空的位置之外,请勿改动程序中的其他内容。 import os #**********SPACE********** N=( input( )) 【?】 # *********SPACE********** def get file(【?】): for f in os. listdir(path): file=os. path. join(path,f) if os. path. isdir(file): continue else: if file. endswith(q): print(file) #**********SPACE get file(【?】)
import os #**********SPACE**********
N=( input( ))
exts = input().split(",") # *********SPACE**********
def get_file(path, exts):
for f in os.listdir(path):
file=os.path.join(path,f)
if os.path.isdir(file):
continue
else:
for q in exts:
if file.endswith(q):
print(file)
break #**********SPACE
get_file(N, exts)