Day 5 of #100DaysOfCode: Security Password Generator

On Day 5 of #100DaysOfCode, I have created another mini project called the security password generator. This project consists of the following concepts I have learned from Dr Angela Yu's 100DaysOfCode: The Complete Python Bootcamp Udemy course. Specifically, I applied knowledge about:

  • For Loops with Python Lists

  • For Loops and Range() function

In the Security Password Generator, the aim is to create a tool that asks the users to enter the number of letters, symbols and numbers they want inside their secure password. For example, if a user has requested for 5 letters, 5 symbols and 5 numbers, security password generator has the ability to create a password that would contain 15 characters that meets the user's request. These characters are arranged in any random order, providing them a secure password which can be used for multiple accounts such as Outlook and any web, desktop and mobile application.

Python Concepts Used:

For Loops and Range() function

Range function is used within for loops in this project to control the iteration process. For instance, the user requests for 5 letters in their secure password which creates a new variable number_of_letters to store the user input. It loops the task from range between 1 and number_of_letters. In the range function, it doesn't include the last character which is why plus one (number_of_letters + 1) is needed to ensure the final character which is 5 is included in the range.

For Loops with Python Lists

In this mini project, for loop is created to manage letters, symbols and numbers. In the example from the previous paragraph, a loop variable named generate_letter is created. This variable is used to select a letter randomly from a predefined python list which contains both upper-case and lower-case alphabetical letters. The letter is then passed into an empty python list [] which is assigned to a new variable called password. Then it uses random.shuffle() function to re-arrange the letters that are inside the password python list in random order. It continues the iteration until it finishes the 5th and final letter. The same process are repeated to generate random symbols and numbers. They are then concatenated together in the password python list using "".join(password) and printed out to create a newly generated secure password.

for generate_numbers in range(1, number_of_numbers + 1):
    generate_numbers = random.choice(numbers)
    password += generate_numbers
    random.shuffle(password)

Takeaways from Security Password Generator

This mini project has played a huge role in reinforce my understanding of for loops with python lists and range function. I have still used breakpoints to help understand how the letters, numbers and symbols are randomly selected, get passed into the empty password list and how they randomly shuffle the strings inside the password list to make the password more complex.

Overall, this is another project that I enjoyed building. To access the full code - https://github.com/keiransystem14/Python100daysofcode/tree/main/Day%205%20Project%20-%20Security%20Password%20Generator