top of page
learn_data_science.jpg

Data Scientist Program

 

Free Online Data Science Training for Complete Beginners.
 


No prior coding knowledge required!

Writer's pictureBah Alain Sei

How to write a program that generates passwords?


As part of the Data Science training program, we were asked to choose a project to be carried out followed by a project of their choice. My choice of work fell on the project concerning password generation.

import string

import random


lettres=string.ascii_letters

chiffres= string.digits

ponc= string.punctuation


while True:

try:

ulettres= eval (input("Lettres (True ou False): "))

uchiffres= eval (input("Chiffres (True ou False): "))

uponc = eval(input("Ponctuation (True ou False): "))


L=int(input("Longueur du mot de passe: "))


char = ""

char += Lettres if ulettres else ""

char += chiffres if uchiffres else ""

char += ponc if uponc else ""


passe ="".join(random.choices(char, k=l))

print(passe)

except:

print("veillez suivre les instructions")

try:

if eval(input("Quitter (True ou False): ")):

break

except:

print("Veuillez suivre les instructions")



1 comment

Recent Posts

See All

1 則留言


Data Insight
Data Insight
2021年9月14日

Your code should be in a code snippet. Also explain what your code is doing and how it works giving examples.

按讚
bottom of page