Westonci.ca is the best place to get answers to your questions, provided by a community of experienced and knowledgeable experts. Explore a wealth of knowledge from professionals across various disciplines on our comprehensive Q&A platform. Join our Q&A platform to connect with experts dedicated to providing accurate answers to your questions in various fields.

Write the code (from to )using for loop andif elseif statementto accept themobile phone numbersof200 residents of Dubaiasstringand check if thelength of eachmobile number is10. Depending on the first 3 characters of the mobile number,display the messagefrom the table below:First 3 charactersMessage“050”, “054”, “056”Etisalat number“052”,“055”, “058”DunumberFor anyother input(if the phone number is not a ten digit number or if it does not start with any of the above digits)Not a valid mobile number

Sagot :

Answer:

In Python:

nos = int(input("How many phone number: "))

for i in range(1,nos+1):

   phn = input("Phone Number: ")

   if not len(phn) == 10:

       print("Invalid")

   else:

       charactersMessage = phn[0:3]

       if charactersMessage in ['050', '054', '056']:

           print("Etisalat Number")

       elif charactersMessage in ['052', '055', '058']:

           print("Du Number")

       else:

           print("Invalid")

Explanation:

Prompts the user for the frequency of phone numbers to check

nos = int(input("How many phone number: "))

This iterates through the phone numbers

for i in range(1,nos+1):

This prompts the user for phone number

phn = input("Phone Number: ")

Prints invalid id number length is not 10

if not len(phn) == 10:

   print("Invalid")

If otherwise

else:

This gets the first 3 characters

   charactersMessage = phn[0:3]

Prints Etisalat number if the characters are either 050, 054 or 056

   if charactersMessage in ['050', '054', '056']:

       print("Etisalat Number")

Prints Du number if the characters are either 052, 055 or 058

   elif charactersMessage in ['052', '055', '058']:

       print("Du Number")

Prints error if otherwise

   else:

       print("Invalid")

Thanks for using our service. We aim to provide the most accurate answers for all your queries. Visit us again for more insights. Thank you for your visit. We're dedicated to helping you find the information you need, whenever you need it. Westonci.ca is here to provide the answers you seek. Return often for more expert solutions.