حالت آفلاین — محتوا از حافظهٔ کش نمایش داده می‌شود

پسورد جنریتور (Password Generator)

تمرین آسان 2154 visibility link download flag

تابعی بنویسید که یک پسورد تصادفی با شرایط زیر ایجاد کند و برگرداند

شامل حروف a تا z کوچک و بزرگ
شامل اعداد 0 تا 9
طول پسورد باید بین 8 تا 10 کاراکتر باشد

reply 17

visibility

// آرایه contents || مشمولات شامل حروف انگلیسی و عدد مجاز هست

function passwordGenerator() {
  let password = "";
  for (let i = 1; i <= rangeRandNumber(8, 10); i++) {
    password += Contents[randNummber(35)];
  }

  console.log(password);
}

function rangeRandNumber(min, max) {
  return Math.round(Math.random() * (max - min) + min);
}

function randNummber(num) {
  return Math.round(Math.random() * num);
}

import random
import string

def generate_password(length=8):
  """
  A function to generate a random password with a specified length.
  Arguments:
      length: Password length (default 8 characters)
  return:
      A string containing a randomly generated password
  """

  # Define the set of allowed characters
  characters = string.ascii_letters + string.digits

  # Generate a random string of specified length
  password = ''.join(random.choice(characters) for _ in range(length))

  return password

# Example of using the function
password_length = random.randint(8, 10)
# We choose the length of the password randomly between 8 and 10
password = generate_password(password_length)
print("Random generated password:", password)
def password():
    horof = str(input("enter your str a,z and A,Z = "))
    num = int(input("enter your number is 0_9 ="))
    new_password = f"{horof}{num}"
    if 8<len(new_password)<10:
       print(f"new passowrd = {new_password}")
    else:
        print(False)
password()   

import random
import string
def generate_password():
    lowercase = string.ascii_lowercase  
    uppercase = string.ascii_uppercase  
    digits = string.digits  
    all_characters = lowercase + uppercase + digits  
    password_length = random.randint(8, 10)
    password = ''.join(random.choices(all_characters, k=password_length))
    return password
print(generate_password())
import random
import string

lower = string.ascii_lowercase
upper = string.ascii_uppercase
symbole = "!@#$%^&()?><~"
number = "0123456789"

all = lower + upper + symbole + number

while True:
    print("choise and opption:\n\t1)creeat a passwored\n\t2)Exite")
    choise = input("youre Choise:")
    if choise == "1":
        length = int(input("enter the length of passwore: "))
        password = "".join((random.sample(all,length)))
        print(password)
    elif choise == "2":
        break    
    else:
        print("youre choise is wrong! \n")
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

def generate_password():
    length = random.randint(8, 10)
    characters = string.ascii_letters + string.digits
    password = ''.join(random.choice(characters) for _ in range(length))
    return password

print(generate_password())
پاسخ هوش مصنوعی Ai Python
import string, random
lowercase = string.ascii_lowercase
uppercase = string.ascii_uppercase
numbers = string.digits
all_char = lowercase + uppercase + numbers
password_list = ''
for i in range(random.randint(8,11)):
    random_char = random.choice(all_char)
    password_list += random_char
print(password_list)
<< صفحه قبل 1 2 صفحه بعد >>

ارسال جواب

جوابت را با Markdown بنویس و ثبت کن

×
بستن