def add(x: int, y: int) -> int:
return x + y
annotation Variables:-
we can annotate a variable using ":" colon sign proceeding with the data type
variable_name : data_type = value
===============================
from typing import Optional
def get_name(prefix: Optional[str]) -> str:
if prefix:
return prefix + "John"
return "John"
======================================
No comments:
Post a Comment