Sunday, April 18, 2021

Python Random Function

import math

import random

import string



def generate_random_digit(length):

    digits = "0123456789"

    otp = ""


    for i in range(length):

        otp += digits[math.floor(random.random() * 10)]


    print(otp)



def generate_random(length):

    print(string.ascii_uppercase)

    print(string.ascii_lowercase)

    print(string.ascii_letters)

    print(string.digits)

    print(''.join(random.choices(string.digits, k=length)))

    print(''.join(random.choices(string.ascii_letters+string.digits, k=length)))

    print(''.join(random.choices(string.ascii_uppercase+string.digits, k=length)))



generate_random_digit(8)

generate_random(10)

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.

ALCATEL 6900

write memory copy running certified reload from working no rollback-timeout