1) Which of the following statements contain valid Python string literals? Select all that are correct: a) string = 'We're #1!' b) string = Hello, world. c) string = "1234" d) string = 'Hello, world.' e) string = 1234 f) string = "We're #1!" 2) Joining two strings with the + operator is called… a) A string method b) String concatenation c) String slicing d) String indexing 3) String methods change the original string. a) True b) False 4) What’s the value of x after this code snippet executes? x = 1234 + 5 a) '1239' b) 1239 c) 12345 d) '12345' 5) What’s the value of x after this code snippet executes? x = "1234" + 5 a) Trick question—this fails with a TypeError b) 12345 c) '12345' d) '1239' 6) What is the output of print(10 - 4 * 2) a) 2 b) 12 7) What is the output of the expression print(18 // 4) a) -4 b) 4 c) -5 d) 5 8) a = [10, 20, 30, 40, 50] Which output is different from the others? a) print(a[::]) b) print(a[0:4]) c) print(a[0:5]) d) print(a[0:len(a)]) 9) What is the output of print(2 ** 3 ** 2) Caution: the exponent operator works from right to left. a) 64 b) 512 10) What is the output of the following code print(bool(0), bool(3.14159), bool(-3), bool(1.0+1j)) a) True True False True b) False True True True c) True True False False d) False True False True 11) Select which is true for Python tuple. Select all that are correct: a) A tuple maintains the order of items b) A tuple is unordered c) We cannot change the tuple once created d) We can change the tuple once created
0%
Python Exercises (print,operators,list,string)
共用
共用
共用
由
Berkkeskin0707
編輯內容
列印
嵌入
更多
作業
排行榜
顯示更多
顯示更少
此排行榜當前是私有的。單擊
共用
使其公開。
資源擁有者已禁用此排行榜。
此排行榜被禁用,因為您的選項與資源擁有者不同。
還原選項
測驗
是一個開放式範本。它不會為排行榜生成分數。
需要登錄
視覺風格
字體
需要訂閱
選項
切換範本
顯示所有
播放活動時將顯示更多格式。
打開結果
複製連結
QR 代碼
刪除
恢復自動保存:
?