Python has three types of numbers:
x = 1 # int
y = 2.8 # float
z = 1j # complex
A Python dictionary is a collection of key-value pairs, where each key is unique and maps to a value. It allows for fast retrieval, insertion, and deletion of data based on keys, making it a versatile and efficient data structure for various programming tasks.
person = {"name": "Bob", "age": 30}
A Python list is an ordered collection of items, which can be of any data type. Lists are mutable, allowing for the addition, removal, and modification of elements. They provide a flexible way to store and manage sequences of data.
fruits = ["apple", "banana", "cherry"]
A Python set is an unordered collection of unique elements. Sets are mutable and do not allow duplicate values, making them useful for storing distinct items and performing operations like union, intersection, and difference. They provide efficient membership testing and are commonly used for tasks involving distinct data elements.
unique_numbers = {1, 2, 3}
A Python string is an immutable sequence of characters used to represent text. Strings support a wide range of operations, such as concatenation, slicing, and various methods for manipulating and querying text data. Strings are enclosed in either single, double, or triple quotes.
double_quotes = "Hello World"
single_quotes = 'Hello World'
triple_quotes = """Hello World"""
A Python tuple is an immutable ordered collection of elements, which can be of any data type.Tuples are useful for storing fixed collections of items and can be indexed and sliced similarly to lists. Tuples are defined by enclosing elements in parentheses.
coordinates = (10.0, 20.0)