How to create RANDOM Numbers in Python?

This recipe helps you create RANDOM Numbers in Python

Recipe Objective

Many a times we need a random number so how we can get it?

So this is the recipe on how we can create RANDOM Numbers in Python.

Step 1 - Loading Library

We have imported numpy which is needed. import numpy as np

Step 2 - Generating Random Numbers

We have generated a few random number numbers with the help of function np.random we have used a attribute normal to make sure that it comes from a normal distribution. print(np.random.normal()) print(np.random.normal(size=14)) print(np.random.uniform(size=14)) print(np.random.randint(low=1, high=100, size=14)) So the output comes as

0.13675095711660307

[-1.5024633   0.36342989  0.70793256 -0.9789945   0.61796606  0.98637534
  1.32068877  1.81571864  0.23038631  0.65866147  0.7082002   0.01925767
  1.94746162 -1.38092815]

[0.16054208 0.00366705 0.03862502 0.27800544 0.32018415 0.95070521
 0.34582893 0.40153549 0.37467516 0.36899577 0.47037688 0.74223317
 0.18082368 0.9568694 ]

[83 48 72 16 89 80  6 17 71 59 52 56 87 45]

Download Materials


What Users are saying..

profile image

Anand Kumpatla

Sr Data Scientist @ Doubleslash Software Solutions Pvt Ltd
linkedin profile url

ProjectPro is a unique platform and helps many people in the industry to solve real-life problems with a step-by-step walkthrough of projects. A platform with some fantastic resources to gain... Read More

Relevant Projects

Build a Medical AI Assistant using Unsloth and QLoRA
In this AI Project, you will learn to fine-tune the LLaMA 3.1 8B model using Unsloth and QLoRA to build a domain-specific medical AI assistant capable of accurate, context-aware, and memory-efficient clinical conversations. It also integrates a Streamlit chatbot interface for real-time interaction and deployment.

Hands-On Approach to Regression Discontinuity Design Python
In this machine learning project, you will learn to implement Regression Discontinuity Design Example in Python to determine the effect of age on Mortality Rate in Python.

NLP Project on LDA Topic Modelling Python using RACE Dataset
Use the RACE dataset to extract a dominant topic from each document and perform LDA topic modeling in python.

Learn How to Build a Linear Regression Model in PyTorch
In this Machine Learning Project, you will learn how to build a simple linear regression model in PyTorch to predict the number of days subscribed.

AWS MLOps Project to Deploy Multiple Linear Regression Model
Build and Deploy a Multiple Linear Regression Model in Python on AWS

Build a Text Generator Model using Amazon SageMaker
In this Deep Learning Project, you will train a Text Generator Model on Amazon Reviews Dataset using LSTM Algorithm in PyTorch and deploy it on Amazon SageMaker.

MLOps Project to Deploy Resume Parser Model on Paperspace
In this MLOps project, you will learn how to deploy a Resume Parser Streamlit Application on Paperspace Private Cloud.

Build Regression Models in Python for House Price Prediction
In this Machine Learning Regression project, you will build and evaluate various regression models in Python for house price prediction.

Avocado Machine Learning Project Python for Price Prediction
In this ML Project, you will use the Avocado dataset to build a machine learning model to predict the average price of avocado which is continuous in nature based on region and varieties of avocado.

Predictive Analytics Project for Working Capital Optimization
In this Predictive Analytics Project, you will build a model to accurately forecast the timing of customer and supplier payments for optimizing working capital.