python 基础习题 1204

1. 写一段程序实现以下功能

  读入用户输入的姓名,打印"你好!xxx",要求输出的字符串占20个宽度,不够补*,居中对齐

  

s = input("请输入姓名:")
t = '你好:'+s
print("{:*^20}".format(t))

2.人类的思维习惯于"四舍五入",请问int在做强转的时候会四舍五入吗?如果不会,想办法是的其进行四舍五入

    不会     

f = 0.335
f1 = 0.565
m = f+0.5
n = f1+0.5
print(int(m))
print(int(n))

  或:

f = float(input(请输入一个小数:))
f1 = f+0.5
print(int(f1))

  

3.python中的变量名字可以是中文吗?请尝试

  可以已尝试过 

4.下列语句哪个是非法的(b

    a. x = y = z = 1  b. x=(y=z+1)  c. x, y = y, x  d. x += y

5.以下各个语句的值

  a. 1 and 0 or 2 and 3 or 3 and 0                  0

  b. 100 % 2 and 5 or 3 and 5 < 100               True

  c. 5 is 6 or 3 and 0 and 3                              0

posted @ 2018-12-04 19:12  米线Max  阅读(79)  评论(0)    收藏  举报