1.Lowercase to Uppercase converter:
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)
2.First letter Only 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)
3.Letters 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)
4.Word Count :
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)
5.Password Validation :
text = input("Create your password: ")
upper = False
lower = False
number = False
special = False
valid = True
i = 0
while i < len(text):
ch = text[i]
if "A" <= ch <= "Z":
upper = True
elif "a" <= ch <= "z":
lower = True
elif "0" <= ch <= "9":
number = True
elif ch in "!@#$&":
special = True
else:
valid = False
i += 1
if len(text) < 8:
print("Password must be at least 8 characters")
else:
if not valid:
print("Only allowed special characters: ! @ # $ &")
if not upper:
print("Add at least one uppercase letter")
if not lower:
print("Add at least one lowercase letter")
if not number:
print("Add at least one number")
if not special:
print("Add at least one special character: ! @ # $ &")
if upper and lower and number and special and valid:
print("Password successfully created")
Top comments (0)