Python Tutorial for Beginners #16 - Random Password Generator PROJECT!

preview_player
Показать описание
Another awesome python project! In today's video we create our own python code to produce a random password comprised of alternating upper and lowercase letters!

🔔NEW videos, tutorials and projects EVERY week so subscribe and hit the bell button so you don't miss an update!

▶️Watch our Python Projects tutorials playlist here:

▶️Watch our full Python tutorial course here:

👊🖐✌️Why not teach yourself how to code Rock, Paper, Scissors in Python!
Video here:

🔗 Social Media Links 🔗

💸 Donations 💸
⬇️Any donations are gratefully received & all donations go straight back into this channel!⬇️

⭐️ Hashtags ⭐️
#CodeOfTheFuture #WomenWhoCode #Python #Coding #Programming #Tutorials

Subscribers - 398
Рекомендации по теме
Комментарии
Автор

Some comments!!

Firstly, the upper & lowercase password can be simplified. I'd realised this after filming so it's worth mentioning! You can simplify it as follows:
password = ""
for i in range(5):
i = chr(random.randint(65, 90))
j = chr(random.randint(65, 90)).lower()
password = str(password) + i + j
print(password)

Secondly, if you want to add numbers to your password, you can!! In python we can't concatenate strings and integers (numbers). The way you overcome that is by creating a new variable which produces random integers from 0 to 9, we'll call it k, and simply putting 'str' around it. Your new code should look like this altogether,

password = ""
for i in range(5):
i = chr(random.randint(65, 90))
j = chr(random.randint(65, 90)).lower()
k = random.randint(0, 10)
password = str(password) + i + j + str(k)
print(password)

I tried this out on my own laptop and it produced 'Ht7Im9Ml2Vl1Yz0'. Awesome!

CodeoftheFuture
Автор

This is great! Really loving this introduction. I found that another way to shift between lower and uppercase letters, you can use modulus 2 of i.

for i in range(10):
if i % 2 ==2:
i = chr(randint(65, 90))
else:
i = chr(randint(65, 90)).lower()
password=str(i)+password

voorhees
Автор

Thank you very much Ellie. As for the second part (Upper and lower case), I don't see the loop is necessary as this can be done like that:

password = ""
for i in range(5):
i = chr(random.randint(65, 90))
j = chr(random.randint(65, 90)).lower()
password = str(password) + i + j
print(password)


The second loop you used may be useful if the password needed is 50 letters in length if we just changed the indentation of the concatenation line to be beneath the second loop like that:

password = ""
for i in range(5):
i = chr(random.randint(65, 90))
for j in range(5):
j = chr(random.randint(65, 90)).lower()
password = str(password) + i + j
print(password)


KhalilYasser
Автор

Thank you for this very helpful and easy to follow tutorial. I'll definitely be subscribing to see what you have in store for us next. Thank you again!

DarkFighter
Автор

Late comment in this one, I was wondering about the list relating to the number reference such as alphabet (65, 90) and vice versa for number this is using ASCII list?

francoisjarzabek
Автор

That's good 👍, hey, how Can I do a Pytest program to test it? Thanks

irvinrp-ven
Автор

J variable was initialize in the inner for loop, why was it able to be used in the outer for loop?

jetspray
Автор

Hello.

I want to if i can do this.

Can l make the password that get genatoar go in to a text document.

tailgater
Автор

Thank you for this great video. My question is how do I creat a random password with letters and numbers?

Dotto
Автор

Thank you so much for this video! It's so easy to understand!! How would I add special characters?

stacyericson
Автор

hey Ellie!!! thank you for this tutorial, just to know if we can add integers into the passwords would you give an idea about how I could do that ... I'll surely google it out but wanted to know how would you do that!

PS -> I am surely an amatuer 😅🤞🏻

enchantedchoco
Автор

Why did you str cast password when password is already set as a string?

jetspray
Автор

Does anyone know how I would shuffle the password so its in random order?

ryanruppert
Автор

I think at 3:30, password is already a string, so I guess there is no need to convert it to a string, Correct me please If I am wrong. Nice Video, by the way.

anupamkasturia
Автор

How to hack Wi-Fi password
(plzz make a one video)
😊😊

multiplex