Python Pioneers: A Beginner's Guide πŸ‡ͺπŸ‡Ή
8.65K subscribers
346 photos
40 videos
24 files
64 links
Welcome to Python Pioneers: Empowering Ethiopian students to embark on their coding journey.

πŸ“’ Channel: @python_pioneers
πŸ‘₯ Group: @python_pioneers_chat
Download Telegram
Dictionary in Python

α‰ Python programming language dictionary α‹¨αˆšα‰£αˆˆα‹ α‰ key-value αŒ₯αŠ•α‹΅ αˆ†αŠα‹ α‹¨αˆšα‰€αˆ˜αŒ‘ elements ሡα‰₯ሡα‰₯ αŠα‹α’ Key α‹¨αˆαŠ•αŒ α‰€αˆ˜α‹ α‹¨α‹«α‹˜α‹αŠ• corresponding value acess αˆ›α‹΅αˆ¨αŒ αˆ΅αŠ•αˆαˆαŒ αŠα‹α’

Dictionaries αŠ¨α‹šαˆ… α‰ αŠα‰΅ ሡለlists αˆ΅αŠ•αˆ›αˆ­ αŠ₯αŠ•α‹³α‹¨αŠα‹ mutable αŠ“α‰Έα‹α£ α‹­αˆ…αˆ αˆ›αˆˆα‰΅ listኑ αŠ¨α‰°αˆαŒ αˆ¨ α‰ αŠ‹αˆ‹ elementαŠ¦α‰ΉαŠ• modify αˆ›αˆ¨αŒ αŠ₯αŠ•α‰½αˆ‹αˆˆαŠ•α’

α‰ python dictionary ለመፍጠር curly braces '{}' αŠα‹ α‹¨αˆαŠ•αŒ α‰€αˆ˜α‹ αŠ¨α‹›αˆ key-value pair α‰  colon ':' αŠ₯αŠ•αˆˆα‹«αˆˆαŠ•α’

ለምሳሌፑ

my_dict = {'key1': 'value1', 'key2': 'value2'}

You can access values in a dictionary by referencing the key in square brackets ([]).

ለምሳሌ :

print(my_dict['key1']) # Output: value1

αˆŒαˆ‹α‹ α‹°αŒαˆž α‹¨α‰±αˆˆα‹«α‹© methods αŠ₯αŠ“ functions α‰ αˆ˜αŒ α‰€αˆ የdictionary αŠ α‹²αˆ΅ elements መጨመር ፣ α‹«αˆ‰α‰΅αŠ• modify αˆ›αˆ¨αŒα£ delete αˆ›αˆ¨αŒ αŠ₯αŠ•α‰½αˆ‹αˆˆαŠ•

Dictionaries are commonly used in Python for storing data that needs to be looked up quickly using a unique key.

Dictionaries α‰ Python α‹αˆ΅αŒ₯ key α‰ αˆ˜αŒ α‰€αˆ በፍαŒ₯αŠα‰΅ መፈለግ α‹«αˆˆα‰£α‰Έα‹αŠ• αˆ˜αˆ¨αŒƒα‹Žα‰½ αˆˆαˆ›αŠ¨αˆ›α‰Έα‰΅ α‰ α‰₯ዛቡ αŒ₯α‰…αˆ αˆ‹α‹­ α‹­α‹αˆ‹αˆ‰α’


#Dictionary
#DataTypes

@python_pioneers
⚑2πŸ‘1πŸ”₯1
Python Pioneers: A Beginner's Guide πŸ‡ͺπŸ‡Ή
Dictionary in Python α‰ Python programming language dictionary α‹¨αˆšα‰£αˆˆα‹ α‰ key-value αŒ₯αŠ•α‹΅ αˆ†αŠα‹ α‹¨αˆšα‰€αˆ˜αŒ‘ elements ሡα‰₯ሡα‰₯ αŠα‹α’ Key α‹¨αˆαŠ•αŒ α‰€αˆ˜α‹ α‹¨α‹«α‹˜α‹αŠ• corresponding value acess αˆ›α‹΅αˆ¨αŒ αˆ΅αŠ•αˆαˆαŒ αŠα‹α’ Dictionaries αŠ¨α‹šαˆ… α‰ αŠα‰΅ ሡለlists αˆ΅αŠ•αˆ›αˆ­ αŠ₯αŠ•α‹³α‹¨αŠα‹ mutable αŠ“α‰Έα‹α£ α‹­αˆ…αˆ αˆ›αˆˆα‰΅ listኑ αŠ¨α‰°αˆαŒ αˆ¨ α‰ αŠ‹αˆ‹ elementαŠ¦α‰ΉαŠ•β€¦
Example of Creating and Using a Dictionary:

# Creating a dictionary
student_info = {
"name": "John Doe",
"age": 17,
"grade": "11th",
"subjects": ["Math", "Science", "English"]
}

# Accessing dictionary values by key
print(student_info["name"]) # Output: John Doe

# Adding a new key-value pair
student_info["hobby"] = "Reading"
print(student_info) # Adds 'hobby': 'Reading' to the dictionary

# Modifying an existing key's value
student_info["grade"] = "12th"
print(student_info["grade"]) # Output: 12th

# Removing a key-value pair using 'pop'
student_info.pop("age")
print(student_info) # Removes 'age' from the dictionary

# Looping through keys and values
for key, value in student_info.items():
print(key, value)

# Checking if a key exists in the dictionary
if "name" in student_info:
print("Key 'name' exists!")

#Dictionary
#DataTypes

@python_pioneers
πŸ‘2
Python Data Types at a Glance

Hey Python Pioneers! πŸ‘¨β€πŸ’»πŸ‘©β€πŸ’»
Here are basic data types in Python you should know:

int – integers (e.g. 5, -10)

float – decimal numbers (e.g. 3.14, -0.001)

str – text or strings (e.g. "Hello World")

bool – True or False

list – ordered, changeable collection (e.g. [1, 2, 3])

dict – key-value pairs (e.g. {"name":"Abebe"})

tuple – ordered, unchangeable collection (e.g. (1, 2, 3))

set – unordered unique items (e.g. {1, 2, 3})

#DataTypes

@python_pioneers
❀2