python基础操作

  1. 下列程序运行结果为:
x=77

print('%c  %X'%(x+32 ,x+32) )
下列程序运行结果:
x=5935.1476

print('%5.3f\t%e\n%12.5f'%(x,x,x))

下列程序运行结果:

x=2.5

y=4.7

a=7

print(x+a%3*int(x+y)%2//4)

下列程序运行结果:

a=3

b=4

c=5

print( a or b+c and b-c )

print(a+b>c and b==c )

print( not (a>b) and not c or 1 )

print( not (a+b)+c-1 and b+c/2 )

 

  1. 编写程序:从键盘输入两个两位数,组成一个新的四位数,如:x=25,y=46,则z=4526.(程序控制在5行以内)

 

 

 

import turtle as t

t.pensize(5)

t.color('red')

t.right(72)

t.forward(200)

t.right(144)

t.forward(200)

t.right(144)

t.forward(200)

t.right(144)

t.forward(200)

t.right(144)

t.forward(200)

t.done()

#绘制一个田字方格的方框

import turtle

#先利用循环绘制一个正方形

for i in range(4):

    turtle.forward(200)

    turtle.left(90)

turtle.forward(100)

turtle.left(90)

turtle.forward(200)

turtle.penup()

turtle.goto(0,100)

turtle.pendown()

turtle.seth(0)

turtle.forward(200)

turtle.done()

import turtle

#本程序使用turtle绘制4个相切的圆形

#移动到第一个坐标点,画第一个圆形

#注意:turtle.circle(radius)方法画圆是在圆形最低点逆时针方向画圆,所以后面的图形的坐标要计算好

turtle.penup()

turtle.goto(-50,0)

turtle.pendown()

turtle.circle(50)

#移动到下一个坐标点

turtle.penup()

turtle.goto(50,0)

turtle.pendown()

#画第二个圆

turtle.circle(50)

#移动到下一个坐标点

turtle.penup()

turtle.goto(-50,-100)

turtle.pendown()

#画第三个圆

turtle.circle(50)

#移动到下一个坐标点

turtle.penup()

turtle.goto(50,-100)

turtle.pendown()

#画第四个圆

turtle.circle(50)

turtle.done()

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值