how many integers types are supported by Python? Name them.
Answers
bool: Boolean (true/false) types. Supported precisions: 8 (default) bits.
int: Signed integer types. Supported precisions: 8, 16, 32 (default) and 64 bits.
uint: Unsigned integer types. Supported precisions: 8, 16, 32 (default) and 64 bits.
float: Floating point types. Supported precisions: 16, 32, 64 (default) bits and extended precision floating point (see note on floating point types).
complex: Complex number types. Supported precisions: 64 (32+32), 128 (64+64, default) bits and extended precision complex (seenote on floating point types).
string: Raw string types. Supported precisions: 8-bit positive multiples.
time: Data/time types. Supported precisions: 32 and 64 (default) bits.
enum: Enumerated types. Precision depends on base type.
There are five standard data types supported by Python.
1. Numbers: Number data type store numeric values.
Example: var = 10
There are four different numerical types in Python.
• int (signed integers) : Example- int_var = 100.
• long (long integers, can be represented in octal and hexadecimal also): Example- long_var = 53694565L.
• float (floating point values): Example- float_var = 85.34.
• complex (complex numbers): Example- complex_var = 5.23j.
2. Strings: Strings are contiguous set of characters in a quotation mark.
Example: string_var = “Good Morning”
3. Lists: The items in a list are separated by a comma within square brackets.
Example: list_var = [‘hello’, 456.8, 56]
4. Tuples: This is similar to lists unlike the items are enclosed within parentheses and items are separated by commas.
Example: tuple_var = (‘pqr’, ‘abc’, 963, 865.23)
5. Dictionary: This is like the hash tables. Items are enclosed in curly braces and values can be assigned and accessed using square brackets.
Example:
dict_var1 = {‘id’ = ‘345’, ‘name’ = ‘abc’}
dict_var2[‘one’] = ”Print one”