NEW
Font size
WorksheetsQuiz về kiểu dữ liệu Str
Total questions: 17
Worksheet time: 9mins
Kết quả của đoạn code sau là gì?
s = "Hello, world!"
print(len(s))
12
13
14
15
Cách nào dưới đây tạo một chuỗi rỗng?
s = " "
s = str()
s = ' '
Tất cả đều đúng.
Lệnh nào dùng để truy xuất ký tự đầu tiên của chuỗi s = "Python"?
s(0)
s[0]
s{0}
s.first()
s = "Python"
print(s[-1])
P
n
o
h
Lệnh nào dưới đây dùng để lấy chuỗi con "thon" từ chuỗi s = "Python"?
s[2:6]
s[-4:]
s[2:]
Cả ba cách.
Kết quả của đoạn code sau là gì?
s = "Python"
print(s[: : -1]
"Python"
"nohtyP"
"n"
Lỗi.
Lệnh nào giúp nối hai chuỗi a = "Hello" và b = "World" thành "Hello World"?
a + b
a + " " + b
a.append(b)
a.join(b)
s = "hello"
print(s.upper())
hello
HOLLE
Hello
HELLO
Hàm nào giúp chuyển "PYTHON" thành "python"?
s.toLower()
s.lower()
s.capitalize()
s.swapcase()
s = "hello world"
print(s.title())
"Hello world"
"Hello World"
"hello world"
"HELLO WORLD"
Lệnh nào giúp kiểm tra chuỗi "Python" có trong s = "I love Python" hay không?
"Python" in s
s.contains("Python")
s.has("Python")
s.find("Python") > 0
Kết quả của đoạn code sau là gì?
s = "Python is fun"
print(s.replace("Python", "Coding"))
"Python is fun"
"Coding is fun"
"Coding fun"
"Python Coding fun"
Kết quả của đoạn code sau là gì?
s = "Python is fun"
print(s.find("is"))
7
8
1
2
Kết quả của đoạn code sau là gì?
s = "Python is fun"
print(s.find("java"))
7
8
1
-1
Lệnh nào giúp tách chuỗi s="hihi,hehe,hoho" thành danh sách ["hihi", "hehe", "hoho"]?
s.split(",")
s.split()
s.cut(",")
s.slice(",")
Chuỗi "12345" có thể chuyển thành số nguyên bằng cách nào?
int("12345")
str("12345")
float("12345")
list("12345")
Kết quả của đoạn code sau là gì?
s = "Hello World"
print("-".join(s.split()))
"Hello-World"
"Hello - World"
"Hello- World"
"HelloWorld"
