Mundo em Python

Gerar palavras passes

from tkinter import *
import random
root = Tk()
root.title("Gerar palavra-passe")
root.configure(bg="yellow")
root.geometry("300x300")
root.resizable(0,0) def limpar():
numerodeletras.delete(0, END)
def gerarpass():
chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789=+!@#$%^&*<>/~-:;?"
password =" "
n=int(numero.get())
for c in range(n):
password = password + random.choice(chars)
resultado.set(password) textotitulo = Label(text="Gerar uma Palavra-Passe",font=("arial","15","bold"),fg="green",bg="yellow")
textotitulo.place(relx=0.1,rely=0.05)
textonumero = Label(text="Qual é o número de caracteres?",font=("arial","12","bold"),fg="blue",bg="yellow")
textonumero.place(relx=0.08,rely=0.2) numero = IntVar()
numerodeletras = Entry(textvariable=numero,
font=("arial","11","bold"),fg="black",justify='center')
numerodeletras.place(relx=0.25,rely=0.4) bt_calcular1 = Button( text="Calcular", bd=2, bg='#107db2',
fg='white',
font=('verdana', 12, 'bold'),command=gerarpass)
bt_calcular1.place(relx=0.05, rely=0.55, relwidth=0.35, relheight=0.1) limpar1 = Button( text="limpar", bd=2, bg='#107db2',
fg='white', font=('verdana', 12, 'bold'),
command=limpar)
limpar1.place(relx=0.45, rely=0.55, relwidth=0.35, relheight=0.1) textoresultado= Label(text="Resultado",
font=("arial","12","bold"),fg="blue")
textoresultado.place(relx=0.35,rely=0.7)
resultado = StringVar()
resultado1 = Label(textvariable=resultado,
font=("arial","12","bold"),fg="black",bg="yellow")
resultado1.place(relx=0.25,rely=0.8)
root.mainloop()
#import random
#
#number = input("How many characters do you need:")
#int1 = int(number)
#for c in range(int1):
# password += random.choice(chars)
#print(password)
0