Answers for "python auto type"

0

python auto type

# Unlike in C/C++ or any statically-typed language,
# the typing in python is dynamic, which means that
# Python will figure out himself wich type should be
# use for your value.
# In Python, you can also change the type of a
# variable during ewxecution, but I strongly advise
# against  doing that.

"""define a type in C++"""
# int x;
"""auto type in C++"""
# auto x = 5;  // C++ will automatically define AnIntegerWithAutoType as int

"""static type in Python"""
x: int
"""auto type in Python"""
x = 5

# You can also define a python variable without giving it a value.

from typing import Any
x: Any # This means that x will not have a value but can get a value from any type later
Posted by: Guest on August-26-2021

Python Answers by Framework

Browse Popular Code Answers by Language