In python there are different ways to generate id’s. Let’s see how different types of Id’s can be generated using python without using inbuilt Python libraries.
1. Generating Random Integer as Ids’
Code #1 : Print 10 random values of numbers between 1 and 100.
76 72 7 78 77 19 24 23 77 96
Code #2 : Print random numbers between 1 and 100 which are multiple of 5.
60 30 35 100 85 25 100 20 90 85
Generating Random numbers is not unique, Same number can repeat itself. It generates only Integer values.
2. Generating Random String as Ids’
Generating Random string id’s consists of letters and digits. This can be useful in generating passwords as its provide the encryption and decryption technique.
Code #1 : Show how to generate random string id’s.
Code #2 : Using Function call
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course