{ "cells": [ { "cell_type": "markdown", "id": "a878efa6-db67-4e06-9963-8e7929bbd668", "metadata": {}, "source": [ " Advance Python " ] }, { "cell_type": "code", "execution_count": 1, "id": "e8071822-558f-4b36-a9ce-76fd8000c949", "metadata": {}, "outputs": [], "source": [ "# OOP's : object oriented programming\n", "\n", "# code reusability \n", "# structured - Home , center , college .\n", "# pillars \n", "\n", "\n" ] }, { "cell_type": "code", "execution_count": null, "id": "335f1cf2-f9a8-48d9-8767-04861ba846e7", "metadata": {}, "outputs": [], "source": [ "\"PYTHON\".\n", "\n", "#WAP to create a method which changes lower to upper case . \n" ] }, { "cell_type": "markdown", "id": "3e509c26-ea2e-4fcd-a04e-37cbeaf4401f", "metadata": {}, "source": [ "# Pillars :\n", "To store data\n", "1. Class and Object\n", "2. Encapsulation\n", "\n", "To secure the code \n", "3. Constructor\n", "4. Abstraction \n", "\n", "Reusability\n", "5. Polymorphism\n", "6. Inheritance\n" ] }, { "cell_type": "code", "execution_count": 2, "id": "566a0cc1-3769-4afa-8d79-70a4cb36df64", "metadata": {}, "outputs": [], "source": [ "# class : \n", "\n", "\n", "# Parents : name , physical appearance , property , habits , hobby - class\n", "# Children - girl , boys - Objects \n", "\n", "# Student details - id , name , add , contact , clg , marks - class\n", "# Objects : \n", "\n", "# Syntax \n", "\n", "class className : \n", " pass # key word\n", "\n", "# Object \n", "\n", "objName = className() # Constructor\n", "\n" ] }, { "cell_type": "code", "execution_count": 19, "id": "6886766b-427e-471a-912c-fb4314e54fdc", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Hello my parents are :Indu , Ramesh , Uttar Pradesh\n", "None\n", "Hello my parents are :A , B , Uttar Pradesh\n", "None\n" ] } ], "source": [ "class Parent :\n", " village = 'Uttar Pradesh'\n", "\n", " \n", " def __init__(self,mName, dName):\n", " self.mName = mName\n", " self.dName = dName\n", "\n", " def details(self):\n", " print(f\"Hello my parents are :{self.mName} , {self.dName} , {Parent.village}\")\n", "\n", "\n", "# Object \n", "\n", "princy = Parent('Indu' , 'Ramesh') # constructor\n", "print(princy.details())\n", " \n", "Udbhav = Parent('A','B')\n", "print(Udbhav.details())\n", "\n", " " ] }, { "cell_type": "code", "execution_count": 17, "id": "2de19f4c-b040-4c53-be29-4dacdce8c2a7", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "This is a: Daisy, Rose\n" ] } ], "source": [ "class Flower:\n", " def __init__(self, acolour, bcolour):\n", " self.acolour = acolour \n", " self.bcolour = bcolour \n", "\n", " def details(self): # Corrected method name\n", " print(f\"This is a: {self.acolour}, {self.bcolour}\") # Use self to access instance variables\n", "\n", "# Create an instance of Flower with actual color names\n", "ColourOfFlower = Flower('Daisy', 'Rose')\n", "ColourOfFlower.details() # Call the details method to print the information \n", "\n", "\n", "\n", "\n", " " ] }, { "cell_type": "code", "execution_count": null, "id": "0434afbb-ef64-44d7-87e9-d9d8ab24648e", "metadata": {}, "outputs": [], "source": [ "# For Registartion ,sign up and sign in\n", "\n", "\n" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.12.7" } }, "nbformat": 4, "nbformat_minor": 5 }