1) Define a string in Python. a) A sequence of numbers b) A sequence of characters c) A list of integers d) A collection of objects 2) Which of the following represents a string in Python? a) 123 b) hello world c) "Hello, World!" d) [1, 2, 3] 3) Which of the following data types is NOT a string in Python? a) 'Python' b) """Welcome""" c) [1, 2, 3] d) "String Example" 4) How would you create an empty string in Python? a) "" b) '' c) str() d) All of the above 5) Which method is used to create a string with a single character? a) str() b) chr() c) character() d) new_string() 6) How can you concatenate two strings in Python? a) Using the + operator b) Using the * operator c) Using append() d) Using join() 7) How do you access the first character of the string "Python"? a) Python[0] b) Python[1] c) Python[1:3] d) Python('0') 8) What will str = "Hello"[2] return? a) "Hello" b) "He" c) "l" d) "e" 9) Which index will give you the last character of a string in Python? a) len(str) b) len(str) - 1 c) -1 d) Both b and c 10) Which loop is commonly used to traverse over a string? a) while b) for c) do-while d) for-in 11) What will be the output of the following code? What will str = "Hello World!"; str[::2] return? a) "Hello World!" b) "Hoo ol!" c) "Hello" d) "Hello W" 12) Which of the following operations will return True? a) "Python" == "python" b) "Python".lower() == "python" 13) "hello world".upper() . predict the output? a) "hello world" b) "HELLO WORLD" 14) Which statement is true about strings in Python? a) Strings can be changed after creation. b) Strings are immutable objects 15) How can you modify the string "Hello" in Python? a) By reassigning it to a new string value b) By using str.replace() c) By using string[0] = "H" d) Strings cannot be modified in Python 16) Which built-in function can be used to find the length of a string? a) length() b) len() c) size() d) count() 17) What will str = "Hello"; str.count("l") return? a) 1 b) 2 c) 3 d) none 18) What will str = "Python"; str.find("o") return? a) 1 b) 2 c) 4 d) -1 19) Which method would you use to replace all occurrences of "old" with "new" in a string? a) replace() b) swap() c) change() d) modify() 20) Which function can be used to check if a string contains only alphabetic characters? a) isalpha() b) isdigit() c) isalnum() d) isalphaor()
0%
strings quiz
共享
共享
共享
由
Mohd015162
编辑内容
打印
嵌入
更多
作业
排行榜
显示更多
显示更少
此排行榜当前是私人享有。单击
,共享
使其公开。
资源所有者已禁用此排行榜。
此排行榜被禁用,因为您的选择与资源所有者不同。
还原选项
随堂测验
是一个开放式模板。它不会为排行榜生成分数。
需要登录
视觉风格
字体
需要订阅
选项
切换模板
显示所有
播放活动时将显示更多格式。
打开成绩
复制链接
QR 代码
删除
恢复自动保存:
?