Search the courses, subjects, tracks, games and features, or jump straight to a page.
3 cards from this section. Quick, good the night before a test.
What decorator is used to define a data class?
Think about how you mark a special function in Python.
What are named tuples primarily used for?
Remember the unique feature of named tuples.
What does the @dataclass decorator do in Python?
Think about functionality that eliminates manual coding.
True or False: Named tuples can be modified after creation.
Remember the definition of immutability and think of tuples.
Create a data class representing a book, with attributes for title, author, and publication year. Include a method that returns a string formatted as 'Title by Author (Year)'.
Think about how you can keep the formatting consistent and where to place your print method.
Design a use case for named tuples that could be used in a database context, such as storing user information. Provide the named tuple definition and an example of instantiation.
Focus on the fields that would be essential in a user profile.
6 more questions in this section. Enroll free to practise them all.
Enroll free