fully define ia variable one needs to mention not
only with type but also it'other propertie! In other
words, not only do all variables have data type
they also contain other properties. Explain the
concept that will help us to describe propenties of any
variable
Answers
Explanation:
2.1. Values and data types¶
A value is one of the fundamental things — like a letter or a number — that a program manipulates. The values we have seen so far are 2 (the result when we added 1 + 1), and "Hello, World!".
These values belong to different data types: 2 is an integer, and "Hello, World!" is a string, so-called because it contains a string of letters. You (and the interpreter) can identify strings because they are enclosed in quotation marks.
The print statement also works for integers.
>>> print 4
4
If you are not sure what type a value has, the interpreter can tell you.
>>> type("Hello, World!")
<type 'str'>
>>> type(17)
<type 'int'>
Not surprisingly, strings belong to the type str and integers belong to the type int. Less obviously, numbers with a decimal point belong to a type called float, because these numbers are represented in a format called floating-point.
>>> type(3.2)
<type 'float'>
What about values like "17" and "3.2"? They look like numbers, but they are in quotation marks like strings.
>>> type("17")
Explanation:
Variable:
In computer programming language, a variable is one of the key and basic elements. Variables are used to define values and can be of fixed value or can change values as per program. Their data type is the key parameter that defines what values they can store.
Data type;
This represents the type of data, whether is a string, integer, floating point etc. This is important because without selecting right data type, we might not get desired output.