Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
学ぶ Comparing Classes and Dictionaries | Section
Object-Oriented Programming in Python

bookComparing Classes and Dictionaries

メニューを表示するにはスワイプしてください

A dictionary groups data with key-value pairs, focusing only on storing information in a simple structure. A class, on the other hand, is a blueprint for creating objects, bundling both data (attributes) and behaviors (methods) to define them together. For example, a dictionary might hold a pet's name, breed, and age, but it's still just a collection of key-value pairs without any inherent behavior.

The core problem of a dictionary is that it only stores data without providing any behavior.

example.py

example.py

copy

The class bundles both the data and the speak method, demonstrating how classes provide structure for organizing attributes and behavior together.

question mark

Which statement best explains the difference between a dictionary and a class?

正しい答えを選んでください

すべて明確でしたか?

どのように改善できますか?

フィードバックありがとうございます!

セクション 1.  2

AIに質問する

expand

AIに質問する

ChatGPT

何でも質問するか、提案された質問の1つを試してチャットを始めてください

セクション 1.  2
some-alt