Generate N Random Hexadecimal Numbers | Python3 program for the above approach ; Maximum length of the random integer ; Function to generate N Hexadecimal integers ; Stores all the possible charcters in the Hexadecimal notation ; Loop to print N integers ; Randomly select length of the int in the range [ 1 , maxSize ] ; Print len charcters ; Print a randomly selected character ; Driver Code
import random , math NEW_LINE maxSize = 10 ; NEW_LINE def randomHexInt ( N ) : NEW_LINE INDENT hexChar = [ '0' , '1' , '2' , '3' , '4' , '5' , '6' , '7' , '8' , '9' , ' A ' , ' B ' , ' C ' , ' D ' , ' E ' , ' F ' ] ; NEW_LINE for i in range ( N ) : NEW_LINE INDENT Len = math . floor ( random . random ( ) * ( maxSize - 1 ) + 1 ) NEW_LINE for j in range ( Len ) : NEW_LINE INDENT print ( hexChar [ math . floor ( random . random ( ) * 16 ) ] , end = " " ) ; NEW_LINE DEDENT print ( ) ; NEW_LINE DEDENT DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT N = 3 ; NEW_LINE randomHexInt ( N ) ; NEW_LINE DEDENT