1204

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

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


str1=input("请输入你的名字:") str2="您好!"+str1 print('{:*^20}'.format(str2))

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

f=float(input('请输入一个浮点数'))
f1=int(f)
f2=f-f1#得到小数
if f2>=0.5:
    f2=1
    print(f1+f2)
else:
    print(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

 

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

  c. 5 is 6 or 3 and 0 and 3

 

本次课程我学会了python的背景,python的基本数据类型 一小部分的函数例如:abs() 绝对值函数  int() 整型函数  divmod() 整除,取余函数      pow()次方函数

切片[start:end:step]      索引 index      读入input()    输出 print()   

 

posted on 2018-12-04 19:29  fpybky  阅读(376)  评论(0编辑  收藏  举报

导航