- 下列程序运行结果为:
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 )
- 编写程序:从键盘输入两个两位数,组成一个新的四位数,如: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()