Python for Kids: A fun and engaging introduction to programming concepts using Python by Praba Rajah
Author:Praba Rajah [Rajah, Praba]
Language: eng
Format: epub
Published: 2024-05-03T00:00:00+00:00
Here, we created a dictionary called character_info that stores information about a character. Each key ("name", "age", "special_ability") acts as a label for its corresponding value ("Alice", 10, "flying").
Accessing and Modifying Values:
We access values in a dictionary using their keys within square brackets. We can also modify existing values or add new key-value pairs:
Python
character_info[ "age" ] = 11 # Update age
character_info[ "hair_color" ] = "brown" # Add a new key-value pair
Common Dictionary Operations:
Dictionaries offer various methods to manage their contents:
Checking for keys: Use the in operator to check if a specific key exists in the dictionary.
Removing key-value pairs: Use the pop() method to remove a key-value pair and return its value.
Looping through dictionaries: Use a for loop to iterate over the keys or key-value pairs in the dictionary.
Python
if "hair_color" in character_info:
print( "Hair color:" , character_info[ "hair_color" ])
favorite_color = character_info.pop( "hair_color" ) # Remove hair_color and store its value
for key in character_info:
print(key, ":" , character_info[key])
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Deep Learning with Python by François Chollet(12555)
Hello! Python by Anthony Briggs(9904)
OCA Java SE 8 Programmer I Certification Guide by Mala Gupta(9785)
The Mikado Method by Ola Ellnestam Daniel Brolund(9769)
Dependency Injection in .NET by Mark Seemann(9329)
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(8282)
Test-Driven iOS Development with Swift 4 by Dominik Hauser(7756)
Grails in Action by Glen Smith Peter Ledbrook(7686)
The Well-Grounded Java Developer by Benjamin J. Evans Martijn Verburg(7550)
Becoming a Dynamics 365 Finance and Supply Chain Solution Architect by Brent Dawson(7007)
Microservices with Go by Alexander Shuiskov(6774)
Practical Design Patterns for Java Developers by Miroslav Wengner(6684)
Test Automation Engineering Handbook by Manikandan Sambamurthy(6629)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(6399)
Angular Projects - Third Edition by Aristeidis Bampakos(6035)
The Art of Crafting User Stories by The Art of Crafting User Stories(5566)
NetSuite for Consultants - Second Edition by Peter Ries(5497)
Demystifying Cryptography with OpenSSL 3.0 by Alexei Khlebnikov(5302)
Kotlin in Action by Dmitry Jemerov(5048)
