Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

in python Question 2 (6 points): Define a random password generator function, similar to the lab question. Your function should take one input n, which

in pythonimage text in transcribed

Question 2 (6 points): Define a random password generator function, similar to the lab question. Your function should take one input n, which will be the length of the password to be generated. For this problem, make sure that n is between 8 and 16, and if the user enters an integer less than 8 you should instead assume n = 8, and if the user enters an integer greater than 16 you should assume n = 16. Your function should import the random module and use the random.choice( ) function to print out a random string of n characters from these possible characters: Any character from 'abcdefghijklmnopqrstuvwxyz' Any character from 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' Any character from '0123456789' Any of the special characters !@#$%^&*() The password must contain at least one uppercase letter, at least one lowercase letter, at least one digit, and at least one special character. In addition, the password may not contain more than 3 letters (either upper case or lower case) in a row. If either of these conditions are violated, simply re-roll a new random password from scratch (and do this as many times as necessary). For full credit, each character must be randomly chosen from one of these four categories with equal probability among the four categories (meaning each category has a 25% chance of being picked from each time). Also for full credit, you should create at least one "helper function (google "helper function if you don't know what it means) to break down this task into smaller tasks. If you find yourself nesting loops and if statements more than 3-ish levels deep, you should really create a "helper function" to reduce the amount of nesting involved in the main function. Do your best

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Students also viewed these Databases questions