python作业01

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

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

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

 

 

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

f = float( input('输入:') )
print(f,"的四舍五入后为:",int( f + 0.5 ))

 

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

3

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

True

  c. 5 is 6 or 3 and 0 and 3

0

运算符不能熟练掌握

posted on 2018-12-04 18:39  Sjwei  阅读(108)  评论(0)    收藏  举报