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
แก้ไขเนื้อหา
สั่งพิมพ์
ฝัง
เพิ่มเติม
กำหนด
ลีดเดอร์บอร์ด
แสดงเพิ่มขึ้น
แสดงน้อยลง
ลีดเดอร์บอร์ดนี้ตอนนี้เป็นส่วนตัว คลิก
แชร์
เพื่อทำให้เป็นสาธารณะ
ลีดเดอร์บอร์ดนี้ถูกปิดใช้งานโดยเจ้าของทรัพยากร
ลีดเดอร์บอร์ดนี้ถูกปิดใช้งานเนื่องจากตัวเลือกของคุณแตกต่างสำหรับเจ้าของทรัพยากร
แปลงกลับตัวเลือก
แบบทดสอบ
เป็นแม่แบบแบบเปิดที่ไม่ได้สร้างคะแนนสำหรับลีดเดอร์บอร์ด
ต้องลงชื่อเข้าใช้
สไตล์ภาพ
แบบ อักษร
ต้องสมัครสมาชิก
ตัวเลือก
สลับแม่แบบ
แสดงทั้งหมด
รูปแบบเพิ่มเติมจะปรากฏเมื่อคุณเล่นกิจกรรม
เปิดผลลัพธ์
คัดลอกลิงค์
คิวอาร์โค้ด
ลบ
คืนค่าการบันทึกอัตโนมัติ:
ใช่ไหม