1.Lowercase to Uppercase
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)
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)
output:
3.Counting Letters
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)
output:
4.Counting Words
text=input("Enter some words :")
i=0
count=1
while i<len(text):
if text[i]!=" " and text[i-1]==" ":
count+=1
i+=1
print(count)
output:
5.Password Validator
text=input("Create your password :")
i=0
upper=False
lower=False
number=False
spacial=False
others=True
while i<len(text):
ch=text[i]
if ch>="A" and ch<="Z":
upper=True
elif ch>="a" and ch<="z":
lower=True
elif ch>="0" and ch<="9":
number=True
elif ch=="!" or ch=="@" or ch=="#" or ch=="$" or ch=="&":
spacial=True
else:
others=False
i+=1
if upper and lower and number and spacial and others:
print("password succesfully create")
else:
print("invalied try another")
output:





Top comments (0)