top of page
learn_data_science.jpg

Data Scientist Program

 

Free Online Data Science Training for Complete Beginners.
 


No prior coding knowledge required!

Password Generator from Username using Python



In this post, you will learn how to create a random string passwords in Python. Using a random and string module, we can write our own password generator.


Steps to Create a Random String


1- Import String and Random modules

2- Use the string constant digits and symbols and the function upper() and lower()

3- Use a for loop and random.choice() function to choose characters from a source

4- Generate a password generator



Let's code a function that generates a password from the username.

1- Import modules


2- Input the username to generate the password


3- Define our function generate_password

3-1 Convert the username to uppercase and lowercase letters.

store numbers and symbols

"digits contain '0123456789'

punctuation contain all special symbols '!”#$%&'()*+,-./:;<=> @[\]^_`{|}~.' "

3-2 Generate random characters from lowercase, uppercase username and all (numbers and symbols)


3-3 Concatenate and return password from username, numbers and symbols



There is our function below


Let's test our funtion



Output:


You can find the whole project on my Github


0 comments

Recent Posts

See All

COURSES, PROGRAMS & CERTIFICATIONS

 

Advanced Business Analytics Specialization

Applied Data Science with Python (University of Michigan)

Data Analyst Professional Certificate (IBM)

Data Science Professional Certificate (IBM)

Data Science Specialization (John Hopkins University)

Data Science with Python Certification Training 

Data Scientist Career Path

Data Scientist Nano Degree Program

Data Scientist Program

Deep Learning Specialization

Machine Learning Course (Andrew Ng @ Stanford)

Machine Learning, Data Science and Deep Learning

Machine Learning Specialization (University of Washington)

Master Python for Data Science

Mathematics for Machine Learning (Imperial College London)

Programming with Python

Python for Everybody Specialization (University of Michigan)

Python Machine Learning Certification Training

Reinforcement Learning Specialization (University of Alberta)

Join our mailing list

Data Insight participates in affiliate programs and may sometimes get a commission through purchases made through our links without any additional cost to our visitors.

bottom of page