random name generator code example

Example 1: random name generator python

import random
import time

print('WARNING: If you want less than 10 names, too bad you cant. Just lower the name count.')

name1 = input('please enter the first name: ')
print(' ')
name2 = input('please enter the second name: ')
print(' ')
name3 = input('please enter the third name: ')
print(' ')
name4 = input('please enter the fourth name: ')
print(' ')
name5 = input('please enter the fith name: ')
print(' ')
name6 = input('please enter the sixth name: ')
print(' ')
name7 = input('please enter the seventh name: ')
print(' ')
name8 = input('please enter the eighth name: ')
print(' ')
name9 = input('please enter the nineth name: ')
print(' ')
name10 = input('please enter the tenth name: ')
print(' ')

Name_list = [name1, name2, name3, name4, name5, name6, name7, name8, name9, name10]

def ask():  
  global start

  print(' ')
  start = input('plese enter y to continue: ')
  print(' ')

ask()

if(start == 'y'):
  print('Generating...')
  time.sleep(1.25)
  print(' ')
  print('Generated!')
  print(' ')
  print('Random Name Generated: ')
  print(random.choice(Name_list))
  print(' ')
elif(start != 'y'):
  print(' ')
  ask()
  print(' ')

Example 2: random photo generator

// change the numbers to whatever dimensions you need

https://picsum.photos/200/300

Example 3: random password generator

function rand_string( $length ) {
	$str = "";
	$chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";

	$size = strlen( $chars );
	for( $i = 0; $i < $length; $i++ ) {
		$str .= $chars[ rand( 0, $size - 1 ) ];
	}

	return $str;
}
//and call the function this way:
$mypass = rand_string(10);

Tags:

Php Example