
Originally published byDev.to
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
🇺🇸
More news from United StatesUnited States
NORTH AMERICA
Related News
How Braze’s CTO is rethinking engineering for the agentic area
11h ago
Amazon Employees Are 'Tokenmaxxing' Due To Pressure To Use AI Tools
22h ago
KDE Receives $1.4 Million Investment From Sovereign Tech Fund
2h ago
Instagram’s new ‘Instants’ feature combines elements from Snapchat and BeReal
2h ago
Six Claude Code Skills That Close the AI Agent Feedback Loop
2h ago


