Ask Documentation
WebsiteGitHubPyPI
  • Introduction
  • Getting Started
    • Install & Get Started
    • Hello, World!
  • Routes & Requests
    • Routes
    • Defining Routes
    • Request Data
    • HTTP Status Codes & Methods
    • CORS
  • Response
    • JSON Response
    • JSON Response With an HTTP Status Code
  • Classes
    • Class Instance Variable
    • Initialization/Constructor Method
  • Data Types
    • Dictionaries
  • Built-in Utilities
    • Quick_set()
    • Deep()
    • Serialize()
    • Require_keys()
    • Random Generators
    • Pattern Matching
    • Email
  • Database
    • Ask and Databases
    • Models/Classes
      • Columns
      • Initialization/Constructor
      • Serialization
      • The &basic decorator
    • CRUD
      • Add
      • Select
      • Update
      • Delete
    • Check if a Row Exists
    • Sorting
    • Database Lists
  • JWT Authentication
    • Introduction
    • Protecting Routes
    • How to Create a Basic Login System
    • Properties & Methods of _auth
    • Making Requests to Protected Routes
  • Decorators
    • What are Decorators?
    • Create and Use Custom Decorators
    • Built-in Decorators
  • Security
    • Hashing
    • Route Security
    • Environment Variables
  • Configuring the Transpiler
  • Askfile.toml
  • Modules & Libraries
    • Importing an Ask Module
    • Includes
    • Importing Python Modules
  • Development Tools
    • Editor Syntax Highlighting
    • Automatic API documentation
    • CLI Flags
    • Running in development mode
    • Versioning System
  • Contribute
    • Feature Requests
    • Bug Reports
    • Contribute Code
Powered by GitBook
On this page
  • Int()
  • Parameters
  • Float()
  • Parameters
  • Element()
  • Parameters
Export as PDF
  1. Built-in Utilities

Random Generators

Generate pseudo-random numbers and choices.

Use the different methods of the built-in random object for this.

Int()

random.int(min, max, count)

Parameters

  • An integer.

  • The start of the range.

  • An integer.

  • The end of the range.

  • Optional parameter (default is 1)

  • How many random numbers to generate.

  • An integer.

Float()

random.float(min, max, count, decimals, unique)

Parameters

  • A float.

  • The start of the range.

  • A float.

  • The end of the range.

  • Optional parameter (default is 1)

  • How many random numbers to generate.

  • An integer.

  • Optional parameter (default is 16)

  • How many decimals (max) to include.

  • A boolean (True/False).

  • Should the numbers generated be unique?

Element()

random.element(iterable, count, weights, unique)

Parameters

  • The iterable to get random elements from.

  • E.g. a list.

  • Optional parameter (default is 1)

  • How many random choices/elements to generate.

  • An integer.

  • Optional weights for the generation.

  • A list.

  • A boolean (True/False).

  • Should the generated choices/elements be unique?

PreviousRequire_keys()NextPattern Matching

Last updated 4 years ago