Skip to content

Files

Latest commit

801f3bf · Oct 4, 2024

History

History

1-Data-types

Python 3.12 Typings

Variable Typings

Type Syntax
String str
Number int
Float float
Boolean bool
name : str = "Sarmad"
print(type (name)) # class
print(id(name)) # address
print(dir(name)) # Gives the available operations

Another Example

name: str = "Sarmad"
age: int = 19
married: bool = False
print(name)

List Typing

vowels: list[str] = ['a', 'e', 'i', 'o', 'u']
odds: list[int] = [1, 3, 5, 7, 9]

print(vowels)

Tuple Typing

props: tuple[(str, str, int, bool)] = ("Sarmad", "[email protected]", 19, True)

print(props)

Set Typing

details: set[str] = {"Sarmad", "[email protected]"}

print(details)