Menu

1 / 7

String Programs

DEV Community·Sasireka·6 months ago
#UBf7ERMV
#coding#python#programming#basic#upper
Reading 0:00
15s threshold

1) Uppercase Letter

text = input ( " Enter some words : " ) i = 0 upper = "" while i < len ( text ): ch = text [ i ] if ch >= " a " and ch <= " z " : upper = upper + chr ( ord ( ch ) - 32 ) else : upper = upper + ch i += 1 print ( upper )

Enter fullscreen mode

Exit fullscreen mode

Output:

2) First Letter Uppercase

text = input ( " Enter some words : " ) i = 0 upper = "" while i < len ( text ): ch = text [ i ] if ( ch >= " a " and ch <= " z " ) and ( text [ i - 1 ] == " " or i == 0 ): upper = upper + chr ( ord ( ch ) - 32 ) else : upper = upper + ch i += 1 print ( upper )

Enter fullscreen mode

Exit fullscreen mode

Output:

3)Letter Count

text = input ( " Enter some words : " ) i = 0 count = 0 while i < len ( text ): ch = text [ i ] if ( ch >= " a " and ch <= " z " ) or ( ch >= " A " and ch <= " Z " ): count += 1 i += 1 print ( count )

Enter fullscreen mode

Exit fullscreen mode

Output:

4) Word Count

text = input ( " Enter some words : " ) i = 0 count = 1 while i < len ( text ): if text [ i ] !=…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.