Back
I am wondering when you use the var: int and when to you use the int(var).
For example:
def func(var: int, var2): print(var - int(var2))
def func(var: int, var2):
print(var - int(var2))
The var: int used to know the type of the variable that is expected to be and pass it to a desired function or class, while int(var) will cast var variable to be an instance of int class:
>> a = '3' # a is String>> a = int(a)>> aout: 3 # a is Integer now
>> a = '3' # a is String
>> a = int(a)
>> a
out: 3 # a is Integer now
Do check out python for data science certification to learn from scratch.
31k questions
32.8k answers
501 comments
693 users