热门

最新

红包

立Flag

投票

同城

我的

发布
qq_59861678
丽绮
3 年前
trueqq_59861678

# 指定一个点,判断其所在象限
x = int(input('请输入X坐标:'))
y = int(input('请输入Y坐标:'))

if x > 0 and y > 0:
print('输入的坐标在第一象限')
elif x < 0 and y > 0 :
print('输入的坐标在第二象限')
elif x < 0 and y < 0 :
print('输入的坐标在第三象限')
elif x > 0 and y < 0 :
print('输入的坐标在第四象限')

CSDN App 扫码分享
分享
评论
点赞
打赏
  • 复制链接
  • 举报
下一条:
# 海龟绘图之棋盘 # x1[(-400,400), (400,400)],那么x1[0]是不是(-400,400), x1[0][0]代表取-400 import turtle # 如果不赋值p = turtle.Pen(),turtle.Pen()是一个 对象,如果直接调用turtle.Pen()参与循环的,每次都会创建一个新的turtle.Pen()对象,这样就是产生你这个运行结果 # p = turtle.Pen() width = 30 num = 18 x1 = [(-400,400),(-400+width*num,400)] y1 = [(-400,400),(-400,400-width*num)] t = turtle.Pen() t.speed(18) # 绘图速度 # t.goto(x1[0][0],x1[0][1]) # t.goto(x1[1][0],x1[1][1]) for i in range(num+1): # 循环18次 t.penup() # 抬笔 t.goto(x1[0][0],x1[0][1]-30*i) t.pendown() # 下笔 t.goto(x1[1][0],x1[1][1]-30*i) for i in range(num+1): t.penup() t.goto(y1[0][0] + 30 * i, y1[0][1]) t.pendown() t.goto(y1[1][0] + 30 * i, y1[1][1]) t.hideturtle() # 隐藏画笔 turtle.done()
立即登录