Python- Variables and Datatypes
Variables are container which hold values. Container may be string,number or boolean.
Example x=12("=" operator where x is the variable name with value 10 )
Data Types
Data types define the type of values a variable can hold. Here are some common data types with simple examples:
Integers (int
): Whole numbers without decimals.
Floats (
float
): Numbers with decimals.Strings (
str
): Text or characters enclosed in single or double quotes.Booleans (
bool
): Represents either True or False.Lists (
list
): Ordered collection of items.Tuples (
tuple
): Similar to lists but immutable (cannot be changed).Dictionaries (
dict
): Collection of key-value pairs.Sets (
set
): Unordered collection of unique items.NoneType (
None
): Represents the absence of a value or a null value.Typecasting :
Typecasting in Python involves converting one data type to another.