text stringlengths 0 93.6k |
|---|
# the result back into number. This is effectively a short form version of the |
# above which allows us to write more concise code. |
number += 2 |
# Output the number to verify we have added 2 to number and now number = 3 |
print(number) |
# Test substraction assignment operator (3 - 2 -> 1) |
number -= 2 |
print(number) |
# Test multiplication assignment operator (1 * 10 -> 10) |
number *= 10 |
print(number) |
# Test power assignment operator (10^3 -> 1000) |
number **= 3 |
print(number) |
# Test the division assignment operator (10 / 3 -> 3.33333...) |
number = 10 |
number /= 3 |
print(number) |
# Test the floor division assignment operator which rounds the result of a |
# division operation down to the nearest integer (10 // 3 -> 3) |
number = 10 |
number //= 3 |
print(number) |
# Test the modulus assignment operator which returns the remainder of a division |
# operation (10 % 3 -> 1) |
number = 10 |
number %= 3 |
print(number) |
# <FILESEP> |
import json |
from datetime import date |
from enum import Enum |
from typing import Literal |
import dash_mantine_components as dmc |
from dash import MATCH, Dash, Input, Output, State, _dash_renderer, callback, clientside_callback |
from dash_iconify import DashIconify |
from pydantic import BaseModel, Field, ValidationError |
from dash_pydantic_form import AccordionFormLayout, FormSection, ModelForm, fields, get_model_cls, ids |
from dash_pydantic_utils import SEP, Quantity |
_dash_renderer._set_react_version("18.2.0") |
app = Dash( |
__name__, |
external_stylesheets=[ |
"https://unpkg.com/@mantine/dates@7/styles.css", |
"https://unpkg.com/@mantine/code-highlight@7/styles.css", |
"https://unpkg.com/@mantine/charts@7/styles.css", |
"https://unpkg.com/@mantine/carousel@7/styles.css", |
"https://unpkg.com/@mantine/notifications@7/styles.css", |
"https://unpkg.com/@mantine/nprogress@7/styles.css", |
], |
) |
server = app.server |
fields.Select.register_data_getter( |
lambda: [ |
{"label": "French", "value": "fr"}, |
{"label": "English", "value": "en"}, |
{"label": "Spanish", "value": "sp"}, |
{"label": "Chinese", "value": "cn"}, |
], |
"languages", |
) |
class Species(Enum): |
"""Species enum.""" |
CAT = "cat" |
DOG = "dog" |
class Pet(BaseModel): |
"""Pet model.""" |
name: str = Field(title="Name", description="Name of the pet") |
species: Species = Field(title="Species", description="Species of the pet") |
dob: date | None = Field(title="Date of birth", description="Date of birth of the pet", default=None) |
alive: bool = Field(title="Alive", description="Is the pet alive", default=True) |
def __str__(self) -> str: |
"""String representation.""" |
return str(self.name) |
class Desk(BaseModel): |
"""Desk model.""" |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.