What keyword is used to create a new class in Python?

Prepare for the WGU ITSW2120 D276 Exam. Study using flashcards and multiple-choice questions, with hints and explanations provided for each question. Get ready to excel in your exam!

In Python, the keyword that is used to define a new class is "class." When you want to create a class, you start the definition with this keyword followed by the name of the class. This structure allows you to encapsulate data and behaviors associated with that data in a single unit, supporting the principles of object-oriented programming. For example, you can create a class called Car using the syntax class Car: which establishes that Car is a new class.

The other options are not used for this purpose: "new" is not a keyword in Python for creating classes, "def" is used for defining functions, and "create" has no specific function in Python syntax regarding class definitions. Thus, "class" is the only correct choice for defining a new class.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy