Course Content
Introduction to Programming and Python
Overview of Python History and evolution Python’s features and benefits Set-Up Development Environment Installing Python and IDE (e.g., PyCharm, VS Code) Writing and running your first Python program Hands-On Activity Write a simple Python program to display “Hello, World!”
0/3
Structure Of A Python Program
A comprehensive overview of the structure of a Python program, covering essential concepts efficiently.
0/1
Basic Syntax and Control Statements
Basic Syntax Structure of a Python program Data types, variables, and operators
0/3
Object-Oriented Programming (OOP)
0/3
Python Programming For Beginners
About Lesson

Key-Value Pairs, Accessing, and Modifying

  • Definition: A dictionary is an unordered collection of key-value pairs. Keys must be unique and immutable, while values can be of any data type.
  • Creating Dictionaries: python
    my_dict = {'name': 'Alice', 'age': 25, 'city': 'New York'}
  • Accessing Values: Use the key to access the corresponding value. python
    print(my_dict['name']) # Output: Alice
  • Modifying Values: Assign a new value to a specific key. python
    my_dict['age'] = 26 print(my_dict) # Output: {'name': 'Alice', 'age': 26, 'city': 'New York'}
  • Adding Key-Value Pairs: Simply assign a value to a new key. python
    my_dict['email'] = 'alice@example.com' print(my_dict) # Output: {'name': 'Alice', 'age': 26, 'city': 'New York', 'email': 'alice@example.com'}
  • Removing Key-Value Pairs: Use del to remove a key-value pair. python
    del my_dict['city'] print(my_dict) # Output: {'name': 'Alice', 'age': 26, 'email': 'alice@example.com'}

PAGE TOP