"Python is a versatile and powerful programming language known for its readability and ease of use. It's widely adopted in various fields, including data science, web development, machine learning, and automation. Python's extensive library ecosystem and strong community support make it a popular choice for developers of all levels."- Gemini 2024
=
+, -, *, /, //, %, **
==, !=, <, >, <=, >=
and, or, not
In Python, everything is an object, including data types and functions. This object-oriented nature allows for flexible and dynamic programming, as objects can have attributes (data) and methods (functions). Common data types in Python include numbers (integers, floats, complex), strings, lists, tuples, dictionaries, and sets, each with its own characteristics and operations
# Variable declarations # Numbers x = 7 y = 3.14 # Strings name = "Toni" title = "Learning to code" # Boolean complete = False # Lists numbers = [1, 2, 3, 4, 5] letters = ['a', 'b', 'c'] # Tuple colors = ('red', 'green', 'blue') # Set items = {'hat', 'shirt', 'socks'} # Dictionary data = { 'planets': 8, 'suns': 1, 'largest_planet': 'Jupiter' } # Output & operators print(x + y) print(x > y) # Formatting output print(f'This is {title} with {name}')
# Nested Dictionary planetary_facts = { "Mercury": { "diameter": 4879, "distance_from_sun": 57.9, "moons": 0 }, "Venus": { "diameter": 12104, "distance_from_sun": 108.2, "moons": 0 }, "Earth": { "diameter": 12742, "distance_from_sun": 149.6, "moons": 1 }, "Mars": { "diameter": 6779, "distance_from_sun": 227.9, "moons": 2 }, "Jupiter": { "diameter": 142984, "distance_from_sun": 778.5, "moons": 79 }, "Saturn": { "diameter": 120536, "distance_from_sun": 1426.7, "moons": 82 }, "Uranus": { "diameter": 50724, "distance_from_sun": 2870.9, "moons": 27 }, "Neptune": { "diameter": 49244, "distance_from_sun": 4495.1, "moons": 14 } }