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

Ed Godalle

Director Data Analytics at EY / EY Tech
linkedin profile url

I am the Director of Data Analytics with over 10+ years of IT experience. I have a background in SQL, Python, and Big Data working with Accenture, IBM, and Infosys. I am looking to enhance my skills... Read More

Relevant Projects

GCP MLOps Project to Deploy ARIMA Model using uWSGI Flask
Build an end-to-end MLOps Pipeline to deploy a Time Series ARIMA Model on GCP using uWSGI and Flask

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.

Deep Learning Project- Real-Time Fruit Detection using YOLOv4
In this deep learning project, you will learn to build an accurate, fast, and reliable real-time fruit detection system using the YOLOv4 object detection model for robotic harvesting platforms.

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.

Azure Text Analytics for Medical Search Engine Deployment
Microsoft Azure Project - Use Azure text analytics cognitive service to deploy a machine learning model into Azure Databricks

NLP Project to Build a Resume Parser in Python using Spacy
Use the popular Spacy NLP python library for OCR and text classification to build a Resume Parser in Python.

Text Classification with Transformers-RoBERTa and XLNet Model
In this machine learning project, you will learn how to load, fine tune and evaluate various transformer models for text classification tasks.

Classification Projects on Machine Learning for Beginners - 2
Learn to implement various ensemble techniques to predict license status for a given business.

NLP Project for Multi Class Text Classification using BERT Model
In this NLP Project, you will learn how to build a multi-class text classification model using using the pre-trained BERT model.

Time Series Forecasting with LSTM Neural Network Python
Deep Learning Project- Learn to apply deep learning paradigm to forecast univariate time series data.