# File: moWePins.py # Author: Dr. Gibson # Date: 11/14/2016 # Section: N/A # E-mail: k.gibson@umbc.edu # Description: # This file contains python code that creates and stores # randomly-generated pins for users. import random QUIT1 = "quit" QUIT2 = "exit" MIN_PIN = 0 MAX_PIN = 9999 def main(): # seed with system time (the default) random.seed() passes = {} # message that will be printed to the user msg = "Please enter a username for the system\n" + \ "Or choose '" + QUIT1 + "' or '" + QUIT2 + "' to quit." userChoice = input(msg) while userChoice != QUIT1 and userChoice != QUIT2: # the username already exists in the dictionary if passes.get(userChoice) != None: print("The PIN for", userChoice, "is", passes[userChoice] ) # the username DOESN'T already exist else: # randomly generate a PIN for the user newPin = random.randrange(MIN_PIN, MAX_PIN + 1, 1) passes[userChoice] = newPin print("The PIN for new user", userChoice, \ "is", passes[userChoice] ) # get new input userChoice = input(msg) #print(passes) main()