livepython.net

180. Python Program to Create a Class and an Object

EasyClasses

Overview

Your first class: define it, build an object from it, and give the object attributes with a dot.

Problem Statement

Define a class called Pet. Read a pet's name and its kind of animal. Create one Pet object, and store the two values in it as the attributes name and kind. Then print a sentence made from the attributes, and the object's class with type(). For example, for Rocky and dog, the program prints Rocky is a dog, then <class '__main__.Pet'>.

Use input() with no prompt text: the tests type the input for you, and a prompt would end up in your output.

Input

Two lines: the name, then the kind. Example:

Rocky
dog

Output

The output for that example:

Rocky is a dog
<class '__main__.Pet'>

The tests try 3 different inputs.

Learn this firstChapter 20 · Python Classes and Objects for Beginners
solution.py
# write your code here

EXPECTED OUTPUT

1Rocky is a dog
2<class '__main__.Pet'>

YOUR OUTPUT

Press Run to see your output here. Lines are compared with the expected output.