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

BigMart Sales Prediction ML Project in Python
The goal of the BigMart Sales Prediction ML project is to build and evaluate different predictive models and determine the sales of each product at a store.

Census Income Data Set Project-Predict Adult Census Income
Use the Adult Income dataset to predict whether income exceeds 50K yr based oncensus data.

Ola Bike Rides Request Demand Forecast
Given big data at taxi service (ride-hailing) i.e. OLA, you will learn multi-step time series forecasting and clustering with Mini-Batch K-means Algorithm on geospatial data to predict future ride requests for a particular region at a given time.

Build Multi Class Text Classification Models with RNN and LSTM
In this Deep Learning Project, you will use the customer complaints data about consumer financial products to build multi-class text classification models using RNN and LSTM.

Tensorflow Transfer Learning Model for Image Classification
Image Classification Project - Build an Image Classification Model on a Dataset of T-Shirt Images for Binary Classification

Build CNN Image Classification Models for Real Time Prediction
Image Classification Project to build a CNN model in Python that can classify images into social security cards, driving licenses, and other key identity information.

Machine Learning Project to Forecast Rossmann Store Sales
In this machine learning project you will work on creating a robust prediction model of Rossmann's daily sales using store, promotion, and competitor data.

Build Regression (Linear,Ridge,Lasso) Models in NumPy Python
In this machine learning regression project, you will learn to build NumPy Regression Models (Linear Regression, Ridge Regression, Lasso Regression) from Scratch.

Image Classification Model using Transfer Learning in PyTorch
In this PyTorch Project, you will build an image classification model in PyTorch using the ResNet pre-trained model.

Build an Image Classifier for Plant Species Identification
In this machine learning project, we will use binary leaf images and extracted features, including shape, margin, and texture to accurately identify plant species using different benchmark classification techniques.