# Code
from random import randint
def ran(n):
x = int(‘9’*(n-1))+1 # first n-digit number, string is converted back to int
y = int(‘9’*n) # last n-digit number
return randint(x, y)
print(‘Random number of digit 3 is’, ran(3))
print(‘Random number of digit 5 is’, ran(5))
# Output
Random number of digit 3 is 883
Random number of digit 5 is 78720