Type Annotation In Pythonby@h3avren
7,828 reads
7,828 reads

Type Annotation In Python

by Ajay Singh Rana3mFebruary 1st, 2022
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

Type annotations are used to indicate the types of variables and inputs/outputs of functions and methods in Python. Type annotations have a straight-forward syntax i.e. `variable_name : data_type` These are associated with variables or function/method arguments to make the code more readable for ourselves and the user**. These expressions do not have any meaning attached with them and these are **ignored by the interpreter**** These are never gonna raise an error if the given variable or argument doesn't have the correct type cause these are just ***hinters*** def sum(num_1 : int,num_2 : int = 2) -> int: return num_1 + num_2

Companies Mentioned

Mention Thumbnail
Mention Thumbnail
featured image - Type Annotation In Python
Ajay Singh Rana HackerNoon profile picture
Ajay Singh Rana

Ajay Singh Rana

@h3avren

Dreaming with Python... Under a sky in India...

About @h3avren
LEARN MORE ABOUT @H3AVREN'S
EXPERTISE AND PLACE ON THE INTERNET.
L O A D I N G
. . . comments & more!

About Author

Ajay Singh Rana HackerNoon profile picture
Ajay Singh Rana@h3avren
Dreaming with Python... Under a sky in India...

TOPICS

THIS ARTICLE WAS FEATURED IN...

Permanent on Arweave
Read on Terminal Reader
Read this story in a terminal
 Terminal
Read this story w/o Javascript
Read this story w/o Javascript
 Lite