PYTHON LESSON
Class defines structure; object is concrete instance.
Model real entities first.
Mixing class and instance fields.
You will study Classes and Objects. It belongs to the Object-Oriented Programming phase.
Remember this:
Class defines structure; object is concrete instance.
Practice step by step. Do not rush. Each run should show you something new.
Tip:
Model real entities first.
Avoid this:
Mixing class and instance fields.
Your challenge:
Create Book class with title and author.
Go to the challenge lab below. Fix errors until the output looks right. Then press the green button to complete the topic.
Copy this example if it helps. Change it so it matches Classes and Objects.
# Topic: Classes and Objects
def main():
sample = "edit me"
# TODO: apply Classes and Objects concept here
result = sample
print("Result:", result)
if __name__ == "__main__":
main()
Create Book class with title and author.
Before you can finish: your output should include at least 16 characters; at least 1 non-empty line(s); no crash traceback—fix errors until the program runs cleanly.
Use Run. Read the output. Change your code until the task is done.
# Challenge starter for Classes and Objects
def solve():
# Write your solution here
pass
print("Update solve() and run")
The first Run may load Python in your browser (one-time). Later runs are faster.