Skip to content

Latest commit

 

History

History
87 lines (71 loc) · 1.24 KB

Readme.md

File metadata and controls

87 lines (71 loc) · 1.24 KB

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", "sarmad@gmail.com", 19, True)

print(props)

Set Typing

details: set[str] = {"Sarmad", "sarmad@gmail.com"}

print(details)