String and list methods
14 important questions on String and list methods
What is the expected output of the following code?
for ch in "def":
print(chr(ord(ch) + 1), end='')
What is the expected output?
t = "zeta"
print(t.endswith("a"))
print(t.endswith("A"))
print(t.endswith("et"))
print(t.endswith("eta"))
2. False
3. False
4. True
What is the expected output?
print('[' + 'thijs'.center(20, '*') + ']')
- Higher grades + faster learning
- Never study anything twice
- 100% sure, 100% understanding
What is the expected output?
t = 'theta'
print(t.find('eta'))
print(t.find('the'))
print(t.find('ha'))
0
-1
What is the expected output?
print('kappa'.find('a', 2, 4))
What is the expected output?
print('30'.isalpha())
print('lambda'.isalpha())
print('lambda30'.isalpha())
print('lambda_30'.isalpha())
True
False
False
What is the expected output?
print('30'.isalpha())
print('lambda'.isalpha())
print('lambda30'.isalpha())
print('lambda_30'.isalpha())
True
False
False
What is the expected output?
print(",".join(["omicron", "pi", "rho"]))
What is the expected output?
print("www.cisco.com".lstrip("w."))
- Removes leading "w." characters from the string.
What is the expected output?
print("This is it!".replace("is", "are", 1))
What is the expected output?
print("tau tau tau".rfind("ta"))
print("tau tau tau".rfind("ta", 9))
print("tau tau tau".rfind("ta", 3, 9))
-1
4
What is the expected output of the following code?
for ch in "abc123XYX":
if ch.isupper(): print(ch.lower(), end='')
elif ch.islower(): print(ch.upper(), end='')
else: print(ch, end='')
What is the expected output of the following code?
s1 = 'Where are the snows of yesteryear?'
s2 = s1.split()
print(s2[-2])
What is the expected output of the following code?
s = 'It is either easy or impossible'
s = s.replace('easy', 'hard').replace('im', '')
print(s)
The question on the page originate from the summary of the following study material:
- A unique study and practice tool
- Never study anything twice again
- Get the grades you hope for
- 100% sure, 100% understanding