CodeSolved

A comprehensive source of programming questions and exercises

Password Generator (Password Generator)

Practice Easy 279/ Download 607 Views

Write a function that creates a random password with the following conditions and returns

Includes the letters A to Z small and large
Includes numbers of 0 to 9
Password length should be between 8 and 10 characters

11 Answers

This answer is only visible to premium members
This answer is only visible to premium members
This answer is only visible to premium members
let msg = 'error'
alert(msg) 
This answer is only visible to premium members
This answer is only visible to premium members

This answer is only visible to premium members

Subscription is currently unavailable.
This answer is only visible to premium members
This answer is only visible to premium members
This answer is only visible to premium members
let msg = 'error'
alert(msg) 
This answer is only visible to premium members
This answer is only visible to premium members

This answer is only visible to premium members

Subscription is currently unavailable.
This answer is only visible to premium members
This answer is only visible to premium members
This answer is only visible to premium members
let msg = 'error'
alert(msg) 
This answer is only visible to premium members
This answer is only visible to premium members

This answer is only visible to premium members

Subscription is currently unavailable.
import random
def Password_Generator():
    char_upper='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
    char_lower=char_upper.lower()
    num='123456789'
    all= char_upper + char_lower + num
    len = random.randrange(8,11)
    print(''.join(random.sample(all,len)))
Password_Generator()
import random
import string
password = ''.join(random.choices(string.ascii_letters +
                   string.digits, k=random.randint(8, 10)))
print(password)
User 2159 Download Python
import random
c=[]
while 1:
        a=['a',"b","c","d","e","f","g","h",'i','j','k','l','m','n','o','p','q','r','s','t','u','v','1','w','x','y','z,','3','4','5','6','7','8','9','0']
        b=random.choice(a)
        c.append(b)
        if len(c)>8 and len(c)<10: break
print(''.join(c))
User 489 Download Python
import random
def password_generator():
    letaher_lower_case = "abcdefghijklmnopqrstuvwxyz"
    letaher_upper_case = letaher_lower_case.upper()
    numbers = "1234567890"
    string = letaher_lower_case + letaher_upper_case + numbers
    password_lenght = random.randint(8, 10)
    password = "".join(random.sample(string, password_lenght))
    return password
print(password_generator())
Nima1393 Download Python
import random
characters = "'abcdefghijklmnopqrstuvwxyz123456789()*&^%$#@!?><ABCDEGHIJKLMNOPQRSTUVWXYZ'"
number=int(input("How many characters should it be?:"))
randompasword="".join (random.sample(characters,number))
print(randompasword)
print('===============================')
Omid.asadi Download Python
def Pasvord() :
    import random as r
    H = "QWERTYUIOPLKJHGFDSAZXCVBNM0123456789qwertyuiopasdfghjklmnbvcxz"
    n = r.randint(8,10)
    The_String = ""
    for i in range(n) :
         number = r.randint(1 , 62)
         The_String = The_String + H[number]
    print(The_String)
Pasvord()

Arshia.a Download Python
import random
import string

def generate_random_password():
    """یک پسورد تصادفی با شرایط مشخص شده ایجاد می‌کند."""
    # Determining permitted characters
    characters = string.ascii_letters + string.digits  # Lowercase and uppercase letters and numbers
    password_length = random.randint(8, 10)  # Password length between 8 and 10 characters

    # Create random password
    password = ''.join(random.choice(characters) for _ in range(password_length))
    
    return password

# Function test
if __name__ == "__main__":
    random_password = generate_random_password()
    print(f"پسورد تصادفی: {random_password}")
Mma123 Download Python
<< Previous page 1 2 Next page >>

Submit answer

Submitting answers is currently unavailable.

Related content

Detection using AI
×
×
Close