目录
1.下列程序运行结果为:
2.下列程序运行结果为:
3.下列程序运行结果为:
4.下列程序运行结果为:
5.编写程序:从键盘输入两个两位数,组成一个新的四位数,
6.编写程序功能如下:
7.编写程序功能如下:
8.绘制图形:
1.下列程序运行结果为:
x = 77
print('%c %x' % (x + 32, x + 32))
运行结果:
m 6d
2.下列程序运行结果为:
x = 5935.1476
print('%5.3f\t%e\n%12.5f' % (x, x, x))
运行结果:
5935.148 5.935148e+03
5935.14760
3.下列程序运行结果为:
x = 2.5
y = 4.7
a = 7
print(x + a % 3 * int(x + y) % 2 // 4)
运行结果:
2.5
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)
运行结果:
3
False
1
False
5.编写程序:从键盘输入两个两位数,组成一个新的四位数,
如:x=25,y=46,则z=4526。(程序控制在五行以内)
x=int(input('请输入一个两位数:'))
y=int(input('请输入一个两位数:'))
z=y//10*1000+x%10*100+x//10*10+y%10
print('新四位数:',z)
运行结果:
请输入一个两位数:25
请输入一个两位数:46
新四位数: 4526
6.编写程序功能如下:
A=eval(input("Enter a numer between 0 and 1000:"))
b=A%10
c=A//100
d=(((A-b)/10)%10)
print("The sum of the digits is",int(b+c+d))
运行结果:
Enter a numer between 0 and 1000:999
The sum of the digits is 27
7.编写程序功能如下:
v, a = eval((input("Enter speed and acceleration: ")))
length = (v ** 2) / (2 * a)
print("The minimum runway 1ength for this airplane is %0.3f meters " % (length))
运行结果:
Enter speed and acceleration: 60,3.5
The minimum runway 1ength for this airplane is 514.286 meters
8.绘制图形:
(1)
import turtle
turtle.pensize(10)
turtle.right(90)
turtle.forward(200)
turtle.right(90)
turtle.forward(100)
turtle.right(90)
turtle.forward(200)
turtle.right(90)
turtle.forward(200)
turtle.right(90)
turtle.forward(200)
turtle.right(90)
turtle.forward(100)
turtle.right(90)
turtle.forward(100)
turtle.right(90)
turtle.forward(100)
turtle.right(180)
turtle.forward(200)
turtle.done()
(2)
import turtle as t
t.pensize(10)
t.penup()
t.goto(45, -45)
t.pendown()
t.circle(45)
t.penup()
t.goto(45, 45)
t.pendown()
t.circle(45)
t.penup()
t.goto(-45, 45)
t.pendown()
t.circle(45)
t.penup()
t.goto(-45, -45)
t.pendown()
t.circle(45)
t.done()
(3)
import turtle as t
t.pensize(10)
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()