Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def true_div( | |
number: float, | |
divisor: float, | |
) -> float: | |
return number / divisor | |
def squares(*numbers: int) -> list[int]: | |
print("type of numbers:", type(numbers)) | |
return [n * n for n in numbers] |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from collections import namedtuple | |
from dataclasses import dataclass | |
# from typing import NamedTuple | |
# Point = namedtuple("Point", "x, y") | |
AgeAndWeight = namedtuple( | |
"AgeAndWeight", | |
"age, weight", | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import Final, Sequence | |
ADMIN_IDS: Final[Sequence[int]] = [1, 5] | |
# ADMIN_IDS: Final[Sequence[int]] = (1, 5) | |
# ADMIN_IDS: Final[tuple[int, ...]] = (1, 5, 8) | |
def main() -> None: | |
print(ADMIN_IDS) | |
ADMIN_IDS.append(7) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sqlalchemy import create_engine, Column, Integer, String, ForeignKey, select | |
from sqlalchemy.orm import sessionmaker, relationship, DeclarativeBase, selectinload | |
# DB_URL = "sqlite:///tags.db" | |
DB_URL = "sqlite:///:memory:" | |
DB_ECHO = False | |
class Base(DeclarativeBase): | |
id = Column(Integer, primary_key=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_num() -> int: | |
return 42 | |
def get_word() -> str: | |
return "spam" | |
def main() -> None: | |
num = get_num() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.*; | |
public class Main { | |
public static void main(String[] args) { | |
int[] numbers = {1, 2, 3, 2, 4, 5, 3, 6, 7, 4}; | |
HashMap<Integer, HashSet<Integer>> dictionary = new HashMap<>(); | |
for (int i = 0; i < numbers.length; i++) { | |
int number = numbers[i]; | |
if (!dictionary.containsKey(number)) { |
NewerOlder