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.