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 代码
删除
恢复自动保存:
?