Generate Random Float Number in Python Last Updated : 23 Jul, 2025 Comments Improve Suggest changes Like Article Like Report Generating a random float number in Python means producing a decimal number that falls within a certain range, often between 0.0 and 1.0. Python provides multiple methods to generate random floats efficiently. Let’s explore some of the most effective ones.Using random.random()random.random() method random module is the most straightforward way to generate a random float number between 0.0 and 1.0. It’s fast, lightweight and ideal for general-purpose tasks where cryptographic security isn't a concern. Python import random a = random.random() print(a) Output0.8680250182868856 Using numpy.random.random()numpy.random.random() function is particularly useful when working with numerical arrays or when high performance is required for large-scale data operations. It also generates a float between 0.0 and 1.0 and is optimized for vectorized and scientific computing. Python import numpy as np a = np.random.random() print(a) Output0.25262934628790734 Using secrets.SystemRandom().random()SystemRandom().random() is a secure alternative to random.random() and is ideal when you need randomness that is safe for security-related applications like password generation or token creation. Python import secrets a = secrets.SystemRandom().random() print(a) Output0.32998191766596596 Using random.uniform(a,b)random.uniform(a, b) function allows you to generate a random float within any specified range [a, b]. Unlike random.random() which is fixed to the 0–1 range, this is more flexible and useful when you need values outside of that interval, such as simulating random prices, measurements or delays. Python import random a = random.uniform(1, 10) print(a) Output1.6991835366920784 Related Articlesrandom modulerandom.random()numpy.random.random()secrets.SystemRandom.random()random.uniform(a,b) Comment More infoAdvertise with us Next Article Company-wise Practice Problems M moneeshnagireddy Follow Improve Article Tags : Python python-basics Practice Tags : python Similar Reads Interview PreparationInterview Preparation For Software DevelopersMust Coding Questions - Company-wise Must Do Coding Questions - Topic-wiseCompany-wise Practice ProblemsCompany PreparationCompetitive ProgrammingSoftware Design-PatternsCompany-wise Interview ExperienceExperienced - Interview ExperiencesInternship - Interview ExperiencesPractice @GeeksforgeeksProblem of the DayTopic-wise PracticeDifficulty Level - SchoolDifficulty Level - BasicDifficulty Level - EasyDifficulty Level - MediumDifficulty Level - HardLeaderboard !!Explore More...Data StructuresArraysLinked ListStackQueueBinary TreeBinary Search TreeHeapHashingGraphAdvance Data StructuresMatrixStringAll Data StructuresAlgorithmsAnalysis of AlgorithmsSearching AlgorithmsSorting AlgorithmsPattern SearchingGeometric AlgorithmsMathematical AlgorithmsRandomized AlgorithmsGreedy AlgorithmsDynamic ProgrammingDivide & ConquerBacktrackingBranch & BoundAll AlgorithmsProgramming LanguagesCC++JavaPythonC#Go LangSQLPHPScalaPerlKotlinWeb TechnologiesHTMLCSSJavaScriptBootstrapTailwind CSSAngularJSReactJSjQueryNodeJSPHPWeb DesignWeb BrowserFile FormatsComputer Science SubjectsOperating SystemsDBMSComputer NetworkComputer Organization & ArchitectureTOCCompiler DesignDigital Elec. & Logic DesignSoftware EngineeringEngineering MathematicsData Science & MLComplete Data Science CourseData Science TutorialMachine Learning TutorialDeep Learning TutorialNLP TutorialMachine Learning ProjectsData Analysis TutorialTutorial LibraryPython TutorialDjango TutorialPandas TutorialKivy TutorialTkinter TutorialOpenCV TutorialSelenium TutorialGATE CSGATE CS NotesGate CornerPrevious Year GATE PapersLast Minute Notes (LMNs)Important Topic For GATE CSGATE CoursePrevious Year Paper: CS exams Like