编程题:
简单的输入输出:编程实现输入姓、名的提示语并接受用户输入,并单独显示姓、名和全名,执行效果如下所示:
Input your surname:ZHANG
Input your firstname:Dazhuang
Your surname is:
ZHANG
Your firstname is:
Dazhuang
Your full name is:
ZHANG Dazhuang
在看参考程序之前你成功了吗?
参考答案:
surname = input('Input your surname:') firstname = input('Input your firstname:') print('Your surname is:') print(surname) print('Your firstname is:') print(firstname) print('Your full name is:') print(surname,firstname)
从键盘输入两个整数,求这两个整数的和、差、积、商(尝试用一般除法和整除两种方式)并输出。
提示:注意input()函数的返回类型
选择题:
以下表达式中,哪一个选项的运算结果是False?
A.'abc' < 'ABC'
B.(3 is 4) == 0
C.8 > 4 > 2
D.9 < 1 and 10 < 9 or 2 > 1
解析: A、ASCII表中,大写字母排在小写字母前面,字符'A'的ASCII码值为65,字符'a'的ASCII码值为97
以下哪一个语句不可以打印出"hello world"字符串(结果需在同一行)?
A.
print('''hello world''')
B.
print('hello world')
C.
print('hello \ world')
D.
print("hello world")
解析: A、三引号可以原样输出字符串 C、“\”是续行符
Python中input()函数的返回的是以下哪一种类型?
A.str
B.dict
C.int
D.list
如果想要查看math库中pi的取值是多少,可以利用以下什么方式(假设已经执行了import math,并且只要包含pi取值就可以)?
A.print(pi)
B.print(math.pi)
C.dir(math)
D.help(math)
解析:
A、需要使用math.pi
C、dir(modulename)只能简单列出模块中包含的函数和符号常量名字
D、help(modulename)会列出模块中包含的函数、符号常量等定义
以下哪些不是Python的关键字?
A.from
B.dict
C.list
D.as