Primary U.S. interstate highways are numbered 1-99. Odd numbers (like the 5 or 95) go north/south, and evens (like the 10 or 90) go east/west. Auxiliary highways are numbered 100-999, and service the primary highway indicated by the rightmost two digits. Thus, I-405 services I-5, and I-290 services I-90.
Given a highway number, indicate whether it is a primary or auxiliary highway. If auxiliary, indicate what primary highway it serves. Also indicate if the (primary) highway runs north/south or east/west.

Respuesta :

Answer:

num1 = input("Enter the Highway Number?(max digit allowed 3)")

n = int(num1)

def calc1(n):

   Lst = []

   while n > 0:

       remainder = n % 10

       Lst.append(remainder)

       quotient = int(n / 10)

       n = quotient

       

   return(Lst)

n1=calc1(n)

if len(n1) <3:

   if n1 % 2 == 0:

       print("The Highway(primary) go east west")

   else:

       print("The Highway(primary) go north south")

else:

   if len(n1)== 3:

       Highwaynumber = int(n1[1]) * 10 + int(n1[0])

       if Highwaynumber % 2 == 0:

           print("The Highway serves primary highway that go east west and primary highway number is I-" +str(Highwaynumber))

       else:

           print("The Highway serves primary highway that go north south and primary highway number is I-" +str(Highwaynumber))

   else:

       print("You entered wrong highway number")

Explanation:

First, we find all the digits of the number and store it in a list. This list is dynamic in nature. However, for this problem. we have mentioned that a number of digits should not be more than 3 as highway numbers cannot be of a higher order than that. And thereafter the program is self-explanatory.

ACCESS MORE
EDU ACCESS