Menu

Post image 1
Post image 2
Post image 3
Post image 4
Post image 5
Post image 6
Post image 7
Post image 8
1 / 8
0

String Programs

DEV Community·Sasireka·29 days ago
#UBf7ERMV
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…

Continue reading — create a free account

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

Read More