w3resource

Python Projects: Create random name profile etc

Python Project-9 with Solution

Create a Python project to create random name (first name, full name etc.) profile etc.

Sample Solution:

Python Code:

main.py

#Source: https://bit.ly/3hlxaq1
#firt create a object for class 'Name'
import random_profile as rp
num = int(input("Input number of random name/full name/profile: "))
name = rp.Name(num)
'''
name = rp.Name(num=1)
num = Total No. of Name You Want To Print
deafult is 1
To Print More Than one Name Change value of num
'''
print("For First Name: ")
name.first_name()

print("\nFor Full Name:")
name.full_name()

print("\nFor Full Profile:")
name.full_profile()

Flowchart:

Python Flowchart: Create random name profile etc

random_profile.py

import random
fname = ['John', 'Jane', 'Corey', 'Travis', 'Dave', 'Kurt', 'Neil', 'Sam', 'Steve', 'Tom', 'James', 'Robert', 'Michael', 'Charles', 'Joe', 'Mary', 'Maggie', 'Nicole', 'Patricia', 'Linda', 'Barbara', 'Elizabeth', 'Laura', 'Jennifer', 'Maria','Adam','Sturt','Nikolson','Tom','Harry','Ruskin','Thor','Rocky','Ravid','David','Harris','Eion','Elon','Mark','Will','Chris']
lname = ['Smith', 'Doe', 'Jenkins', 'Robinson', 'Davis', 'Stuart', 'Jefferson', 'Jacobs', 'Wright', 'Patterson', 'Wilks', 'Arnold', 'Johnson', 'Williams', 'Jones', 'Brown', 'Davis', 'Miller', 'Wilson', 'Moore', 'Taylor', 'Anderson', 'Thomas', 'Jackson', 'White', 'Harris', 'Martin','Potter','Jukerberg','Smith','Nebula','Downy','Downy Jr']
street_names = ['Main', 'High', 'Pearl', 'Maple', 'Park', 'Oak', 'Pine', 'Cedar', 'Elm', 'Washington', 'Lake', 'Hill']
fake_cities = ['Metropolis', 'Eerie', "King's Landing", 'Sunnydale', 'Bedrock', 'South Park', 'Atlantis', 'Mordor', 'Olympus', 'Dawnstar', 'Balmora', 'Gotham', 'Springfield', 'Quahog', 'Smalltown', 'Epicburg', 'Pythonville', 'Faketown', 'Westworld', 'Thundera', 'Vice City', 'Blackwater', 'Oldtown', 'Valyria', 'Winterfell', 'Braavos‎', 'Lakeview']
states = ['AL', 'AK', 'AZ', 'AR', 'CA', 'CO', 'CT', 'DC', 'DE', 'FL', 'GA', 'HI', 'ID', 'IL', 'IN', 'IA', 'KS', 'KY', 'LA', 'ME', 'MD', 'MA', 'MI', 'MN', 'MS', 'MO', 'MT', 'NE', 'NV', 'NH', 'NJ', 'NM', 'NY', 'NC', 'ND', 'OH', 'OK', 'OR', 'PA', 'RI', 'SC', 'SD', 'TN', 'TX', 'UT', 'VT', 'VA', 'WA', 'WV', 'WI', 'WY']

class Name:
    def __init__(self,num=1):
        '''
        num = Total No. of Name You Want To Print
        deafult is 1
        To Print More Than one Name Change value of num
        ''' 
        self.num = num

    def first_name(self):
        #print first name
        for i in range(self.num):
          first = random.choice(fname)
          print(first)

    def last_name(self):
        #print last name
        for i in range(self.num):
          last = random.choice(lname)
          print(last)
   
    def full_name(self):
        #print full name
        for i in range(self.num):
          first = random.choice(fname)
          last = random.choice(lname)
          print(f'{first} {last}')

    def full_profile(self):
        #print full profile
        
        for i in range(self.num):
          first = random.choice(fname)
          last = random.choice(lname)
          phone = f'+91-{random.randint(800, 999)}{random.randint(800, 999)}{random.randint(1000,9999)}'

          street_num = random.randint(100, 999)
          street = random.choice(street_names)
          city = random.choice(fake_cities)
          state = random.choice(states)
          zip_code = random.randint(10000, 99999)
          
          address = f'{street_num} {street} St., {city} {state} {zip_code}'
          email = first.lower() + last.lower() + '@bogusemail.com'
          print(f'{first} {last} \n {address}- Us\n{phone}\n{email}')
          print('-'*30)
        print('*'*30)

Output:

Input number of random name/full name/profile:  10
For First Name: 
Linda
Adam
Jennifer
James
Elon
Tom
Jane
Joe
Barbara
Sturt

For Full Name:
Eion White
Tom Potter
Harry Jones
Neil Jukerberg
Adam Moore
Eion Williams
Will Nebula
Travis Davis
Mark Potter
Elizabeth Taylor

For Full Profile:
Joe Brown 
 516 Washington St., Quahog TX 89444- Us
+91-9959907040
[email protected]
------------------------------
Charles Davis 
 731 Washington St., Epicburg AL 56161- Us
+91-8858612588
[email protected]
------------------------------
Chris Downy Jr 
 304 Lake St., Pythonville MA 33999- Us
+91-8059992824
chrisdowny [email protected]
------------------------------
Sam Jones 
 877 High St., Oldtown UT 77089- Us
+91-9579231799
[email protected]
------------------------------
Sam Jones 
 796 Park St., Eerie NM 11273- Us
+91-9658289648
[email protected]
------------------------------
Joe Harris 
 612 Washington St., Vice City CA 69686- Us
+91-9148787505
[email protected]
------------------------------
Jane Robinson 
 389 Maple St., Dawnstar VT 94392- Us
+91-8218264020
[email protected]
------------------------------
Sturt Stuart 
 970 High St., Faketown OH 94619- Us
+91-8509832149
[email protected]
------------------------------
Linda Johnson 
 605 Hill St., Braavos‎ RI 30382- Us
+91-9739705315
[email protected]
------------------------------
Corey Jacobs 
 427 High St., Eerie IL 54100- Us
+91-8889856191
[email protected]
------------------------------
******************************

Flowchart:

Python Flowchart: Create random name profile etc.

Contribute your code and comments through Disqus.



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://www.w3resource.com/projects/python/python-projects-9.php