IKH

Practice Question

Question 1

Write a python program to check whether the given string follow ABC language identifiers rules. Rules are given below:

  • The allowed characters are a-z,A-Z,0-9,#
  • The first character should be a lower case alphabet symbol from a to k
  • The second character should be a digit divisible by 3
  • The length of identifier should be atleast 2.
Python
import re
s=input("Enter Identifier:")
m=re.fullmatch("[a-k][0369][a-zA-Z0-9#]*",s)
if m!= None:
  print(s,"is valid Yava Identifier")
else:
  print(s,"is invalid Yava Identifier")

Output

PowerShell
Enter Identifier:a6kk9z##
a6kk9z## is valid Yava Identifier
PowerShell
Enter Identifier:z9b876
z9b876 is invalid Yava Identifier

Question 2

Write a python program to check whether the given number is valid mobile number or not?

Python
import re
n=input("Enter number:")
m=re.fullmatch("[7-9]\d{9}",n)
if m!= None:
  print("Valid Mobile Number")
else:
  print("Invalid Mobile Number")

Output

PowerShell
Enter number:9686968689
Valid Mobile Number
PowerShell
Enter number:6786786787
Invalid Mobile Number

Ungraded Questions

Get ready for an exhilarating evaluation of your understanding! Brace yourself as we dive into the upcoming assessment. Your active participation is key, so make sure to attend and demonstrate your knowledge. Let’s embark on this exciting learning journey together!

Report an error