Results for “dictionaries”

5 results

  1. Article Mini projects

    Calculate your weight on different planets in Python

    …coding our space weight calculator: First, we'll create a dictionary of planets and their surface gravities: planets = { "Mercury": 3.7, "Venus": 8.87, "Earth": 9.81, "Mars": 3.711, "Jupiter": 24.79…

  2. Article Python Fundamentals

    Python Books for Beginners

    …first half covers Python fundamentals (variables, lists, dictionaries, functions, classes), while the second half walks you through three complete projects - a Space Invaders-style game, data…

  3. Article Python Fundamentals

    Variables and data types in Python

    …print(common_targets) Dictionaries Key-value pairs, perfect for storing related data: planet_data = { "name": "Mars", "diameter": 6779, # kilometers "has_moons": True, "moons": ["Phobos", "Deimos"] }…

  4. Article Mini projects

    Base 6 Number System in Python

    …we create the reverse mapping ( ERIDIAN_TO_DIGIT ) using a dictionary comprehension instead of typing it out manually. Less typing, fewer bugs. Putting It All Together: A Mini Converter Tool Here's a…

  5. Article Mini projects

    Calculating Escape Velocity in Python

    …here with vectorized operations: import numpy as np # Dictionary with planet data planets = { "Mercury": {"mass": 3.301e23, "radius": 2.4397e6}, "Venus": {"mass": 4.867e24, "radius": 6.0518e6}…