Computer Science, asked by akshatjha89, 9 months ago

I need a python program for generating a random 8 digit numeric code and then send it to the email given by the user in a text box ​

Answers

Answered by tanishmajumdar2912
2

Answer:

# import library  

import math, random  

# function to generate OTP  

def generateOTP() :  

# Declare a digits variable  

# which stores all digits  

digits = "0123456789"

OTP = ""  

# length of password can be chaged  

# by changing value in range  

for i in range(8) :  

 OTP += digits[math.floor(random.random() * 10)]  

return OTP  

# Driver code  

if __name__ == "__main__" :  

 

print("OTP of 8 digits:", generateOTP())  


akshatjha89: how do you create a text box in which the user enters his email and then the number generated is delivered to that email
tanishmajumdar2912: Follow this code :
tanishmajumdar2912: aster = Tk()
e = Entry(master)
e.pack()

e.focus_set()

def callback():
print e.get() # This is the text you may want to use later

b = Button(master, text = "OK", width = 10, command = callback)
b.pack()

mainloop()
akshatjha89: there isnt any text box for the user to enter his email
tanishmajumdar2912: You can try this in Tkinter module
akshatjha89: i did but no textbox is showing
tanishmajumdar2912: It should be there check it again
akshatjha89: ok
Similar questions