1.Write a program to check whether a given Gmail ID is valid or not.
Python
def verify_Gmail(Gmail):
i=0
while i<len(Gmail):
current=Gmail[i]
i+=1
if current>="a" and current<="z":
continue;
elif current>="A" and current<="Z":
continue;
elif current>="0" and current<="9":
continue;
elif current=="@" or current=="." or current=="_":
continue;
else:
return False
if Gmail[-10:]=="@gmail.com":
return True
else:
return False
if verify_Gmail(input("Enter Your Gmail :")):
print("valid")
else:
print("invalid")
output
2. Write a program to check whether a given pincode is valid or not. A valid pincode must contain exactly 6 digits.
Python
pincode = int(input("Enter a pincode: "))
count = 0
temp = pincode
while temp > 0:
temp = temp // 10
count += 1
if count == 6 and pincode >= 100000 and pincode <= 999999:
print("YES")
else:
print("NO")
output
3.Write a program to check whether a given mobile number is valid or not.
Python
def mobile(n):
i=0
while i<len(n):
if(n[i]>="0" and n[i]<="9") or (n[i]=="+") or (n[i]==" "):
i+=1
else:
return "characters and special charactors not allowed"
if len(n)==10:
if n[0]>="6" and n[0]<="9":
return "valid";
else:
return "First number should not be less then 6 "
if len(n)==13:
if n[0:3]=="+91":
if n[3]>="6" and n[3]<="9":
return "valid"
else:
return "Fourth number should not be less then 6"
else:
return "First three number should like +91"
if len(n)==14:
if n[0:4]=="+91 ":
if n[4]>="6" and n[4]<="9":
return "valid"
else:
return "fifth number should not be less then 6"
return "First four number should like +91 "
return "Please Enter Your valid Mobile Number"
print(mobile(input("Enter Your Mobile Number : ")));
output



Top comments (0)