1. Full String Upper
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. Every First Letter Upper
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. First Letter only Uppercase
text=input("Enter some words: ")
i=0
count=0
upper=""
while i<len(text):
ch=text[i]
if (ch>="a" and ch<="z")or(ch>="A" and ch<="Z"):
count+=1
else:
upper=upper+ch
i+=1
print(count)
Output:
4. Word Counter
text=input("Enter some words: ")
i=0
count=1
upper=""
while i<len(text):
ch=text[i]
if text[i]!=" " and text[i-1]==" ":
count+=1
i+=1
print(count)
Output
5. Password Verify
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")
elif not upper:
print("please inclued upper char in password")
elif not lower:
print("please inclued lower char in password")
elif not number:
print("please inclued number in password")
elif not spacial:
print("please inclued spacial chars: ! @ # $ & in password")
else:
print("spacial charactor only allow !, @, #, $, & ")
Output





Top comments (0)