編程題:
簡單的輸入輸出:編程實現輸入姓、名的提示語並接受用戶輸入,並單獨顯示姓、名和全名,執行效果如下所示:
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