python第一次作业

目录

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()

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值