Question: Create a new Python script named introduction.py . Within this script, define a class named Person. The class should have the following attributes: name (

Create a new Python script named introduction.py.
Within this script, define a class named Person. The class should have the following attributes:
name (string)
age (integer)
country (string)
These attributes should be set during the initialization of a Person object.
Add a method to the Person class named introduce_yourself.
This method should print a string in the format: "Hello, my name is [name]. I'm [age] years old and I'm from [country]."
Ensure the name, age, and country values in the string come from the object's attributes.
Now, create two Person objects with different attributes (i.e., different names, ages, and countries).
For example, you might create one Person object representing a 30-year-old named John from Canada, and another Person object representing a 25-year-old named Maria from Spain.
You could also create a Person object of yourself or a classmate.
Call the introduce_yourself method on both Person objects, and observe the output.
Ensure that the printed output matches the attributes of each Person object.
Save your Python script and run it to verify that it works as expected.
The console should print the introduction messages for both Person objects.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!