number_input widget in Streamlit

The number_input method is a numeric input widget in Streamlit that allows users to enter or select numeric values (integer or float) directly from the app interface.

It is useful for scenarios such as:

Syntax

st.number_input(
    label,
    min_value=None,
    max_value=None,
    value=default_value,
    step=1,
    format=None,
    key=None,
    help=None
)    

Example: Basic Example

Python

# Importing the Streamlit library
import streamlit as st

# Title
st.title("Number Input Example")

# Simple number input
number = st.number_input(
    "Enter a number",
    min_value=0,
    max_value=100,
    value=10,
    step=5
)

# Display result
st.write("You entered:", number)    

Output

Number input in Streamlit