-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPerson_Class_IIlustration
1 lines (1 loc) · 1.23 KB
/
Person_Class_IIlustration
1
{"nbformat":4,"nbformat_minor":0,"metadata":{"colab":{"provenance":[],"authorship_tag":"ABX9TyMKWHFfkx8xeCdtQ3DO7Wks"},"kernelspec":{"name":"python3","display_name":"Python 3"},"language_info":{"name":"python"}},"cells":[{"cell_type":"code","execution_count":1,"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"cfX4aSDwB5OI","executionInfo":{"status":"ok","timestamp":1728221733275,"user_tz":-60,"elapsed":2621,"user":{"displayName":"Abdallah Musa","userId":"08270029295017670213"}},"outputId":"d4c62edc-d679-4460-b41d-a1df3c01f263"},"outputs":[{"output_type":"stream","name":"stdout","text":["Hello, my name is Alice, I am 25 years old, and I identify as female.\n"]}],"source":["\n","# Let's create the class Person with the specified attributes and the introduce method.\n","\n","class Person:\n"," def __init__(self, name, age, gender):\n"," self.name = name\n"," self.age = age\n"," self.gender = gender\n","\n"," def introduce(self):\n"," print(f\"Hello, my name is {self.name}, I am {self.age} years old, and I identify as {self.gender}.\")\n","\n","# Creating an instance of the Person class and calling the introduce method\n","person = Person(\"Alice\", 25, \"female\")\n","person.introduce()"]}]}