137k views
4 votes
Unlike other programming languages, Python has no command for declaring a _____.

User Muirik
by
8.1k points

1 Answer

2 votes

Answer:

data type

Step-by-step explanation:

In Python and most other interpreted programming languages, a variable is automatically assigned a data type based on what it is set to.

For example, the variable declaration:


\tt x = 3

automatically sets the variable
\tt x to an integer value of 3.

Or, this declaration:


\tt xExists = True

automatically sets the variable
\tt xExists to a boolean value of True.

And this declaration after the first two:


\mathtt{ x = } \ \textsf{

automatically changes the variable
\tt x to a string with the text "Happy days".

__________

This is different from most compiled languages, where it is often needed to specify a primitive data type, such as int, boolean, or double.

For example, here is a variable declaration in Java:


\tt char \ c = \ 'a'

that explicitly sets the variable
\tt c to a char data type of value 97 (the ASCII value of 'a').

User Tausif Khan
by
7.9k points

No related questions found