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