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
# Functional programming is about immutable objects: | |
name = "John Doe" # string | |
age = 29 # int | |
weight = 98.7 # float | |
# and stateless functions: | |
def say_hello(to: str) -> None: |
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 Tuple | |
class Person: | |
# class attribute | |
species = "Homo Sapiens" | |
# Instance attribute | |
def __init__(self, name: str, age: int) -> None: | |
self.name = name | |
self.age = age |
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 math # We'll use the math module later in this snippet | |
class Vector: | |
"""A 2D vector class with some useful methods""" | |
def __init__(self, x: float, y: float) -> None: | |
self.x = x | |
self.y = y |