You can download this code by clicking the button below.
This code is now available for download.
This function uses the Faker library to generate a dictionary containing a user's name, email, phone number, address, and company.
Technology Stack : Python, Faker
Code Type : Python Function
Code Difficulty : Intermediate
import random
from faker import Faker
def generate_random_user_data():
fake = Faker()
name = fake.name()
email = fake.email()
phone_number = fake.phone_number()
address = fake.address()
company = fake.company()
return {
"name": name,
"email": email,
"phone": phone_number,
"address": address,
"company": company
}
# JSON Output