Recap:
What does the isalpha() function in Python return?
A. True if all characters in the string are alphabets, else False.
B. True if all characters in the string are numbers, else False.
C. True if all characters in the string are alphanumeric, else False.
D. True if all characters in the string are spaces, else False.
What does the count() function in Python do?
A. It counts the total number of characters in a string.
B. It counts the occurrences of a specified substring within a string.
C. It returns true if all characters in the string are alphabets.
D. It returns true if all characters in the string are numbers.
What is the purpose of the find() function in Python strings?
A. It returns the position of the last occurrence of a substring within a
string.
B. It returns true if the string begins with a specified prefix.
C. It returns the position of the first occurrence of a substring within a
string.
D. It returns true if all the letters in the string are lowercased.
Predict the output of the following
codes:
1. str=“My Blog” 2 for i in
a=‘ ‘ .
range(2,7,2):
for i in
print(i*'2')
range(len(str)):
a+=str[i]
print(a)
3. s=“welcome to my site
https://ictieskwt.com”
print(s.find(‘com’))
print(s.find(‘o’))
print(s.find(‘o’,10,20))
print(s.find(‘o’,5,10))
s="look to
future“
s[8:10]
s[-4:-2]
s[-2:]
s1="smart
class“
s1[0:3:3]
s1[1:3:2]
s1[2:3:2]
Join the answers to all these questions and guess the
answer. s1[-8:-6]
1.isspace()
2.lstrip(), rstrip() and
strip()
3.startswith(), endswith()
4.replace()
5.join()
6.split()
Write a program that inputs individual words of your school
motto and joins them to make a string.
w1=input("Enter word1:")
w2=input("Enter word2:")
w3=input("Enter word3:")
w4=input("Enter word4:")
motto=' '.join([w1,w2,w3,w4])
print("Motto of our school
is:",motto)
Enter word1:To prepare
Enter word2:global citizens,
Enter word3:To provide
Enter word4:leadership for future
Motto of our school is: To prepare global citizens, To provide leadership
for future