├── .gitignore ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── assets └── Logos & Favicon │ ├── CDC High Resolution Circle Logo Transparent Background.png │ ├── CDC High Resolution Circle Logo.jpg │ ├── CDC New High Resolution Logo Circle.png │ ├── CDC New High Resolution Logo Option 2.png │ ├── CDC New High Resolution Logo.png │ ├── github.png │ └── icons8-community-96.png ├── docs └── Project_Setup.md ├── index.html ├── package-lock.json ├── package.json ├── postcss.config.cjs ├── src ├── App.jsx ├── Components │ ├── Navbar.jsx │ └── Search.jsx ├── Constants │ └── index.js ├── Python │ ├── CodeEditor.jsx │ ├── PlayGround copy.jsx │ ├── PlayGround.jsx │ └── Scripts.jsx ├── Python_Library_Pages │ ├── AllApps.jsx │ ├── Flask │ │ └── Introduction-to-flask.jsx │ ├── Matplotlib │ │ └── Intro-to-Matplotlib.jsx │ ├── Numpy │ │ └── Intro-to-Numpy.jsx │ ├── PYQT │ │ └── Introduction-to-PYQT.jsx │ ├── Pandas │ │ └── Intro-to-Pandas.jsx │ ├── Python_Basics │ │ ├── Intrduction-to-Operators.jsx │ │ ├── Introduction-to-Functions.jsx │ │ └── Introduction-to-Python.jsx │ ├── Scikit-Learn │ │ └── Intro-to-ScikitLearn.jsx │ ├── Seaborn │ │ ├── Assets │ │ │ ├── Fig1.png │ │ │ ├── Fig2.png │ │ │ └── Fig3.png │ │ └── Introduction-to-Seaborn.jsx │ ├── TensorFlow │ │ └── Introduction-to-tensorFlow.jsx │ └── Tkinter │ │ └── Introduction-to-tkinter.jsx ├── index.css ├── layouts │ ├── RootLayout.jsx │ └── sidebar │ │ ├── SubMenu.jsx │ │ └── index.jsx └── main.jsx ├── tailwind.config.cjs ├── vite.config.js └── yarn.lock /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | 8 | 9 | # Compiled binary addons (http://nodejs.org/api/addons.html) 10 | build/Release 11 | 12 | # Dependency directories 13 | /node_modules/ 14 | jspm_packages/ 15 | 16 | # Distribution directories 17 | dist/ 18 | 19 | # Typescript v1 declaration files 20 | typings/ 21 | 22 | # Optional npm cache directory 23 | .npm 24 | 25 | # Optional eslint cache 26 | .eslintcache 27 | 28 | # Optional REPL history 29 | .node_repl_history 30 | 31 | # Output of 'npm pack' 32 | *.tgz 33 | 34 | # Yarn Integrity file 35 | .yarn-integrity -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing Guidelines 2 | 3 | Welcome to our open-source project! By contributing, you help us create better software for everyone. 4 | 5 | Before you start contributing, please take a moment to read the following guidelines to ensure a smooth and effective contribution process: 6 | 7 |

Technology Stack

8 |

9 | 10 | 11 | 12 |

13 | 14 | ## Table of Contents 15 | 16 | - [Contributing Guidelines](#contributing-guidelines) 17 | - [Table of Contents](#table-of-contents) 18 | - [Getting Started](#getting-started) 19 | - [Standard Design Protocol](#standard-design-protocol) 20 | - [How Can I Contribute?](#how-can-i-contribute) 21 | - [Team Onboarding](#team-onboarding) 22 | - [Reporting Bugs](#reporting-bugs) 23 | - [Suggesting Enhancements](#suggesting-enhancements) 24 | - [Working on Issues](#working-on-issues) 25 | - [Submitting Pull Requests](#submitting-pull-requests) 26 | 27 | ## Getting Started 28 | 29 | - Ensure you have an IDE installed on your local machine. 30 | - Fork the repository on GitHub. 31 | - Clone your forked repository locally: `git clone https://github.com/thecuriousteam/PyLibLog.git` 32 | - Change your directory to the project: `cd PyLibLog` 33 | 34 | 35 | ## Standard Design Protocol 36 | 1. Font & Color Code 37 | 1. Headings H1 - #8800ff 38 | 2. Heading H2 to H6 and body, Paragraph - #000000 39 | 3. Heading Font - https://fonts.google.com/specimen/Poppins 40 | 4. Body Font Body - https://fonts.google.com/specimen/Source+Serif+4 41 | 5. Font Size - https://medium.com/eightshapes-llc/typography-in-design-systems-6ed771432f1e 42 | 6. Standrad Website Design reference 43 | 1. https://dart-tutorial.com/ 44 | 2. https://www.w3schools.com/html/ 45 | 3. https://www.studytonight.com/html5-references/html-a-tag 46 | 47 | ![Size Structure ](https://miro.medium.com/v2/resize:fit:828/format:webp/1*2av-i7NsHMvkhkyElFHQxg.png) 48 | 49 | ## How Can I Contribute? 50 | 51 | ### Team Onboarding 52 | - Developers needs to onboard to opensource community for easy information flow along with admins, please join with this link [Curious Developers Community - Hacktoberfest ](https://chat.whatsapp.com/HNu3VaLPK3z3yt3JFUs7D7)
53 | 54 | ### Reporting Bugs 55 | 56 | If you find a bug, please ensure the bug was not already reported by searching on GitHub under [Issues](https://github.com/thecuriousteam/PyLibLog/issues). If you can't find an existing issue addressing the problem, please [open a new issue](https://github.com/thecuriousteam/PyLibLog/issues/new) and provide detailed information about the bug. 57 | 58 | ### Suggesting Enhancements 59 | 60 | If you have an idea for an enhancement, we welcome your input. Before creating a new enhancement issue, please check the existing issues to see if your enhancement idea has already been discussed. If it hasn't, [create a new issue](https://github.com/thecuriousteam/PyLibLog/issues/new) and outline your enhancement proposal. 61 | 62 | ### Working on Issues 63 | 64 | Feel free to pick any open issue from our [issue tracker](https://github.com/thecuriousteam/PyLibLog/issues) that you find interesting. Comment on the issue that you would like to work on so that others are aware you are addressing it. If you need more context on a particular issue, please ask for clarification. 65 | 66 | ### Submitting Pull Requests 67 | 68 | 1. Fork the repository and create your branch from `main`: `git checkout -b your-branch-name` 69 | 2. Make your changes and test thoroughly. 70 | 3. Add, commit, and push your changes to your forked repository. 71 | 4. Create a pull request to the `main` branch of the original repository. 72 | 5. Clearly describe your changes and why you think they should be merged. 73 | 6. Be willing to make any requested changes or improvements. 74 | 75 | Thank you for contributing to our project! 🚀 76 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Curious Team 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # PyLibLog - Your Python Library Encyclopedia 🐍📚 2 | Python is renowned for its extensive library ecosystem, but navigating through the vast array of libraries can be a daunting task. That's where PyLibLog comes to your rescue. We've created a one-stop destination for Python developers, learners, and enthusiasts to explore, understand, and leverage Python libraries effectively. 3 | Teaching and sharing information about Python libraries through blog posts. These blogs include explanations, definitions, examples, and what happens when you use them. 4 |
5 | 6 | # Contributing Guidelines 7 | 8 | Welcome to our open-source project! By contributing, you help us create better software for everyone. 9 | 10 | Before you start contributing, please take a moment to read the following guidelines to ensure a smooth and effective contribution process: 11 | 12 |

Technology Stack

13 |

14 | 15 | 16 | 17 |

18 | 19 | ## Table of Contents 20 | 21 | - [PyLibLog - Your Python Library Encyclopedia 🐍📚](#pyliblog---your-python-library-encyclopedia-) 22 | - [Contributing Guidelines](#contributing-guidelines) 23 | - [Table of Contents](#table-of-contents) 24 | - [Getting Started](#getting-started) 25 | - [Standard Design Protocol](#standard-design-protocol) 26 | - [How Can I Contribute?](#how-can-i-contribute) 27 | - [Team Onboarding](#team-onboarding) 28 | - [Reporting Bugs](#reporting-bugs) 29 | - [Suggesting Enhancements](#suggesting-enhancements) 30 | - [Working on Issues](#working-on-issues) 31 | - [Git Commands](#git-commands) 32 | - [Submitting Pull Requests](#submitting-pull-requests) 33 | - [Resources](#resources) 34 | 35 | ## Getting Started 36 | 37 | - Ensure you have an IDE installed on your local machine. 38 | - Fork the repository on GitHub. 39 | - Clone your forked repository locally: `git clone https://github.com/thecuriousteam/PyLibLog.git` 40 | - Change your directory to the project: `cd PyLibLog` 41 | 42 | 43 | ## Standard Design Protocol 44 | 1. Font & Color Code 45 | 1. Headings H1 - #8800ff 46 | 2. Heading H2 to H6 and body, Paragraph - #000000 47 | 3. Heading Font - https://fonts.google.com/specimen/Poppins 48 | 4. Body Font Body - https://fonts.google.com/specimen/Source+Serif+4 49 | 5. Font Size - https://medium.com/eightshapes-llc/typography-in-design-systems-6ed771432f1e 50 | 6. Standard Website Design reference 51 | 1. https://dart-tutorial.com/ 52 | 2. https://www.w3schools.com/html/ 53 | 3. https://www.studytonight.com/html5-references/html-a-tag 54 | 55 | ![Size Structure ](https://miro.medium.com/v2/resize:fit:828/format:webp/1*2av-i7NsHMvkhkyElFHQxg.png) 56 | 57 | ## How Can I Contribute? 58 | 59 | ### Team Onboarding 60 | Developers needs to onboard to opensource community for easy information flow along with admins, please join with this link [Curious Developers Community - Hacktoberfest ](https://chat.whatsapp.com/HNu3VaLPK3z3yt3JFUs7D7)
61 | 62 | ### Reporting Bugs 63 | 64 | If you find a bug, please ensure the bug was not already reported by searching on GitHub under [Issues](https://github.com/thecuriousteam/PyLibLog/issues). If you can't find an existing issue addressing the problem, please [open a new issue](https://github.com/thecuriousteam/PyLibLog/issues/new) and provide detailed information about the bug. 65 | 66 | ### Suggesting Enhancements 67 | 68 | If you have an idea for an enhancement, we welcome your input. Before creating a new enhancement issue, please check the existing issues to see if your enhancement idea has already been discussed. If it hasn't, [create a new issue](https://github.com/thecuriousteam/PyLibLog/issues/new) and outline your enhancement proposal. 69 | 70 | ### Working on Issues 71 | 72 | Feel free to pick any open issue from our [issue tracker](https://github.com/thecuriousteam/PyLibLog/issues) that you find interesting. Comment on the issue that you would like to work on so that others are aware you are addressing it. If you need more context on a particular issue, please ask for clarification. 73 | 74 | ## Git Commands 75 | You can also refer to this [Article](https://www.atlassian.com/git/tutorials/comparing-workflows/gitflow-workflow) 76 | 77 | 1. git flow -h (gives the list of sub commands) 78 | 2. git flow init (initializes the repository) 79 | 3. git status (shows which branch we are in) 80 | 4. git flow feature list (gives list of feature branches) 81 | - git flow feature start featureName (to create a feature branch) 82 | - git branch (shows the list of branches) 83 | - git flow feature list (gives list of feature branches) 84 | - git status (shows the list of changes made) 85 | - git add . (to add all the changes at once) 86 | - git commit -m "Commit message" (to commit the changes) 87 | - git log --oneline (shows the logs) 88 | 5. git checkout develop (used to switch to specific develop branch) 89 | 6. git flow feature finish -k featureName (used to merge the feature branch to develop without deleting the feature branch) 90 | 7. git push -u origin develop (used to push the changes to cloud) 91 | 8. git push --set-upstream origin featureName 92 | 9. git flow release start 1.2.1 93 | 10. git flow release finish –kn <1.1.1> 94 | 95 | ### Submitting Pull Requests 96 | 97 | 1. Fork the repository and create your branch from `main`: `git checkout -b your-branch-name` 98 | 2. Make your changes and test thoroughly. 99 | 3. Add, commit, and push your changes to your forked repository. 100 | 4. Create a pull request to the `main` branch of the original repository. 101 | 5. Clearly describe your changes and why you think they should be merged. 102 | 6. Be willing to make any requested changes or improvements. 103 | 104 | ## Resources 105 | - Learning Contents: 106 | - [Curious Community Web Development Open Source Resources](https://drive.google.com/drive/folders/1K3FKSM3hu5IS3gOv0aFtQ4wEwStKhoXQ?usp=sharing) 107 | - [React JS](https://drive.google.com/drive/folders/1G0TJMZ4P-UAiwSG0ijgkND-gkEOB95-I?usp=drive_link) 108 | - Hacktoberfest Official Website: [https://hacktoberfest.digitalocean.com/](https://hacktoberfest.digitalocean.com/)
109 | - GitHub Hacktoberfest Guide: [https://github.com/firstcontributions/first-contributions](https://github.com/firstcontributions/first-contributions)
110 | 111 | ### Updates 112 | **Date -** 03/10/2023 113 | 1. We are extending the technology based on the developers discussion 114 | 2. Technology Stack 115 | 1. Basic HTML, CSS, JS 116 | 2. ReactJS, Tailwind CSS, React Router 117 | 118 | Creative Commons License 119 |
This work is licensed under a Creative Commons Attribution 4.0 International License. 120 |
121 | All rights reserved by Curious Developers Community. 122 | 123 | Thank you for contributing to our project! 🚀 124 | 125 | -------------------------------------------------------------------------------- /assets/Logos & Favicon/CDC High Resolution Circle Logo Transparent Background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thecuriousteam/PyLibLog/4f9d01622f9a78e945afd6b4cd619bc5c3acacc8/assets/Logos & Favicon/CDC High Resolution Circle Logo Transparent Background.png -------------------------------------------------------------------------------- /assets/Logos & Favicon/CDC High Resolution Circle Logo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thecuriousteam/PyLibLog/4f9d01622f9a78e945afd6b4cd619bc5c3acacc8/assets/Logos & Favicon/CDC High Resolution Circle Logo.jpg -------------------------------------------------------------------------------- /assets/Logos & Favicon/CDC New High Resolution Logo Circle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thecuriousteam/PyLibLog/4f9d01622f9a78e945afd6b4cd619bc5c3acacc8/assets/Logos & Favicon/CDC New High Resolution Logo Circle.png -------------------------------------------------------------------------------- /assets/Logos & Favicon/CDC New High Resolution Logo Option 2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thecuriousteam/PyLibLog/4f9d01622f9a78e945afd6b4cd619bc5c3acacc8/assets/Logos & Favicon/CDC New High Resolution Logo Option 2.png -------------------------------------------------------------------------------- /assets/Logos & Favicon/CDC New High Resolution Logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thecuriousteam/PyLibLog/4f9d01622f9a78e945afd6b4cd619bc5c3acacc8/assets/Logos & Favicon/CDC New High Resolution Logo.png -------------------------------------------------------------------------------- /assets/Logos & Favicon/github.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thecuriousteam/PyLibLog/4f9d01622f9a78e945afd6b4cd619bc5c3acacc8/assets/Logos & Favicon/github.png -------------------------------------------------------------------------------- /assets/Logos & Favicon/icons8-community-96.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thecuriousteam/PyLibLog/4f9d01622f9a78e945afd6b4cd619bc5c3acacc8/assets/Logos & Favicon/icons8-community-96.png -------------------------------------------------------------------------------- /docs/Project_Setup.md: -------------------------------------------------------------------------------- 1 | # PyLibLog - Documentation 2 | 3 | Please follow these documentation to setup this project for development work 4 | 5 | ## Installation 6 | 7 | Use the website [Node JS](https://nodejs.org/en/download/current) to install Node Js in your PC. 8 | 9 | ## Project Setup Steps 10 | ### Clone The Project 11 | 12 | ```bash 13 | git clone repo_url 14 | ``` 15 | 16 | ### Go Inside Project And Take The Latest Pull 17 | ```bash 18 | git pull 19 | ``` 20 | 21 | ### Install the Node Modules 22 | 23 | ```bash 24 | npm i 25 | ``` 26 | 27 | ### Run The React APP 28 | 29 | ```bash 30 | npm run dev 31 | ``` 32 | ## Contributing 33 | 34 | Pull requests are welcome. For major changes, please open an issue first 35 | to discuss what you would like to change. 36 | 37 | Please make sure to update tests as appropriate. 38 | 39 | ## License 40 | 41 | [MIT](https://choosealicense.com/licenses/mit/) -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | PyLibLog 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "sidebar-with-submenu", 3 | "private": true, 4 | "version": "0.0.0", 5 | "type": "module", 6 | "scripts": { 7 | "dev": "vite", 8 | "build": "vite build", 9 | "preview": "vite preview" 10 | }, 11 | "dependencies": { 12 | "brace": "^0.11.1", 13 | "framer-motion": "^9.0.1", 14 | "react": "^18.2.0", 15 | "react-ace": "^10.1.0", 16 | "react-dom": "^18.2.0", 17 | "react-helmet": "^6.1.0", 18 | "react-helmet-async": "^1.3.0", 19 | "react-icons": "^4.7.1", 20 | "react-refresh": "^0.14.0", 21 | "react-responsive": "^9.0.2", 22 | "react-router-dom": "^6.8.0", 23 | "react-scripts": "^5.0.1", 24 | "react-simple-code-editor": "^0.13.1" 25 | }, 26 | "devDependencies": { 27 | "@types/react": "^18.0.27", 28 | "@types/react-dom": "^18.0.10", 29 | "@vitejs/plugin-react": "^3.1.0", 30 | "autoprefixer": "^10.4.13", 31 | "postcss": "^8.4.21", 32 | "tailwind-scrollbar": "^2.1.0", 33 | "tailwindcss": "^3.2.7", 34 | "vite": "^4.5.0" 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /postcss.config.cjs: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | plugins: { 3 | tailwindcss: {}, 4 | autoprefixer: {}, 5 | }, 6 | } 7 | -------------------------------------------------------------------------------- /src/App.jsx: -------------------------------------------------------------------------------- 1 | import { Route, Routes, Outlet } from "react-router-dom"; 2 | import RootLayout from "./layouts/RootLayout"; 3 | import AllApps from "./Python_Library_Pages/AllApps"; 4 | 5 | import PythonBasics from "./Python_Library_Pages/Python_Basics/Introduction-to-Python"; 6 | import NumpyBasics from "./Python_Library_Pages/Numpy/Intro-to-Numpy"; 7 | import MatplotlibBasics from "./Python_Library_Pages/Matplotlib/Intro-to-Matplotlib"; 8 | import PandasBasics from "./Python_Library_Pages/Pandas/Intro-to-Pandas"; 9 | import OperatorsBasics from "./Python_Library_Pages/Python_Basics/Intrduction-to-Operators"; 10 | import FunctionsBasics from "./Python_Library_Pages/Python_Basics/Introduction-to-Functions"; 11 | import PlayGround from "./Python/PlayGround"; 12 | 13 | import Navbar from "./Components/Navbar"; 14 | import TensorFlow from "./Python_Library_Pages/TensorFlow/Introduction-to-tensorFlow"; 15 | import IntroAndInstall from "./Python_Library_Pages/Flask/Introduction-to-flask"; 16 | import PYQT from "./Python_Library_Pages/PYQT/Introduction-to-PYQT"; 17 | import TkinterIntro from "./Python_Library_Pages/Tkinter/Introduction-to-tkinter"; 18 | import Seaborn from "./Python_Library_Pages/Seaborn/Introduction-to-Seaborn"; 19 | 20 | 21 | const App = () => { 22 | return ( 23 | 24 | 25 | 26 | } /> 27 | 28 | } /> 29 | 30 | }> 31 | } /> 32 | } 35 | /> 36 | } 39 | /> 40 | 41 | }> 42 | } /> 43 | {/* if we have child element we need added here */} 44 | 45 | }> 46 | } /> 47 | 48 | }> 49 | } /> 50 | 51 | 52 | {/* Seaborn */} 53 | }> 54 | } /> 55 | 56 | 57 | {/* TensorFlow */} 58 | }> 59 | } /> 60 | 61 | 62 | }> 63 | } /> 64 | 65 | }> 66 | } /> 67 | 68 | }> 69 | } /> 70 | 71 | {/* remaing routes*/} 72 | 73 | 74 | 75 | ); 76 | }; 77 | 78 | export default App; 79 | -------------------------------------------------------------------------------- /src/Components/Navbar.jsx: -------------------------------------------------------------------------------- 1 | import React, { useState } from "react"; 2 | 3 | const Navbar = () => { 4 | // Navbar links 5 | let links = [ 6 | { name: "Docs", link: "/" }, 7 | { name: "Libraries", link: "/" }, 8 | { name: "Blog", link: "/" }, 9 | ]; 10 | 11 | const [isOpen, setisOpen] = useState(false); 12 | 13 | return ( 14 | <> 15 | 52 | 53 | ); 54 | }; 55 | 56 | export default Navbar; 57 | -------------------------------------------------------------------------------- /src/Components/Search.jsx: -------------------------------------------------------------------------------- 1 | import React, {useState} from 'react'; 2 | import { subMenusList } from '../Constants'; 3 | import {CiSearch } from "react-icons/ci"; 4 | import { AiOutlineDoubleRight } from "react-icons/ai"; 5 | import { NavLink } from 'react-router-dom'; 6 | 7 | const Search = () => { 8 | const [searchInput, setSearchInput] = useState(""); 9 | const [isSearchBarOpen, setIsSearchBarOpen] = useState(false); 10 | const [searchResults, setSearchResults] = useState([]); 11 | const handleChange = (e) => { 12 | const inputValue = e.target.value.toLowerCase(); 13 | e.preventDefault(); 14 | setSearchInput(inputValue); 15 | // Filter sub-menus based on the search input 16 | const results = subMenusList.reduce((acc, menu) => { 17 | const mainRoute = menu.name.toLowerCase(); 18 | 19 | // Filter children of the menu based on the search input 20 | const content = menu.children.filter((child) => { 21 | const childContent = child.title.toLowerCase(); 22 | return childContent.includes(inputValue); 23 | }); 24 | 25 | if (content.length > 0) { 26 | acc.push({ content, mainRoute }); 27 | } 28 | 29 | return acc; 30 | }, []); 31 | 32 | setSearchResults(results); 33 | }; 34 | // const filteredContent = subMenusList.filter(menu => { 35 | // const content = menu.title.toLowerCase(); 36 | // return content.includes(searchInput.toLowerCase()); 37 | // }); 38 | 39 | const selectOption = (name) => { 40 | setSearchInput(name); 41 | setIsSearchBarOpen(false) 42 | }; 43 | 44 | return ( 45 | <> 46 |
47 | 48 | setIsSearchBarOpen(true)} /> 55 |
56 | {(searchInput && isSearchBarOpen) && ( 57 |
58 | {searchResults.length > 0 ? ( 59 | searchResults.map((menu, i) => 60 | menu.content.map((child, j) => ( 61 |
62 | 63 |

selectOption(child.title)}> 64 | {child.title} 65 |

66 |
67 |
68 | )) 69 | ) 70 | ) : ( 71 |
72 |

No results found

73 |
74 | )} 75 |
76 | )} 77 | 78 | 79 | ) 80 | } 81 | 82 | export default Search -------------------------------------------------------------------------------- /src/Constants/index.js: -------------------------------------------------------------------------------- 1 | // important 2 | // guys must name route value equal to same as what you give the route in App.jsx 3 | 4 | export const subMenusList = [ 5 | { 6 | name: "Python-Basics", 7 | title: "Python Basics", 8 | route: "/Python-Basics/Introduction-to-Python", 9 | children: [ 10 | { 11 | title: "Introduction to Python", 12 | route: "Introduction-to-Python", 13 | }, 14 | { 15 | title: "Introduction to Operators", 16 | route: "Introduction-to-Operators", 17 | }, 18 | { 19 | title: "Introduction to Functions", 20 | route: "Introduction-to-Functions", 21 | }, 22 | ], 23 | }, 24 | { 25 | name: "Arrow", 26 | title: "Arrow", 27 | route: "/Arrow/Introduction-to-Arrow", 28 | children: [ 29 | { 30 | title: "Introduction to Arrow", 31 | route: "Introduction-to-Arrow", 32 | }, 33 | { 34 | title: "Date and time handling", 35 | route: "Date-and-time-handling", 36 | }, 37 | { 38 | title: "Datetime manipulation", 39 | route: "Datetime-manipulation", 40 | }, 41 | ], 42 | }, 43 | { 44 | name: "Beautiful Soup", 45 | title: "Beautiful Soup", 46 | route: "/Beautiful-Soup/Introduction-to-Beautiful-Soup", 47 | children: [ 48 | { 49 | title: "Introduction to Beautiful Soup", 50 | route: "Introduction-to-Beautiful-Soup", 51 | }, 52 | { 53 | title: "Web scraping", 54 | route: "Web-scraping", 55 | }, 56 | { 57 | title: "HTML parsing", 58 | route: "HTML-parsing", 59 | }, 60 | ], 61 | }, 62 | { 63 | name: "Cython", 64 | title: "Cython", 65 | route: "/Cython/Introduction-to-Cython", 66 | children: [ 67 | { 68 | title: "Introduction to Cython", 69 | route: "Introduction-to-Cython", 70 | }, 71 | { 72 | title: "C and Python integration", 73 | route: "C-and-Python-integration", 74 | }, 75 | { 76 | title: "Performance optimization", 77 | route: "Performance-optimization", 78 | }, 79 | ], 80 | }, 81 | { 82 | name: "Django", 83 | title: "Django", 84 | route: "/Django/Introduction-to-Django", 85 | children: [ 86 | { 87 | title: "Introduction to Django", 88 | route: "Introduction-to-Django", 89 | }, 90 | { 91 | title: "Web development", 92 | route: "Web-development", 93 | }, 94 | { 95 | title: "Web frameworks", 96 | route: "Web-frameworks", 97 | }, 98 | ], 99 | }, 100 | { 101 | name: "Flask", 102 | title: "Flask", 103 | route: "/Flask/Introduction-to-flask", 104 | children: [ 105 | { 106 | title: "Introduction to Flask", 107 | route: "Introduction-to-flask", 108 | }, 109 | ], 110 | }, 111 | { 112 | name: "Flask-RESTful", 113 | title: "Flask-RESTful", 114 | route: "/Flask-RESTful/Introduction-to-Flask-RESTful", 115 | children: [ 116 | { 117 | title: "Introduction to Flask-RESTful", 118 | route: "Introduction-to-Flask-RESTful", 119 | }, 120 | { 121 | title: "RESTful API development with Flask", 122 | route: "RESTful-API-development-with-Flask", 123 | }, 124 | ], 125 | }, 126 | { 127 | name: "GeoPandas", 128 | title: "GeoPandas", 129 | route: "/GeoPandas/Introduction-to-GeoPandas", 130 | children: [ 131 | { 132 | title: "Introduction to GeoPandas", 133 | route: "Introduction-to-GeoPandas", 134 | }, 135 | { 136 | title: "Geographic data analysis", 137 | route: "Geographic-data-analysis", 138 | }, 139 | { 140 | title: "Geospatial data manipulation", 141 | route: "Geospatial-data-manipulation", 142 | }, 143 | ], 144 | }, 145 | { 146 | name: "Gevent", 147 | title: "Gevent", 148 | route: "/Gevent/Introduction-to-Gevent", 149 | children: [ 150 | { 151 | title: "Introduction to Gevent", 152 | route: "Introduction-to-Gevent", 153 | }, 154 | { 155 | title: "Asynchronous networking", 156 | route: "Asynchronous-networking", 157 | }, 158 | { 159 | title: "Coroutines", 160 | route: "Coroutines", 161 | }, 162 | ], 163 | }, 164 | { 165 | name: "Keras", 166 | title: "Keras", 167 | route: "/Keras/Introduction-to-Keras", 168 | children: [ 169 | { 170 | title: "Introduction to Keras", 171 | route: "Introduction-to-Keras", 172 | }, 173 | { 174 | title: "Deep learning", 175 | route: "Deep-learning", 176 | }, 177 | { 178 | title: "Neural networks", 179 | route: "Neural-networks", 180 | }, 181 | { 182 | title: "High-level API for TensorFlow", 183 | route: "High-level-API-for-TensorFlow", 184 | }, 185 | ], 186 | }, 187 | { 188 | name: "Matplotlib", 189 | title: "Matplotlib", 190 | route: "/Matplotlib/Introduction-to-Matplotlib", 191 | children: [ 192 | { 193 | title: "Introduction to Matplotlib", 194 | route: "Introduction-to-Matplotlib", 195 | }, 196 | { 197 | title: "Data visualization", 198 | route: "Data-visualization", 199 | }, 200 | { 201 | title: "2D plotting", 202 | route: "2D-plotting", 203 | }, 204 | ], 205 | }, 206 | { 207 | name: "NetworkX", 208 | title: "NetworkX", 209 | route: "/NetworkX/Introduction-to-NetworkX", 210 | children: [ 211 | { 212 | title: "Introduction to NetworkX", 213 | route: "Introduction-to-NetworkX", 214 | }, 215 | { 216 | title: "Network analysis", 217 | route: "Network-analysis", 218 | }, 219 | { 220 | title: "Graph theory", 221 | route: "Graph-theory", 222 | }, 223 | ], 224 | }, 225 | { 226 | name: "NLTK (Natural Language Toolkit)", 227 | title: "NLTK", 228 | route: 229 | "/NLTK-(Natural-Language-Toolkit)/Introduction-to-NLTK-(Natural-Language-Toolkit)", 230 | children: [ 231 | { 232 | title: "Introduction to NLTK (Natural Language Toolkit)", 233 | route: "Introduction-to-NLTK-(Natural-Language-Toolkit)", 234 | }, 235 | { 236 | title: "Natural language processing (NLP)", 237 | route: "Natural-language-processing-(NLP)", 238 | }, 239 | { 240 | title: "Text mining", 241 | route: "Text-mining", 242 | }, 243 | ], 244 | }, 245 | { 246 | name: "NumPy-Library", 247 | title: "NumPy", 248 | route: "/NumPy-Library/Intro-to-Numpy", 249 | children: [ 250 | { 251 | // List of Pages 252 | title: "Intro to Numpy", 253 | route: "Intro-to-Numpy", 254 | }, 255 | ], 256 | }, 257 | { 258 | name: "OpenCV", 259 | title: "OpenCV", 260 | route: "/OpenCV/Introduction-to-OpenCV", 261 | children: [ 262 | { 263 | title: "Introduction to OpenCV", 264 | route: "Introduction-to-OpenCV", 265 | }, 266 | { 267 | title: "Computer vision", 268 | route: "Computer-vision", 269 | }, 270 | { 271 | title: "Image processing", 272 | route: "Image-processing", 273 | }, 274 | ], 275 | }, 276 | { 277 | name: "Pandas-Library", 278 | title: "Pandas", 279 | route: "/Pandas-Library/Intro-to-pandas", 280 | children: [ 281 | { 282 | title: "Intro to pandas", 283 | route: "Intro-to-pandas", 284 | }, 285 | ], 286 | }, 287 | { 288 | name: "Pillow (PIL)", 289 | title: "Pillow (PIL)", 290 | route: "/Pillow-(PIL)/Introduction-to-Pillow-(PIL)", 291 | children: [ 292 | { 293 | title: "Introduction to Pillow (PIL)", 294 | route: "Introduction-to-Pillow-(PIL)", 295 | }, 296 | { 297 | title: "Image processing", 298 | route: "Image-processing", 299 | }, 300 | { 301 | title: "Image manipulation", 302 | route: "Image-manipulation", 303 | }, 304 | ], 305 | }, 306 | { 307 | name: "Plotly", 308 | title: "Plotly", 309 | route: "/Plotly/Introduction-to-Plotly", 310 | children: [ 311 | { 312 | title: "Introduction to Plotly", 313 | route: "Introduction-to-Plotly", 314 | }, 315 | { 316 | title: "Interactive data visualization", 317 | route: "Interactive-data-visualization", 318 | }, 319 | { 320 | title: "Charts", 321 | route: "Charts", 322 | }, 323 | { 324 | title: "Graphs", 325 | route: "Graphs", 326 | }, 327 | ], 328 | }, 329 | { 330 | name: "Pygame", 331 | title: "Pygame", 332 | route: "/Pygame/Introduction-to-Pygame", 333 | children: [ 334 | { 335 | title: "Introduction to Pygame", 336 | route: "Introduction-to-Pygame", 337 | }, 338 | { 339 | title: "Game development", 340 | route: "Game-development", 341 | }, 342 | { 343 | title: "Multimedia", 344 | route: "Multimedia", 345 | }, 346 | ], 347 | }, 348 | { 349 | name: "PyQT", 350 | title: "PyQT", 351 | route: "/PyQT/Introduction-to-PyQT", 352 | children: [ 353 | { 354 | title: "Introduction to PyQT", 355 | route: "Introduction-to-PyQT", 356 | }, 357 | { 358 | title: "Desktop application development", 359 | route: "Desktop-application-development", 360 | }, 361 | { 362 | title: "GUI (Graphical User Interface)", 363 | route: "GUI-(Graphical-User-Interface)", 364 | }, 365 | ], 366 | }, 367 | { 368 | name: "PyTorch", 369 | title: "PyTorch", 370 | route: "/PyTorch/Introduction-to-PyTorch", 371 | children: [ 372 | { 373 | title: "Introduction to PyTorch", 374 | route: "Introduction-to-PyTorch", 375 | }, 376 | { 377 | title: "Deep learning", 378 | route: "Deep-learning", 379 | }, 380 | { 381 | title: "Neural networks", 382 | route: "Neural-networks", 383 | }, 384 | { 385 | title: "Dynamic neural networks", 386 | route: "Dynamic-neural-networks", 387 | }, 388 | ], 389 | }, 390 | { 391 | name: "Requests", 392 | title: "Requests", 393 | route: "/Requests/Introduction-to-Requests", 394 | children: [ 395 | { 396 | title: "Introduction to Requests", 397 | route: "Introduction-to-Requests", 398 | }, 399 | { 400 | title: "HTTP requests", 401 | route: "HTTP-requests", 402 | }, 403 | { 404 | title: "Web APIs", 405 | route: "Web-APIs", 406 | }, 407 | ], 408 | }, 409 | { 410 | name: "Scikit-Learn", 411 | title: "Scikit-Learn", 412 | route: "/Scikit-Learn/Introduction-to-Scikit-Learn", 413 | children: [ 414 | { 415 | title: "Introduction to Scikit-Learn", 416 | route: "Introduction-to-Scikit-Learn", 417 | }, 418 | { 419 | title: "Machine learning", 420 | route: "Machine-learning", 421 | }, 422 | { 423 | title: "Data mining", 424 | route: "Data-mining", 425 | }, 426 | { 427 | title: "Data analysis", 428 | route: "Data-analysis", 429 | }, 430 | ], 431 | }, 432 | { 433 | name: "Scipy", 434 | title: "Scipy", 435 | route: "/Scipy/Introduction-to-Scipy", 436 | children: [ 437 | { 438 | title: "Introduction to Scipy", 439 | route: "Introduction-to-Scipy", 440 | }, 441 | { 442 | title: "Scientific computing", 443 | route: "Scientific-computing", 444 | }, 445 | { 446 | title: "Optimization", 447 | route: "Optimization", 448 | }, 449 | { 450 | title: "Signal processing", 451 | route: "Signal-processing", 452 | }, 453 | ], 454 | }, 455 | { 456 | name: "Scrapy", 457 | title: "Scrapy", 458 | route: "/Scrapy/Introduction-to-Scrapy", 459 | children: [ 460 | { 461 | title: "Introduction to Scrapy", 462 | route: "Introduction-to-Scrapy", 463 | }, 464 | { 465 | title: "Web scraping", 466 | route: "Web-scraping", 467 | }, 468 | { 469 | title: "Web crawling", 470 | route: "Web-crawling", 471 | }, 472 | ], 473 | }, 474 | { 475 | name: "Seaborn", 476 | title: "Seaborn", 477 | route: "/Seaborn/Introduction-to-Seaborn", 478 | children: [ 479 | { 480 | title: "Introduction to Seaborn", 481 | route: "Introduction-to-Seaborn", 482 | }, 483 | { 484 | title: "Statistical data visualization", 485 | route: "Statistical-data-visualization", 486 | }, 487 | ], 488 | }, 489 | { 490 | name: "Spacy", 491 | title: "Spacy", 492 | route: "/Spacy/Introduction-to-Spacy", 493 | children: [ 494 | { 495 | title: "Introduction to Spacy", 496 | route: "Introduction-to-Spacy", 497 | }, 498 | { 499 | title: "NLP", 500 | route: "NLP", 501 | }, 502 | { 503 | title: "Text processing", 504 | route: "Text-processing", 505 | }, 506 | { 507 | title: "Tokenization", 508 | route: "Tokenization", 509 | }, 510 | { 511 | title: "Named entity recognition", 512 | route: "Named-entity-recognition", 513 | }, 514 | ], 515 | }, 516 | { 517 | name: "SQLAlchemy", 518 | title: "SQLAlchemy", 519 | route: "/SQLAlchemy/Introduction-to-SQLAlchemy", 520 | children: [ 521 | { 522 | title: "Introduction to SQLAlchemy", 523 | route: "Introduction-to-SQLAlchemy", 524 | }, 525 | { 526 | title: "Database interaction", 527 | route: "Database-interaction", 528 | }, 529 | { 530 | title: "ORM (Object-Relational Mapping)", 531 | route: "ORM-(Object-Relational-Mapping)", 532 | }, 533 | ], 534 | }, 535 | { 536 | name: "SymPy", 537 | title: "SymPy", 538 | route: "/SymPy/Introduction-to-SymPy", 539 | children: [ 540 | { 541 | title: "Introduction to SymPy", 542 | route: "Introduction-to-SymPy", 543 | }, 544 | { 545 | title: "Symbolic mathematics", 546 | route: "Symbolic-mathematics", 547 | }, 548 | { 549 | title: "Computer algebra system", 550 | route: "Computer-algebra-system", 551 | }, 552 | ], 553 | }, 554 | { 555 | name: "TensorFlow", 556 | title: "TensorFlow", 557 | route: "/TensorFlow/Introduction-to-tensorFlow", 558 | children: [ 559 | { 560 | title: "Introduction to TensorFlow", 561 | route: "Introduction-to-TensorFlow", 562 | }, 563 | ], 564 | }, 565 | { 566 | name: "Tkinter", 567 | title: "Tkinter", 568 | route: "/Tkinter/Introduction-to-tkinter", 569 | children: [ 570 | { 571 | title: "Introduction to tkinter", 572 | route: "Introduction-to-tkinter", 573 | }, 574 | { 575 | title: "Exploring widgets in tkinter", 576 | route: "Exploring-widgets-in-tkinter", 577 | }, 578 | { 579 | title: "Binding functions", 580 | route: "Binding-functions", 581 | }, 582 | { 583 | title: "Advanced tkinter", 584 | route: "Advanced-tkinter", 585 | }, 586 | ], 587 | }, 588 | { 589 | name: "Twisted", 590 | title: "Twisted", 591 | route: "/Twisted/Introduction-to-Twisted", 592 | children: [ 593 | { 594 | title: "Introduction to Twisted", 595 | route: "Introduction-to-Twisted", 596 | }, 597 | { 598 | title: "Asynchronous networking", 599 | route: "Asynchronous-networking", 600 | }, 601 | { 602 | title: "Event-driven programming", 603 | route: "Event-driven-programming", 604 | }, 605 | ], 606 | }, 607 | /* remaining contents*/ 608 | ]; 609 | -------------------------------------------------------------------------------- /src/Python/CodeEditor.jsx: -------------------------------------------------------------------------------- 1 | import React, { useState, useEffect } from "react"; 2 | import PropTypes from "prop-types"; 3 | import AceEditor from "react-ace"; 4 | 5 | const CodeEditor = ({ value, onChange, ...otherProps }) => { 6 | const [editorValue, setEditorValue] = useState(value); 7 | 8 | useEffect(() => { 9 | if (value !== editorValue) { 10 | setEditorValue(value); 11 | } 12 | }, [value]); 13 | 14 | const handleEditorChange = (newValue) => { 15 | setEditorValue(newValue); 16 | onChange(newValue); 17 | }; 18 | 19 | return ( 20 | 28 | ); 29 | }; 30 | 31 | CodeEditor.propTypes = { 32 | value: PropTypes.string, 33 | onChange: PropTypes.func, 34 | }; 35 | 36 | CodeEditor.defaultProps = { 37 | value: "", 38 | onChange: () => null, 39 | }; 40 | 41 | export default CodeEditor; 42 | -------------------------------------------------------------------------------- /src/Python/PlayGround copy.jsx: -------------------------------------------------------------------------------- 1 | import React, { useState } from "react"; 2 | import { Helmet, HelmetProvider } from "react-helmet-async"; 3 | import Scripts from "./Scripts"; 4 | import CodeEditor from "./CodeEditor"; 5 | import "brace/mode/python"; 6 | import "brace/theme/monokai"; 7 | 8 | let logs = []; 9 | 10 | const PlayGround = () => { 11 | const [code, setCode] = useState(""); 12 | const [outputArr, setOutputArr] = useState([]); 13 | 14 | const run = () => { 15 | try { 16 | logs = []; 17 | window.brython([1]); 18 | } catch (error) { 19 | console.log(error); 20 | } 21 | }; 22 | 23 | const handleConsoleLog = (value) => { 24 | if (value !== "using indexedDB for stdlib modules cache") { 25 | logs.push(`${value}`); 26 | setOutputArr([...logs]); 27 | } 28 | }; 29 | 30 | const clearLogs = () => { 31 | logs = []; 32 | setOutputArr([]); 33 | }; 34 | 35 | window.console.log = handleConsoleLog; 36 | 37 | return ( 38 | 39 |
40 |
41 | 42 | 7 | ) 8 | } 9 | 10 | Scripts.propTypes = { 11 | code: PropTypes.string.isRequired, 12 | }; 13 | 14 | export default Scripts -------------------------------------------------------------------------------- /src/Python_Library_Pages/AllApps.jsx: -------------------------------------------------------------------------------- 1 | import { subMenusList } from "../Constants"; 2 | import githubicon from "../../assets/Logos & Favicon/github.png"; 3 | import { Link } from "react-router-dom"; 4 | 5 | const AllApps = () => { 6 | return ( 7 |
8 |
9 |

PyLibLog

10 |

11 | Your Python Library Encyclopedia 🐍📚 12 |

13 |
14 |

15 | PyLibLog is open source project... you can also contribute 16 |

17 | 21 | github-icon 22 | 23 |
24 |
25 |
26 |

Get Start

27 |

Explore all python libraries

28 |
    29 | {subMenusList?.map((data, i) => ( 30 |
  • 34 | {/* {data.name} */} 35 | {i + 1}. 36 | {data.title} 37 |
  • 38 | ))} 39 |
40 |
41 |
42 | ); 43 | }; 44 | 45 | export default AllApps; 46 | -------------------------------------------------------------------------------- /src/Python_Library_Pages/Flask/Introduction-to-flask.jsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | 3 | const IntroAndInstall = () => { 4 | return ( 5 |
6 |
7 |

Introduction to Flask

8 |

Flask is a micro web framework written in Python, that allows developers to build lightweight web applications quickly and easily with Flask Libraries.It is based on WSGI toolkit and jinja2 template engine.

9 |

The backend server Flask was created fully in Python. It is a lightweight application that speeds up the development of backend apps.


10 |

What is WSGI?

11 |

It is an acronym for web server gateway interface which is a standard for python web application development. It is considered as the specification for the universal interface between the web server and web application.Werkzeug It is a WSGI toolkit, which implements requests, response objects, and other utility functions. This enables building a web framework on top of it.The Flask framework uses Werkzeug as one of its bases.


12 |

What is Jinja2?

13 |

Jinja2 is a web template engine which combines a template with a certain data source to render the dynamic web pages.




14 |
15 | 16 |
17 |

Installing Flask on Windows

18 |

1. Make sure that Python PIP should be installed on your OS. You can check using the below command.

19 |
20 |

pip -V

21 |

or

22 |

pip --version

23 |

24 |

2. At first, open the command prompt in administrator mode. Then the following command should be run. This command will help to install Flask using Pip in Python and will take very less time to install.

25 |
26 |

pip install flask

27 |

28 |

3. After that, also the following two commands should be run. These commands will start Flask in the command prompt. Hence, the process is completed successfully.

29 |
30 |

python

31 |

import flask

32 |
33 |



34 |
35 |

File Structure of a flask application

36 |

Flask doesn't impose a strict structure, but a common structure includes the following files and directories:

37 |
    38 |
  •   Main Application File (usually named app.py or application.py): This is the entry point of your Flask application. It contains the Flask application instance, route definitions, and other application-specific code.
  • 39 |
  •   Templates Directory (usually named templates): This directory contains HTML templates for rendering dynamic web pages. Flask uses the Jinja2 templating engine by default. You can use these templates to generate HTML with dynamic data.
  • 40 |
  •   Static Directory (usually named static): This directory stores static files like CSS stylesheets, JavaScript files, images, and other assets that are served directly to the client's web browser.
  • 41 |
42 |



43 |

Running and accessing your application

44 |

To run your web application created app.py using flask, In your terminal, navigate to the directory containing your app.py file and run the Flask application with the following command:

45 |
46 |

python app.py

47 |

48 |

Flask will start a development server, and it will display output indicating that the application is running. Typically, it will say something like "Running on http://127.0.0.1:5000/," indicating that your application is accessible at http://127.0.0.1:5000 in your web browser.


49 |

Open a web browser and navigate to the URL displayed in the terminal (e.g., http://127.0.0.1:5000). You should see your Flask application in action.




50 |
51 |

Creating first flask application

52 |

Write the following lines of code and save to a file named as script.py.

53 |
54 |

from flask import Flask

55 |

app = Flask(__name__)

56 |

@app.route("/")

57 |

def home():

58 |

  return '<h1>Hello World</h1>'

59 |

if __name__=='__main__':

60 |

  app.run(debug=True)

61 |

62 |

Creating Flask App Object - The Flask class can be imported to create the main application object. It takes the name of the app as an argument.
app = Flask(__name__)


63 |

Creating a Route - Routes in a Flask app can be created by defining a view function and associating a URL with it using the route() decorator. Routes specify how the Flask app handles requests it receives, such as what to display on the webpage at a certain URL.
@app.route("/")


64 |

Returning HTML From Route - In a Flask app, HTML can be returned from a view function to be rendered on a webpage. The HTML can be returned as a string.
return '<h1>Hello World</h1>'


65 |

Running The App in Debugger -This coomand is used to run the flask application with debug mode as on. When debug mode is turned on, It allows developers to locate any possible error and as well the location of the error, by logging a traceback of the error.
if __name__=='__main__':
  app.run(debug=True)

66 |



67 |

Routing

68 |

The route() decorator in Flask is used to bind URL to a function.

69 |
70 |

@app.route('/hello')

71 |

def hello_world():

72 |

  return 'hello world'

73 |

74 |

Here, URL ‘/hello’ rule is bound to the hello_world() function. As a result, if a user visits http://localhost:5000/hello URL, the output of the hello_world() function will be rendered in the browser.


75 |

A decorator’s purpose is also served by the following representation −

76 |
77 |

def hello_world():

78 |

  return 'hello world'

79 |

app.add_url_rule('/','hello',hello_world)

80 |

81 |

The add_url_rule() function is used to bind a URL with a function as in the above example, route() is used.

82 |



83 |
84 |

Templates

85 |

The goal is to create a flask application which can render or generate a template when the user goes to a specific URL.

86 |

1. First create the templates, you can use any basic HTML template. Before that, create a folder called “templates” in the current folder. Inside this “templates” folder, all of the templates will be residing. For example index.html be:

87 |
88 |

<!DOCTYPE html>

89 |

<html>

90 |

<head>

91 |

  <title>FlaskTest</title>

92 |

</head>

93 |

<body>

94 |

  <h2>Welcome to flask tutorial</h2>

95 |

  <p>This is explaination of how templates are rendered in a flask application.</p>

96 |

</body>

97 |

</html>

98 |

99 |

2. Now, we need a way to actually link the template with a specific route or URL. We need to change the python file script.py

100 |
101 |

from flask import Flask, render_template

102 |

app = Flask(__name__)

103 |

@app.route("/")

104 |

def index():

105 |

  return render_template("index.html")

106 |

if __name__=='__main__':

107 |

  app.run(debug=True)

108 |



109 |
110 |

Jinja Templating and Template inheritence

111 |

Any parameters beyond the template file name index.html into the templating service can also be used in small snippets of code inside HTML file, such as conditionals or loops.


112 |

So, let us re-use our “index.html” and create a block in there. T do that we use “{% block <name> %} (where name = ‘body’) to start the block, this will take everything above it and store it in a virtual block of template, to end the block you simply use “{% endblock %}” this will copy everything below it.


113 | templates/index.html 114 |
115 |

<!DOCTYPE html>

116 |

<html>

; 117 |

<head>

118 |

  <title>FlaskTest</title>

119 |

</head>

120 |

<body>

121 |

  <h2>Welcome to flask tutorial</h2>

122 |

  <p>This is explaination of how templates are rendered in a flask application.</p>

123 |

{% block body%}

124 |

<p>This is a Flask application.</p>

125 |

{% endblock %}

126 |

</body>

127 |

</html>

128 |

129 |

So, here we are not including the <p> tags as everything below the {% endblock %} and everything above the {% block body %} tag is copied. We are also using absolute URLs. The URLs are dynamic and quite easy to understand. We enclose them in “{ }” as part of the Jinja2 syntax. The url_for function reverses the entire URL for us, we just have to pass the name of the function as a string as a parameter to the function.


130 |

Now, we’ll create another template to reuse this created block “body”, let’s create the template home.html with the following contents:


131 | templates/home.html 132 |
133 |

{% extends 'index.html' %}

134 |

{% block body %}

135 |

 { <p>This is home page.</p>

136 |

{% endblock %}

137 |

138 |

This looks like a two-liner but will also extend (not include) the index.html. This is by using the {% extends <file.html> %} tags, they parse the block into the mentioned template. After this, we can add the things we want. If you use the include tag it will not put the replacement paragraph in the correct place on the index.html page. It will create an invalid HTML file, but since the browser is very forgiving you will not notice unless you look at the source generated. The body text must be properly nested.


139 |

Inducing Logic in Templates - We can use for loops if conditions in templates. this is such a great feature to leverage on. We can create some great dynamic templates without much of a hassle.

140 |



141 |

HTTP methods

142 |

HTTP is the hypertext transfer protocol which is considered as the foundation of the data transfer in the world wide web. All web frameworks including flask need to provide several HTTP methods for data communication. Flask can run different code from the same URL dependent on HTTP method used.


143 |

  POST Method - It is used to send the form data to the server. The server does not cache the data transmitted using the post method.

144 |

Let us first create a form to get some data at the client side from the user, and we will try to access this data on the server by using the POST request.


145 | login.html 146 |
147 |

<!DOCTYPE html>

148 |

<html>

; 149 |

<head>

150 |

  <title>Form</title>

151 |

</head>

152 |

<body>

153 |

  <form action = "http://localhost:5000/login" method = "post">

154 |

Welcome to flask tutorial</h2>

155 |

  <table>

156 |

<tr><td>Name</td>

157 |

<td><input type = "text" name = "uname"></td></tr>

158 |

<tr><td>Password</td>

159 |

<td><input type = "password" name = "pass"></td></tr>

160 |

<tr><td><input type = "submit"></td></tr>

161 |

</table>

162 |

</form>

163 |

</body>

164 |

</html>

165 |

166 | post_example.py 167 |
168 |

from flask import *

169 |

app = Flask(__name__)

170 |

@app.route("/login",methods = ['POST'])

171 |

def login():

172 |

  uname=request.form['uname']

173 |

  password=request.form['pass']

174 |

  if uname== "ayush" and password=="google":

175 |

    return "Welcome %s" %uname

176 |

if __name__=='__main__':

177 |

  app.run(debug=True)

178 |

179 |

Start the development server by running the post_example.py. After providing the required input and submitting, the form data is ent to the development server by using the post method.


180 |

  GET Method - It is the method which can be used to send data in the unencrypted form to the server. By default, the requests are handled by the GET() method. Let's consider the same example for the Get method. However, there are some changes in the data retrieval syntax on the server side. First, create a form as login.html.


181 | login.html 182 |
183 |

<!DOCTYPE html>

184 |

<html>

; 185 |

<head>

186 |

  <title>Form</title>

187 |

</head>

188 |

<body>

189 |

  <form action = "http://localhost:5000/login" method = "get">

190 |

Welcome to flask tutorial</h2>

191 |

  <table>

192 |

<tr><td>Name</td>

193 |

<td><input type = "text" name = "uname"></td></tr>

194 |

<tr><td>Password</td>

195 |

<td><input type = "password" name = "pass"></td></tr>

196 |

<tr><td><input type = "submit"></td></tr>

197 |

</table>

198 |

</form>

199 |

</body>

200 |

</html>

201 |

202 | get_example.py 203 |
204 |

from flask import *

205 |

app = Flask(__name__)

206 |

@app.route("/login",methods = ['GET'])

207 |

def login():

208 |

  uname=request.form['uname']

209 |

  password=request.form['pass']

210 |

  if uname== "ayush" and password=="google":

211 |

    return "Welcome %s" %uname

212 |

if __name__=='__main__':

213 |

  app.run(debug=True)

214 |

215 |

After providing the input ans submitting ,The data is sent using the get() method is retrieved on the development server.


216 |

The data is obtained by using the following line of code.

217 |
218 |

uname = request.args.get('uname')

219 |

220 |
221 | 222 |
223 | ); 224 | }; 225 | export default IntroAndInstall; 226 | -------------------------------------------------------------------------------- /src/Python_Library_Pages/Matplotlib/Intro-to-Matplotlib.jsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | 3 | const MatplotlibBasics = () => { 4 | return ( 5 |
6 |

Introduction to Matplotlib

7 | 8 |

Development can start for Matplotlib from here

9 |
10 | ); 11 | }; 12 | 13 | export default MatplotlibBasics; 14 | -------------------------------------------------------------------------------- /src/Python_Library_Pages/Numpy/Intro-to-Numpy.jsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | 3 | const NumpyBasics = () => { 4 | return ( 5 |
6 |

Introduction to NumPy

7 | 8 |

Development can start for NumPy from here

9 |
10 | ); 11 | }; 12 | 13 | export default NumpyBasics; -------------------------------------------------------------------------------- /src/Python_Library_Pages/PYQT/Introduction-to-PYQT.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | 3 | const PYQT = () => { 4 | return ( 5 |
6 |
7 |

Introduction-to-PYQT

8 |

9 | In the world of software development, creating user-friendly graphical interfaces is a critical aspect of building successful applications. PyQt, a set of Python bindings for the Qt application framework, is a powerful and versatile tool that allows developers to design and implement interactive, cross-platform applications with ease. In this blog, we'll provide you with an introduction to PyQt, exploring what it is, its features, and why it's a valuable choice for developers. 10 |


11 | 12 |
    13 |
  • 14 |   Cross-Platform Compatibility 15 |
  • 16 |
  • 17 |   Rich GUI Elements 18 |
  • 19 |
  • 20 |  Support for 2D and 3D Graphics 21 |
  • 22 |
  • 23 |  Signals and Slots 24 |
  • 25 |
  • 26 |  Internationalization and Localization 27 |
  • 28 |

29 |

Let's break down the key concepts step by step:

30 |
    31 |
  1. 32 | Qt Framework: PyQt is built on top of the Qt framework, which provides tools for developing cross-platform applications, including GUIs. 33 |
  2. 34 |
  3. 35 | Widgets: Everything visible on the user interface in PyQt is a widget, including buttons, labels, text boxes, and more. 36 |
  4. 37 |
  5. 38 | Signals and Slots: Signals and slots are a fundamental concept in PyQt, enabling interactivity by connecting events to functions. 39 |
  6. 40 |
  7. 41 | Layouts: Layouts in PyQt help organize widgets within a window and adapt to different screen sizes and orientations. 42 |
  8. 43 |
  9. 44 | Main Window: QMainWindow is the top-level widget that serves as the main window of your application, providing menu bars and toolbars. 45 |
  10. 46 |
  11. 47 | Events and Event Handling: Understanding how events work and how to handle them is crucial for PyQt development. 48 |
  12. 49 |
  13. 50 | Dialogs: PyQt offers built-in dialog boxes for common tasks such as opening files, displaying messages, and obtaining user input. 51 |
  14. 52 |
  15. 53 | Custom Widgets: You can create custom widgets in PyQt to extend its capabilities for your application. 54 |
  16. 55 |
  17. 56 | Model-View-Controller (MVC): PyQt follows the MVC pattern to separate data, presentation, and user interaction concerns. 57 |
  18. 58 |
  19. 59 | Internationalization and Localization: PyQt supports creating multilingual applications for a global audience. 60 |
  20. 61 |
  21. 62 | Threading and Concurrency: Managing threading and concurrency is important to maintain a responsive user interface. 63 |
  22. 64 |
  23. 65 | Qt Designer: Qt Designer is a visual tool for creating user interfaces in PyQt, aiding in GUI layout design. 66 |
  24. 67 |
68 | 69 |
70 | 71 | 72 |
73 | 74 |

Setting Up PyQt for Python Development

75 | 76 |

PyQt is a Python library for creating graphical user interfaces (GUI) for desktop applications. To get started with PyQt, follow these steps:

77 | 78 |
    79 |
  1. 80 |

    Install Python

    81 |

    Ensure you have Python installed on your system. You can download Python from the official website: Python Downloads.

    82 |
  2. 83 |
  3. 84 |

    Install PyQt5

    85 |

    Open your command line or terminal and run the following command to install PyQt5 using pip:

    86 |
    87 |
    pip install PyQt5
    88 |
    89 | 90 |
  4. 91 |
  5. 92 |

    Optional: Install PyQt5 Tools

    93 |

    If you want to use PyQt5 tools, such as Qt Designer (a visual interface builder), you can install them separately:

    94 |
    95 |
    pip install PyQt5-tools
    96 |
    97 | 98 |
  6. 99 |
  7. 100 |

    Verify the Installation

    101 |

    Open a Python interpreter in your command line or terminal and try to import PyQt5:

    102 |
    103 |
    import PyQt5
    104 |
    105 | 106 |

    If there are no errors, PyQt5 is installed correctly.

    107 |
  8. 108 |
  9. 109 |

    Choose an IDE or Text Editor

    110 |

    Select your preferred Integrated Development Environment (IDE) or text editor for Python development. Some popular options include PyCharm, Visual Studio Code, and IDLE (included with Python).

    111 |
  10. 112 |
  11. 113 |

    Write Your First PyQt Application

    114 |

    Create a simple PyQt application to test your setup. Here's an example that displays a window:

    115 |
    116 |
    import sys
    117 |
    
    118 | from PyQt5.QtWidgets import QApplication, QWidget
    119 | 
    120 |
    
    121 | app = QApplication(sys.argv)
    122 | 
    123 | 124 |
    
    125 | window = QWidget()
    126 | 
    127 |
    
    128 | window.setWindowTitle("Hello, PyQt!")
    129 | 
    130 |
    
    131 | window.show()
    132 | 
    133 |
    
    134 | sys.exit(app.exec_())
    135 |         
    136 |
    137 | 138 | 139 |

    Save this code to a .py file and run it with your Python interpreter. You should see a window with the title "Hello, PyQt!".

    140 |
  12. 141 |
142 | 143 |

Now you're all set to start developing desktop applications with PyQt using Python. Explore the PyQt documentation and tutorials to create more complex GUI applications.

144 | 145 |
146 | 147 | 148 | 149 |
150 | 151 | ) 152 | } 153 | 154 | export default PYQT -------------------------------------------------------------------------------- /src/Python_Library_Pages/Pandas/Intro-to-Pandas.jsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | 3 | const PandasBasics = () => { 4 | return ( 5 |
6 |

Introduction to Pandas

7 | 8 |

Development can start for Pandas from here

9 |
10 | ); 11 | }; 12 | 13 | export default PandasBasics; -------------------------------------------------------------------------------- /src/Python_Library_Pages/Python_Basics/Intrduction-to-Operators.jsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | 3 | const OperatorsBasics = () => { 4 | return ( 5 |
6 |

Introduction to Operators in Python

7 | 8 |

Development can start for Python from here

9 |
10 | ); 11 | }; 12 | 13 | export default OperatorsBasics; 14 | -------------------------------------------------------------------------------- /src/Python_Library_Pages/Python_Basics/Introduction-to-Functions.jsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | 3 | const FunctionsBasics = () => { 4 | return ( 5 |
6 |

Introduction to Functions in Python

7 | 8 |

Development can start for Python from here

9 |
10 | ); 11 | }; 12 | 13 | export default FunctionsBasics; 14 | -------------------------------------------------------------------------------- /src/Python_Library_Pages/Python_Basics/Introduction-to-Python.jsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | 3 | const PythonBasics = () => { 4 | return ( 5 |
6 | 7 |

1. Introduction to Python

8 |
9 |
 10 |         
 11 |           {`Python is a high-level, interpreted programming language known for its readability and simplicity. It:
 12 |   - Supports multiple programming paradigms.
 13 |   - Has a large standard library.
 14 |   - Python is free and easy to learn.
 15 | 
 16 | This doc will help you to get all the knowledge you want for getting started with Python. 
 17 | If you have never programmed anything before and are just getting started, this might be the blog for you. 
 18 | Python has many use cases in different industries such as
 19 | 
 20 |   Web Development:
 21 |     - Frameworks like Django and Flask make Python a popular choice for building web applications.
 22 | 
 23 |   Data Science and Machine Learning:
 24 |     - Python is extensively used for data analysis, machine learning, and artificial intelligence.
 25 |     - Libraries such as NumPy, Pandas, Scikit-learn, TensorFlow, and PyTorch are widely employed.
 26 | 
 27 |   Finance:
 28 |     - Python is used in finance for quantitative analysis, risk management, and algorithmic trading.
 29 |     - Libraries such as Pandas and NumPy are particularly useful in this domain.
 30 | 
 31 |   Education:
 32 |     - Python is widely used in teaching programming due to its simplicity.
 33 |     - It's often the first language taught in many computer science courses.
 34 | 
 35 |   Game Development:
 36 |     - Python is used in the game development industry, and libraries like Pygame make it 
 37 |       easier to develop 2D games.
 38 | 
 39 |   GIS (Geographic Information System):
 40 |     - Python is used for GIS applications, and libraries like Geopandas and ArcPy are popular 
 41 |       in this field.`}
 42 |         
 43 |       
44 |
45 |
46 | 47 |

2. Setting up Python

48 |

49 |
50 |

For Windows:

51 |

Download Python:

52 |
    53 |
  1. Visit the official Python website at python.org
  2. 54 |
  3. Navigate to the "Downloads" section.
  4. 55 |
  5. Click on the latest version of Python for Windows.
  6. 56 |
57 | 58 |

Run the Installer:

59 |
    60 |
  1. Run the downloaded installer.
  2. 61 |
  3. Check the box that says "Add Python to PATH" during installation.
  4. 62 |
63 | 64 |

Install Python:

65 |
    66 |
  1. Click "Install Now" to start the installation process.
  2. 67 |
  3. The installer will download and install Python on your system.
  4. 68 |
69 | 70 |

Verify Installation:

71 |
    72 |
  1. Open a Command Prompt or PowerShell.
  2. 73 |
  3. Type python --version or python -V and press Enter to verify the installation.
  4. 74 |
75 |
76 |

For macOS:

77 | 78 |

Install Homebrew (if not installed):

79 |
    80 |
  1. Open Terminal.
  2. 81 |
  3. Install Homebrew by following the instructions on the Homebrew website.
  4. 82 |
83 | 84 |

Install Python using Homebrew:

85 |
    86 |
  1. In Terminal, type brew install python and press Enter.
  2. 87 |
88 | 89 |

Verify Installation:

90 |
    91 |
  1. Type python3 --version or python3 -V and press Enter to verify the installation.
  2. 92 |
93 |
94 |

For Linux (Ubuntu/Debian):

95 | 96 |

Update Package List:

97 |
    98 |
  1. Open a terminal.
  2. 99 |
  3. Run sudo apt update to update the package list.
  4. 100 |
101 | 102 |

Install Python:

103 |
    104 |
  1. Run sudo apt install python3 to install Python.
  2. 105 |
106 | 107 |

Verify Installation:

108 |
    109 |
  1. Type python3 --version or python3 -V and press Enter to verify the installation.
  2. 110 |
111 |

112 |
113 |
114 | 115 |

3. Write Your First Program

116 |
117 |

Now that we know the importance and some use-cases of Python, let's jump into the interesting and exciting part that is writing our first program using Python. Don't worry if you are writing a program for the first time; you'll get to know soon. Now let's start our first program!

118 | 119 |

Program 1: Hello World!

120 |
121 |           
122 |             {`print("Hello World!")`}
123 |           
124 |         
125 | 126 |

127 | Explanation: 128 |

129 |
    130 |
  • This is the classic "Hello, World!" program, often used as a first program in many programming languages.
  • 131 |
  • As the name suggests, print() function is used to display the text "Hello, World!" on the screen.
  • 132 |
  • Python is known for its readability and simplicity, and this program demonstrates how concise Python code can be.
  • 133 |
134 | 135 |

136 | To run the programs: 137 |

138 |
    139 |
  1. Install Python: Follow the installation instructions provided earlier according to your operating system.
  2. 140 |
  3. Create Python Files: Open a text editor (VS Code is recommended for beginners), copy and paste the respective program code into the editor.
  4. 141 |
  5. Save and Run: Save the file with a .py extension (e.g., hello_world.py or user_greeting.py). Open a terminal or command prompt, navigate to the directory where you saved the file, and run the program using python filename.py (replace filename with the actual name of your file).
    (Alternate Method) If you are using VS Code, head to Extensions present on the left side of VS Code and type python, install the extension for future use, after this on the top right side you'll notice a play button just click that, your code will be executed
  6. 142 |
143 |

144 | 145 | Output: Hello World! 146 | 147 |

148 |

These programs are basic examples to help you understand the syntax and structure of Python code. As you progress, you can explore more advanced topics, such as data types, control structures, and functions.

149 | 150 |

151 | 152 |

153 |

4. How to Take Input from User in Python

154 |
155 | 156 |

In Python, you can take input from the user using the input() function. Now let's move on and take input from the user. This function reads a line from the user's input and returns it as a string.

157 | 158 |

Example:

159 |
160 |         
161 |           {`user_input = input("Enter something: ")
162 | print("You entered:", user_input)`}
163 |         
164 |       
165 | 166 |

Explanation:

167 |
    168 |
  • In this code, input("Enter something: ") prompts the user to enter something and waits for them to input a value.
  • 169 |
  • The entered value is stored in the variable user_input.
  • 170 |
  • Finally, print("You entered:", user_input) displays the entered value to the user.
  • 171 |
172 | 173 |

You can use the input() function without any argument, but providing a prompt inside the function call makes the user interaction more meaningful.

174 | 175 |

Keep in mind that the input() function always returns a string. If you want to use the input as a number, you'll need to convert it using functions like int() or float() for example:

176 | 177 |

178 | 179 | {`user_input = int(input("Enter an integer: ")) 180 | print("You entered:", user_input)`} 181 |

182 |
183 | 184 |

This code takes an integer as input and converts it to an integer type using int() function.

185 | 186 |

Always be cautious when using user input in your programs, especially if you're expecting a specific type of input. You may want to add error handling to handle cases where the user enters unexpected input.

187 | 188 |

189 | 190 |

5. Python Keywords

191 |
192 |

Keywords in Python are reserved words that have special meanings and cannot be used as identifiers (variable names, function names, etc.). These keywords are part of the Python language syntax and serve specific purposes in the code.

193 |
194 | 195 |

1. False, True, None

196 |
197 |         
198 |           
199 |             {`flag = True
200 | if flag:
201 |       print("The flag is True")`}
202 |           
203 |         
204 |       
205 | 206 |

In this example, True is a Boolean value, and the if statement checks if the condition is True and prints a message. 207 | The same goes as for false.

208 |
209 |

2. and, or, not:

210 |
211 | 212 |

and operator:

213 |
214 |         
215 |           
216 |             {`x = 5
217 | y = 10
218 | if x > 0 and y > 0:
219 | print("Both x and y are greater than 0")`}
220 |           
221 |         
222 |       
223 | 224 |

The and operator is used to combine two conditions. The statement prints a message if both conditions are True.

225 |
226 |

or operator:

227 |
228 |         
229 |           
230 |             {`x = 5
231 | y = 10
232 | if x > 0 or y > 0:
233 |     print("Either x or y is greater than 0")`}
234 |           
235 |         
236 |       
237 |

The or operator is used when either of a condition is true. The statement prints if one statement is True out of both.

238 |
239 |

not operator:

240 |
241 |         
242 |           
243 |             {`x = 5
244 | y = 10
245 | if not (x > 0 and y > 0):
246 |     print("Either x or y is not greater than 0")`}
247 |           
248 |         
249 |       
250 |

The not operator is used to negate the condition inside the if statement. The print statement will be executed if either x or y (or both) is not greater than 0.

251 |
252 |

3. if, else, elif

253 |
254 |         
255 |           
256 |             {`score = 85
257 |   if score >= 90:
258 |       print("A grade")
259 |   elif score >= 80:
260 |       print("B grade")
261 |   else:
262 |       print("C grade")`}
263 |           
264 |         
265 |       
266 | 267 |

If the score is 90 or above, it prints "A grade."
268 | Otherwise, if the score is between 80 and 89 (inclusive), it prints "B grade."
269 | If neither of the above conditions is met, it prints "C grade" as the default grade for scores below 80.
270 | This program uses conditional statements (if, elif, and else) to determine the appropriate grade based on the student's score.

271 |
272 | 273 |

4.break, continue, comment

274 |
275 |

break

276 | 277 |
278 |         
279 |           
280 |             {`print("Example with break:")
281 | for i in range(5):
282 |     if i == 3:
283 |         print("Breaking the loop at i =", i)
284 |         break
285 |     print(i)
286 | `}
287 |           
288 |           
289 | 290 |

Output for break :

291 | 0
292 | 1
293 | 2
294 | Breaking the loop at i = 3
295 |
296 |
297 |
298 |
299 |

break statement is used to terminate the loop when i becomes equal to 3. As a result, the loop is interrupted, and the message is printed.

300 |
301 |

continue

302 | 303 |
304 |         
305 |           
306 |             {`print("\nExample with continue:")                                                 
307 | for i in range(5):
308 |     if i == 2:
309 |         print("Skipping iteration at i =", i)
310 |         continue
311 |     print(i)
312 | `}
313 | 
314 |           
315 |           
316 | 317 |

Output for continue :

318 | 0
319 | 1
320 | Skipping iteration at i = 2
321 | 3
322 | 4
323 |
324 |
325 |
326 |
327 |

continue statement is used to skip the iteration when i is equal to 2. As a result, the print statement inside the loop is bypassed for that specific iteration, and the loop continues with the next iteration.

328 |
329 | 330 |

Comment

331 |
332 |         
333 |           
334 |             # Here '#' is used to add comments for a line, this will not be exceuted / not seen in Output 
335 | print("Hey there!")
336 |
337 |
338 | 339 |
340 | Output : Hey there! 341 |
342 |
343 |
344 | 345 |

5. def, return

346 |
347 |         
348 |           
349 |             {`def add(x, y):
350 |     return x + y
351 | 
352 | result = add(3, 5)
353 | print(result)`}
354 |             

355 | Output : 8 356 |
357 |
358 |
359 | 360 |

Functions are defined using def, and return is used to send a value back to the caller. In this case, a simple add function is defined and called with arguments.

361 | 362 |
363 |

6. import, from, as

364 |
365 |         
366 |           
367 |             {`import math
368 | from math import sqrt as square_root
369 | 
370 | result = square_root(25)`}
371 |             

372 | Output : 5 373 |
374 |
375 |
376 | 377 |

import is used to bring in a module, and from allows you to import specific items. In this example, the sqrt function from the math module is imported and given the alias square_root.

378 |

379 |

6.Some Basic Types of Errors :

380 |
381 |

Syntax Errors :

382 |
383 |         
384 |             # Syntax Error Example 
385 | print("Hello, World!" 386 |
387 |
388 |

These occur when the code violates the syntax rules of the programming language.
The interpreter cannot execute the code if it contains syntax errors.

389 |

390 |

Runtime errors :

391 |
392 |         
393 |           
394 |             # Runtime Error Example (Division by Zero) 
395 | x = 10 / 0 396 | 397 |
398 |
399 |

Also known as exceptions, these errors occur during the execution of the program.
Common examples include division by zero, accessing an undefined variable,
or trying to open a file that does not exist.

400 |
401 |

402 | 403 |

7. Exception Handling

404 |
405 |

Exception is an event or object that occurs during the execution of a program and disrupts the normal flow of instructions.
Exceptions are typically caused by errors in the code or by unexpected conditions that may arise during runtime.
406 | When an exception occurs, the normal flow of the program is halted, and the control is transferred to a special code segment known as an exception handler. 407 | 408 | 409 |

410 |
411 |
412 |         
413 |           

try, except block:

414 | 415 | 416 | # Code that may cause an exception
417 | result = 10 / 0
418 | except ZeroDivisionError:
419 | # Code to handle the ZeroDivisionError
420 | print("Cannot divide by zero.")
421 |
422 |
423 |
424 |

To handle exceptions, the try block is used to enclose the code that might raise an exception,
and the except block is used to define the actions to be taken if a particular exception occurs.

425 |
426 |
427 | 428 |

finally block:

429 |
430 |         try:
431 |           file = open("example.txt", "r") 
432 | # Code to read from the file
433 | finally:
434 | file.close()
435 |
436 |
437 |
438 |

The "finally" block is used to define cleanup actions that must be executed under all circumstances, whether an exception occurred or not.

439 | 440 | 441 |

442 |

8. Classes

443 |
444 |
445 |         
446 |           
447 |             {`class Dog:
448 |     def __init__(self, name, age):
449 |         self.name = name
450 |         self.age = age
451 | 
452 |     def bark(self):
453 |         print("Woof!")
454 | 
455 | # Creating an Object
456 | my_dog = Dog("Buddy", 3)
457 | 
458 | # Accessing Class Members
459 | print("Name:", my_dog.name)
460 | print("Age:", my_dog.age)
461 | 
462 | # Calling a Method
463 | my_dog.bark()`}
464 |           
465 |         
466 |       
467 |

468 | Classes in Python are used for object-oriented programming. In this example, a Dog class is defined with a constructor (__init__) and a method (bark). An object my_dog is created, and its attributes and methods are accessed.

469 | The "Dog" class is a simple representation of a dog with attributes for name and age, and a method to make the dog bark. The object "my_dog" is created from this class, and its attributes are accessed and a method is called to demonstrate the basic principles of object-oriented programming in Python. 470 |

471 |
472 | ); 473 | }; 474 | 475 | export default PythonBasics; -------------------------------------------------------------------------------- /src/Python_Library_Pages/Scikit-Learn/Intro-to-ScikitLearn.jsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thecuriousteam/PyLibLog/4f9d01622f9a78e945afd6b4cd619bc5c3acacc8/src/Python_Library_Pages/Scikit-Learn/Intro-to-ScikitLearn.jsx -------------------------------------------------------------------------------- /src/Python_Library_Pages/Seaborn/Assets/Fig1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thecuriousteam/PyLibLog/4f9d01622f9a78e945afd6b4cd619bc5c3acacc8/src/Python_Library_Pages/Seaborn/Assets/Fig1.png -------------------------------------------------------------------------------- /src/Python_Library_Pages/Seaborn/Assets/Fig2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thecuriousteam/PyLibLog/4f9d01622f9a78e945afd6b4cd619bc5c3acacc8/src/Python_Library_Pages/Seaborn/Assets/Fig2.png -------------------------------------------------------------------------------- /src/Python_Library_Pages/Seaborn/Assets/Fig3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thecuriousteam/PyLibLog/4f9d01622f9a78e945afd6b4cd619bc5c3acacc8/src/Python_Library_Pages/Seaborn/Assets/Fig3.png -------------------------------------------------------------------------------- /src/Python_Library_Pages/Seaborn/Introduction-to-Seaborn.jsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | 3 | const Seaborn = () => { 4 | return ( 5 |
6 |
7 |

Introduction to Seaborn

8 |

9 | Seaborn is a python package that is crucial for information visualization. It is used to make sense of large amounts of data in a straightforward way. 10 |

11 |

12 | What is data visualization? 13 |

14 |

15 | Graphical display of information and data is known as data visualization. 16 | They offer an easy approach to observe and analyze trends, outliers, patterns in information using visual elements such as charts, graphs, mapping. 17 | If the dataset is large, it becomes a hassle to work with. hence to analyze and generate sound judgment, data visualization is used. 18 |

19 |

Key features of Seaborn

20 |
    21 |
  • 22 |   Provides an intuitive and high-level interface for creating complex visualizations with minimal code. This makes it accessible to both beginners and experienced data scientists. 23 |
  • 24 |
  • 25 |   Specializes in visualizing statistical relationships in data. It offers functions for creating informative visualizations that reveal data distributions, relationships, and patterns. 26 |
  • 27 |
  • 28 |   Comes with a variety of attractive themes and color palettes, making it easy to create visually appealing plots and charts. You can quickly change the look and feel of your visualizations to suit your needs. 29 |
  • 30 |
  • 31 |   Seaborn is built on top of Matplotlib, which means you can seamlessly integrate Seaborn with Matplotlib when you need fine-grained control over plot customization. 32 |
  • 33 |
  • 34 |   Excels at visualizing categorical data, allowing you to create informative bar plots, box plots, violin plots, and more. It's particularly useful for comparing data across different categories. 35 |
  • 36 |

37 |
38 | 39 | 40 | {/* Installation Process */} 41 | 42 |
43 |

Installing Seaborn on Windows

44 |

1. Ensure that you have either Python PIP or Conda installed. You can verify your environment using the following commands.

45 |

For PIP users:

46 |
47 |

pip --version

48 |

or

49 |

pip -V

50 |
51 |

For Conda users:

52 |
53 |

conda --version

54 |

or

55 |

conda -V

56 |
57 | 58 |

2. Open command prompt as administrator. Then run the following commands to begin installation.

59 |

For PIP users:

60 |
61 |

pip install seaborn

62 |
63 |

For Conda users:

64 |
65 |

conda install seaborn

66 |
67 | 68 |

3. Finally confirm the installation using these commands into your Python IDE.

69 |
70 |

import seaborn as sns

71 |

sns.__version__

72 |

73 |
74 | 75 | {/* Getting Started with Seaborn */} 76 |
77 |

Getting Started with Seaborn

78 |

79 | In this section, we will implement seaborn on a dataset and plot 3 different types of graphs while also exploring customization options available. 80 |

81 |

1. Import essential libraries

82 |
83 |

import seaborn as sns

84 |

import pandas as pd

85 |

import numpy as np

86 |
87 |

2. Load dataset

88 |

Now that all the necessary dependencies are imported, we can get started with plotting data. 89 | Seaborn comes with 17 datasets which is useful for beginners to work on. 90 | To see the full list of datasets available, use the command: 91 |

92 |
93 |

sns.get_dataset_names()

94 |
95 |

96 | The "tips" dataset is a simple and small dataset that contains information about restaurant tips. It includes the following columns: 97 |

    98 |
  •   'total_bill': This column represents the total bill amount, which includes both the cost of the meal and any additional charges.
  • 99 |
  •   'tip': This column represents the tip amount given by the customer.
  • 100 |
  •   'sex': This column represents the gender of the person paying the bill (e.g., Male or Female).
  • 101 |
  •   'smoker': This column indicates whether the party was a smoker or non-smoker (e.g., Yes or No).
  • 102 |
  •   'day': This column specifies the day of the week.
  • 103 |
  •   'time': This column indicates whether it was lunch or dinner.
  • 104 |
  •   'size': This column represents the size of the party (i.e., the number of people in the group).
  • 105 |
106 |

107 |

We will use the following commands to display the first 5 rows of the dataset.

108 |
109 |

tips_df = sns.load_dataset("titanic")

110 |

tips_df.head()

111 |
112 |

3. Scatter Plot

113 |

114 | A scatter plot is a type of graphical representation used in statistics and data analysis to display the relationship between two variables. 115 | It is especially useful for visualizing the distribution and patterns of data points in a two-dimensional space. 116 |

117 |
118 |

sns.scatterplot(x="tip", y="total_bill", data=tips_df, hue="day", size="size", palette="YlGnBu")

119 |
120 |

Let us explore the parameters: 121 |

    122 |
  •   'x': Specifies the x axis. In this case, the 'tip' column is chosen.
  • 123 |
  •   'y': Specifies the y axis. In this case, the 'total' column is chosen.
  • 124 |
  •   'data': Specifies the dataframe which was initialized as 'tips_df'.
  • 125 |
  •   'hue': Groups various points into different colours according to 'days' column.
  • 126 |
  •   'size': Grouping variable that will produce points with different sizes
  • 127 |
  •   'palette': Specifies the theme of the plot, in this case we have gone with Yellow Blue Green.
  • 128 |
129 |

130 |
131 | Scatter plot of tips vs total tips received 132 |
133 |

Fig 1. Scatterplot with seaborn

134 |

135 | The executed code should display a plot similar to Fig 1. We can infer how the tips from customers change depending on the total bill. 136 | Additionally, the tips are sorted according to four different colours for each day while the size of the circle indicates the number of people in that customer group. 137 |

138 |

4. Histograms

139 |

140 | A histogram is a graphical representation of the distribution of a dataset, showing the frequency or count of data points within specific intervals also known as 'bins'. 141 |

142 |
143 |

sns.histplot(x="tip", data=tips_df, kde=False, bins=15)

144 |
145 |

146 | Let us explore the parameters: 147 |

    148 |
  •   'x': Specifies the x axis. In this case, the 'tip' column is chosen.
  • 149 |
  •   'data': Specifies the dataframe which was initialized as 'tips_df'.
  • 150 |
  •   'kde': KDE stands for Kernel Density Estimate. It is a smoothed, continuous version of a histogram, providing a more detailed representation of the data distribution.
  • 151 |
  •   'bins': Specifies the intervals of grouping the tips received which totals upto 15.
  • 152 |
153 |

154 |
155 | Histogram displaying the frequency of receiving tips 156 |
157 |

Fig 2. Histogram with seaborn

158 |

159 | The executed code should display a plot similar to Fig 2. We can infer how the frequenctly a particular amount is received by a waiter. 160 |

161 |

5. Bar Plot

162 |

163 | A barplot is a way to create a bar chart to visualize the relationship between a categorical variable and a numeric variable. For example, we can use this plot to compare the number of males vs the number of females who give tips. 164 |

165 |
166 |

sns.barplot(x="sex", y="tip", data=tips_df, palette="OrRd")

167 |
168 |

Let us explore the parameters: 169 |

    170 |
  •   'x': Specifies the x axis. In this case, the 'sex' column is chosen.
  • 171 |
  •   'y': Specifies the y axis. In this case, the 'total' column is chosen.
  • 172 |
  •   'palette': Specifies the theme of the plot, in this case we have gone with Orange Red.
  • 173 |
174 |

175 |
176 | Bar plot of tips vs total tips received 177 |
178 |

Fig 3. Bar plot with seaborn

179 |

180 | The executed code should display a plot similar to Fig 3. According to the graph, male customers give larger tips than their female counterparts. 181 | The mean of male customer tips is slightly greater than 3 compared to female customers which is around 2.8. 182 |

183 |
184 |
185 | ) 186 | } 187 | 188 | export default Seaborn -------------------------------------------------------------------------------- /src/Python_Library_Pages/TensorFlow/Introduction-to-tensorFlow.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | 3 | const TensorFlow = () => { 4 | return ( 5 |
6 |
7 |

Introduction-to-tensorFlow

8 |

9 | TensorFlow is a popular open-source machine learning framework developed by Google. It has gained widespread adoption in the machine learning and deep learning communities. 10 |


11 |

12 | TensorFlow makes it easy for beginners and experts to create machine learning models for desktop, mobile, web, and cloud. 13 |


14 |

15 | TensorFlow is an end-to-end platform for machine learning. It supports the following: 16 |


17 |
    18 |
  • 19 |   Multidimensional-array based numeric computation. 20 |
  • 21 |
  • 22 |   GPU and distributed processing 23 |
  • 24 |
  • 25 |  Automatic differentiation 26 |
  • 27 |
  • 28 |  Model construction, training, and export 29 |
  • 30 |
  • 31 |  And more... 32 |
  • 33 |

34 |

Let's break down the key concepts step by step:

35 |

1. Machine Learning:

36 |

37 | Machine learning is a subfield of artificial intelligence (AI) that focuses on creating algorithms that can learn from and make predictions or decisions based on data. These algorithms can improve their performance over time with more data and experience. 38 |

39 |

2. Tensors:

40 |

41 | ensors are like multi-dimensional arrays, and they can have various ranks. For instance, a scalar (single number) is a rank-0 tensor, a vector (e.g., an array of numbers) is a rank-1 tensor, and a matrix is a rank-2 tensor. Tensors are at the core of TensorFlow, and most data in machine learning is represented as tensors. 42 |


43 |

3. Scalability:

44 |

45 | TensorFlow is like a super versatile tool that can teach computers and make them smart. It can work on regular computers (CPUs), super-fast graphics cards (GPUs), and even special machines called TPUs, which are like rocket boosters for learning. This means you can use TensorFlow for both small and big projects, and it will be quick and efficient. 46 |

47 |
48 |

4. Nodes and Graphs:

49 |

50 | In TensorFlow, computations are represented as a directed graph. This graph is made up of nodes (also called operations or ops) and edges. Nodes are operations that perform computations on tensors. For example, you might have nodes for addition, multiplication, or matrix operations. 51 |


52 |

5. Session:

53 |

54 | To execute operations in a TensorFlow graph, you need to create a session. The session allocates resources and performs the computations. This is where the "magic" happens, as it evaluates the operations in the graph and produces results. 55 |


56 |

6. Variables and Placeholders:

57 |

58 | In machine learning, you often need to work with parameters that change during training (like the weights of a neural network). TensorFlow provides the concept of variables to represent these changing parameters. Placeholders, on the other hand, are used to feed data into the model. 59 |


60 |

7. Neural Networks:

61 |

62 | Neural networks are a class of machine learning models inspired by the structure of the human brain. They consist of layers of interconnected nodes (neurons) that process and transform data to make predictions or decisions. 63 |


64 |

8. Deep Learning:

65 |

66 | Deep learning is a subfield of machine learning that focuses on using deep neural networks, typically with multiple hidden layers. TensorFlow is particularly well-suited for building and training deep neural networks. 67 |


68 |

9. Training:

69 |

70 | Training a model in TensorFlow involves feeding it a dataset, making predictions, calculating how wrong those predictions are, and then adjusting the model's parameters to make better predictions. This process is typically done through backpropagation and optimization algorithms. 71 |


72 |

10.Libraries and APIs:

73 |

74 | TensorFlow provides high-level APIs (like Keras) that make it easier to build and train machine learning models. These APIs abstract away many of the complexities, making it more accessible for beginners. 75 |


76 |

11.Community and Resources:

77 |

78 | TensorFlow has a large and active community with plenty of tutorials, documentation, and resources to help you learn and solve problems. 79 |


80 |

12.Use Cases:

81 |

82 | TensorFlow is used in a wide range of applications, including image and speech recognition, natural language processing, recommendation systems, and more. It's not limited to any specific domain and can be applied to various real-world problems. 83 |

84 |
85 | {/* getting started with TensorFlow */} 86 |
87 |

Install TensorFlow With pip


88 |

Before Installation of TensorFlow You need to set up Your Python .

89 |

90 |
91 |

For Windows:

92 |

Download Python:

93 |
    94 |
  1. Visit the official Python website at python.org
  2. 95 |
  3. Navigate to the "Downloads" section.
  4. 96 |
  5. Click on the latest version of Python for Windows.
  6. 97 |
98 | 99 |

Run the Installer:

100 |
    101 |
  1. Run the downloaded installer.
  2. 102 |
  3. Check the box that says "Add Python to PATH" during installation.
  4. 103 |
104 | 105 |

Install Python:

106 |
    107 |
  1. Click "Install Now" to start the installation process.
  2. 108 |
  3. The installer will download and install Python on your system.
  4. 109 |
110 | 111 |

Verify Installation:

112 |
    113 |
  1. Open a Command Prompt or PowerShell.
  2. 114 |
  3. Type python --version or python -V and press Enter to verify the installation.
  4. 115 |
116 |


117 |

Installation of TensorFlow :

118 |

119 | TensorFlow is a popular machine learning library developed by Google. 120 |

121 |

122 | We'll go through the steps for installing it on different operating systems. I'll assume you have a system that meets the requirements you provided. 123 |

124 |
125 |

126 | 1. Installing on Ubuntu:


127 |

128 | Note: Make sure your system is up to date: 129 |

130 |

For installation of tensorFlow Open cmd (cammand prompt) and type following cammand...

131 |
132 |

pip install tensorflow

133 |
134 |
135 |

136 | 2. Installing on Windows:


137 |

138 | Note: Make sure your system is up to date: 139 |

140 |
141 |

pip install tensorflow

142 |
143 |
144 |

3. Installing on macOS:

145 |
146 |

pip install tensorflow

147 |
148 |

NOTE: Cammand is same for every OS Only what you need to check is your python version .

149 |
150 | 151 | {/* Tensors */} 152 |
153 |

Introduction to Tensors

154 |

155 | In TensorFlow, a tensor is a fundamental data structure that represents multi-dimensional arrays. Tensors are the primary building blocks for constructing and manipulating machine learning models. They can be thought of as generalizations of matrices and can have various dimensions, including scalars, vectors, matrices, and higher-dimensional arrays. 156 |

157 |

Here's an overview of tensors in TensorFlow:


158 |

1.   Scalars:


159 |

160 | Tensors of rank 0 are scalars. They have no dimensions and represent single values. In TensorFlow, you can create a scalar tensor like this: 161 |


162 |
163 |

import tensorflow as tf

164 |

scalar_tensor = tf.constant(5)

165 |
166 |
167 |

2.   Vector:


168 |

169 | Tensors of rank 1 are vectors. They have one dimension and can be considered as an array of values. 170 |


171 |
172 |

vector_tensor = tf.constant([1, 2, 3, 4, 5])

173 |

174 |
175 |

3.   Matrices::


176 |

177 | Tensors of rank 2 are matrices. They have two dimensions, representing rows and columns. For example: 178 |


179 |
180 |

matrix_tensor = tf.constant([[1, 2, 3], [4, 5, 6]])

181 |
182 |
183 |

4.   Higher-Dimensional Tensors:


184 |

185 | Tensors can have more than two dimensions. For instance, a rank-3 tensor could represent a cube of values, and a rank-4 tensor could represent a hyperspace. 186 |


187 |
188 |

rank_3_tensor = tf.constant([[[1, 2], [3, 4]], [[5, 6], [7, 8]]])

189 |

rank_4_tensor = tf.constant([[[[1, 2], [3, 4]], [[5, 6], [7, 8]]], [[[9, 10], [11, 12]], [[13, 14], [15, 16]]]])

190 |

191 |
192 |

5.   Data Types:


193 |

194 | Tensors can hold data of different types, such as tf.float32, tf.int32, and more. You can specify the data type when creating a tensor. 195 |


196 |
197 |

float_tensor = tf.constant(3.14, dtype=tf.float32)

198 |

int_tensor = tf.constant(42, dtype=tf.int32)

199 |
200 |
201 |

6.   Tensor Operations:


202 |

203 | TensorFlow provides a wide range of operations to manipulate tensors, including element-wise operations, matrix operations, and more complex operations for building and training machine learning models. 204 |


205 |
206 |

tensor_a = tf.constant([1, 2, 3])

207 |

tensor_b = tf.constant([4, 5, 6])

208 |

result_tensor = tf.add(tensor_a, tensor_b)

209 |

210 |
211 |

7.   Shape:


212 |

213 | The shape of a tensor describes its dimensions. You can access the shape of a tensor using the .shape attribute. 214 |


215 |
216 |

shape = tensor_a.shape # Returns the shape of tensor_a

217 |
218 |
219 |

8.   Reshaping:


220 |

221 | You can change the shape of a tensor using the tf.reshape function. This is useful when you need to convert a tensor from one shape to another. 222 |


223 |
224 |

reshaped_tensor = tf.reshape(matrix_tensor, [3, 2]) # Reshapes a 2x3 matrix to a 3x2 matrix

225 |
226 |
227 |

9.   TensorFlow Constants and Variables:


228 |

229 | You can create tensors using tf.constant for constant values, and tf.Variable for mutable tensors that can be updated during training. 230 |


231 |
232 |

constant_tensor = tf.constant([1, 2, 3])

233 |

variable_tensor = tf.Variable([4, 5, 6])

234 |
235 |
236 | {/* Variables */} 237 |
238 |

Introduction to Variables

239 |

240 | TensorFlow variables are a fundamental part of deep learning and machine learning models. They serve as containers for storing and managing the model's learnable parameters, which are iteratively updated during training to minimize the loss function and improve the model's performance. TensorFlow's efficient memory management, automatic differentiation, and device placement capabilities make it a powerful framework for handling variables and optimizing model training. 241 |


242 |

Here's a detailed explanation of TensorFlow variables:


243 |

1. Import TensorFlow :

244 |

Import TensorFlow: To use TensorFlow, you need to import it at the beginning of your Python script or notebook. 245 |

246 |
247 |

import tensorflow as tf

249 |
250 |
251 |

2. Creating Variables:

252 |

253 | To create a TensorFlow variable, you can use the tf.Variable() constructor. You typically initialize variables with initial values 254 |

255 |
256 |

initial_value = tf.constant([1.0, 2.0, 3.0])

257 |

my_variable = tf.Variable(initial_value)

258 |
259 |
260 |

3. Variable Initialization:

261 |

262 | Variables need to be explicitly initialized using tf.global_variables_initializer() before they can be used in a TensorFlow session. However, in modern versions of TensorFlow (2.x and later), you can often skip this step, as variable initialization is handled automatically. 263 |

264 |
265 |

4. Variable Update:

266 |

267 | Variables are typically updated during training to optimize a model's parameters. You can use operations like assign() and assign_add() to change the value of a variable. 268 |

269 |
270 |

updated_value = my_variable.assign([4.0, 5.0, 6.0])

271 |
272 |
273 |

5. Variable Collections:

274 |

275 | TensorFlow allows you to group variables into collections. This can be helpful when saving or loading models. You can add variables to collections using `tf.add_to_collection()`. 276 |

277 |
278 |

tf.add_to_collection('my_variables', my_variable)

279 |
280 |
281 |

6. Saving and Restoring Variables:

282 |

283 | You can save and restore variables using TensorFlow's `tf.train.Saver`. This is useful for checkpointing your model's progress during training and for deploying trained models. 284 |

285 |
286 |

saver = tf.train.Saver()

287 |

saver.save(sess, "my_model.ckpt")

288 | # Later, restore the model 289 |

saver.restore(sess, "my_model.ckpt")

290 |
291 |
292 |

7. Device Placement:

293 |

294 | You can specify where you want to place a variable, either on a CPU or a GPU. This can be done using the `device` argument when creating the variable. 295 |

296 |
297 |

with tf.device('/gpu:0'):

298 |

gpu_variable = tf.Variable([1.0, 2.0, 3.0])

299 |
300 |
301 |

8. Variable Scopes:

302 |

303 | You can use variable scopes to organize variables and manage their names. This can help with debugging and readability. 304 |

305 |
306 |

with tf.variable_scope('my_scope'):

307 |

scoped_variable = tf.Variable(0.0)

308 |
309 |
310 |

9. Eager Execution:

311 |

312 | In TensorFlow 2.x, eager execution is enabled by default, which means you can manipulate variables just like any other Python objects without the need for a session. Eager execution makes TensorFlow code more intuitive and Pythonic. 313 |

314 |
315 |

tf.config.run_functions_eagerly(True) # Eager execution is enabled by default in TF 2.x

316 |
317 |
318 |

10. Resource Management:

319 |

320 | TensorFlow Variables are tracked as resource objects and have built-in memory management and device placement. 321 |

322 |
323 |

with tf.device('/gpu:0'):

324 |

var = tf.Variable(0.0)

325 |
326 |
327 |
328 | 329 | ) 330 | } 331 | 332 | export default TensorFlow -------------------------------------------------------------------------------- /src/Python_Library_Pages/Tkinter/Introduction-to-tkinter.jsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | 3 | const TkinterIntro = () => { 4 | return ( 5 |
6 |
7 |

Introduction to Tkinter

8 |

9 | Tkinter ("Tk Interface")is python's standard cross-platform package 10 | for creating graphical user interfaces (GUIs). Tkinter's greatest 11 | strength is its ubiquity and simplicity. It works out of the box on 12 | most platforms (linux, OSX, Windows). 13 |

14 |
15 |

16 | Tkinter is lightweight and relatively painless to use compared to 17 | other frameworks. This makes it a compelling choice for building GUI 18 | applications in Python, especially for applications where a modern 19 | sheen is unnecessary, and the top priority is to quickly build 20 | something that’s functional and cross-platform. 21 |

22 |
23 |
24 |
25 |
26 |
27 |

Create First GUI Application using Tkinter

28 |

29 | Developing desktop based applications with python Tkinter is not a 30 | complex task. An empty Tkinter top-level window can be created by 31 | using the following steps. 32 |

33 |
34 |
    35 |
  1. 36 | import the Tkinter module. 37 | 38 |
    39 |

    import tkinter as tk

    40 |

    41 |
  2. 42 |
  3. 43 | Create an instance of the Tk class which represents the main window. 44 |
    45 |

    window = tk.Tk()

    46 |

    47 |
  4. 48 |
  5. 49 | Now that you have a window, you can add a widget. Use the tk.Label 50 | class to add some text to a window. 51 |
    52 |

    greeting = tk.Label(text="Hello, PyLibLog")

    53 |
    54 |

    55 | We will learn about some more widgets like buttons, frames, etc. 56 | in the next section.. 57 |


    58 |
  6. 59 |
  7. 60 | Use the mainloop method to run your application. 61 |
    62 |

    window.mainloop()

    63 |

    64 |
  8. 65 |
66 |
67 |
68 |
69 |
70 |
71 |

Tkinter Widgets

72 |

Widget is an element of Graphical User Interface (GUI) that displays/illustrates information or gives a way for the user to interact with the OS. In Tkinter , Widgets are objects ; instances of classes that represent buttons, frames, and so on. Each separate widget is a Python object. When creating a widget, you must pass its parent as a parameter to the widget creation function. The only exception is the “root” window, which is the top-level window that will contain everything else and it does not have a parent.


73 |
74 | 75 | 76 | 77 | 78 | 79 |
80 | 81 | 82 | 83 | 84 |
85 | 86 | 87 | 92 | 93 |
94 | 95 | 96 | 99 | 100 |
101 | 102 | 103 | 107 | 108 |
109 | 110 | 111 | 115 | 116 |
117 | 118 | 119 | 124 | 125 |
126 | 127 | 128 | 132 | 133 |
134 | 135 | 136 | 140 | 141 |
142 | 143 | 144 | 148 | 149 |
WidgetDescription
LabelA Widget used to display text on the screen.
Button 88 | {" "} 89 | A button that can contain text and can perform an action when 90 | clicked. 91 |
Entry 97 | A text entry widget that allows only a single line of text 98 |
Frame 104 | A rectangular region used to group related widgets or provide 105 | padding between widgets 106 |
Checkbutton 112 | The Checkbutton is used to display the CheckButton on the 113 | window. 114 |
Radiobutton 120 | The Radiobutton is different from a checkbutton. Here, the user 121 | is provided with various options and the user can select only 122 | one option among them. 123 |
Scrollbar 129 | It provides the scrollbar to the user so that the user can 130 | scroll the window up and down. 131 |
MessageBox 137 | This module is used to display the message-box in the desktop 138 | based applications. 139 |
ListBox 145 | The ListBox widget is used to display a list of options to the 146 | user. 147 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |

Tkinter Geometry

157 |

158 | The Tkinter geometry specifies the method by using which, the widgets 159 | are represented on display. The python Tkinter provides the following 160 | geometry methods. 161 |

162 |
    163 |
  •   The pack() method
  • 164 |
  •   The grid() method
  • 165 |
  •   The place() method
  • 166 |


167 |

pack() method

168 |

169 | The pack() widget is used to organize widget in the block. The 170 | positions widgets added to the python application using the pack() 171 | method can be controlled by using the various options specified in the 172 | method call. 173 |

174 |
175 |

widget.pack(options)

176 |
177 |
178 |

179 | A list of possible options that can be passed in pack() is given 180 | below. 181 |

182 |
    183 |
  •   184 | expand If the expand is set to true, the widget expands to fill any 185 | space. 186 |
  • 187 |
  •   188 | Fill By default, the fill is set to NONE. However, we can set it to 189 | X or Y to determine whether the widget contains any extra space. 190 |
  • 191 |
  •   192 | size it represents the side of the parent to which the widget is to 193 | be placed on the window. 194 |
  • 195 |
196 |
197 |
198 |

grid() widget

199 |

200 | The grid() geometry manager organizes the widgets in the tabular form. 201 | We can specify the rows and columns as the options in the method call. 202 | We can also specify the column span (width) or rowspan(height) of a 203 | widget. 204 |

205 |
206 |

widget.grid(options)

207 |
208 |
209 |

210 | A list of possible options that can be passed inside the grid() method 211 | is given below. 212 |

213 |
    214 |
  •   215 | Column 216 | The column number in which the widget is to be placed. The leftmost 217 | column is represented by 0. 218 |
  • 219 |
  •   220 | Columnspan 221 | The width of the widget. It represents the number of columns up to 222 | which, the column is expanded. 223 |
  • 224 |
  •   225 | ipadx, ipady 226 | It represents the number of pixels to pad the widget inside the 227 | widget's border. 228 |
  • 229 |
  •   230 | padx, pady 231 | It represents the number of pixels to pad the widget outside the 232 | widget's border. 233 |
  • 234 |
  •   235 | row 236 | The row number in which the widget is to be placed. The topmost row 237 | is represented by 0. 238 |
  • 239 |
  •   240 | rowspan 241 | The height of the widget, i.e. the number of the row up to which the 242 | widget is expanded. 243 |
  • 244 |
  •   245 | Sticky 246 | If the cell is larger than a widget, then sticky is used to specify 247 | the position of the widget inside the cell. It may be the 248 | concatenation of the sticky letters representing the position of the 249 | widget. It may be N, E, W, S, NE, NW, NS, EW, ES. 250 |
  • 251 |
252 |
253 |
254 |

place() method

255 |

The place() geometry manager organizes the widgets to the specific x and y coordinates. 256 |

257 |
258 |

widget.place(options)

259 |

260 |

A list of possible options is given below.

261 |
    262 |
  •   263 | Anchor It represents the exact position of the widget within the container. The default value (direction) is NW (the upper left corner) 264 |
  • 265 |
  •   266 | bordermode The default value of the border type is INSIDE that refers to ignore the parent's inside the border. The other option is OUTSIDE. 267 |
  • 268 |
  •   269 | height, width It refers to the height and width in pixels. 270 |
  • 271 |
  •   272 | relheight, relwidth It is represented as the float between 0.0 and 1.0 indicating the fraction of the parent's height and width. 273 |
  • 274 |
  •   275 | relx, rely It is represented as the float between 0.0 and 1.0 that is the offset in the horizontal and vertical direction. 276 |
  • 277 |
  •   278 | x, y It refers to the horizontal and vertical offset in the pixels. 279 |
  • 280 |
281 |
282 |
283 | ); 284 | }; 285 | 286 | export default TkinterIntro; 287 | -------------------------------------------------------------------------------- /src/index.css: -------------------------------------------------------------------------------- 1 | @import url("https://fonts.googleapis.com/css2?family=Montserrat:wght@100;200;300;400;500;600;700;800&family=Play:wght@700&display=swap"); 2 | @import url('https://fonts.googleapis.com/css2?family=Poppins&family=Work+Sans&display=swap'); 3 | @tailwind base; 4 | @tailwind components; 5 | @tailwind utilities; 6 | 7 | @layer base { 8 | html { 9 | /* @apply font-Montserrat; */ 10 | font-family: "Work Sans", "Helvetica", "Tahoma", "Geneva", "Arial", sans-serif; 11 | } 12 | body { 13 | background: #f1f1f1; 14 | letter-spacing: 0.5px; 15 | } 16 | h1 { 17 | @apply text-xl font-medium capitalize; 18 | } 19 | } 20 | 21 | .link { 22 | @apply p-2.5 flex rounded-md gap-6 items-center md:cursor-pointer cursor-default duration-300 font-medium; 23 | } 24 | 25 | .active { 26 | @apply bg-blue-100 text-blue-600; 27 | } 28 | -------------------------------------------------------------------------------- /src/layouts/RootLayout.jsx: -------------------------------------------------------------------------------- 1 | import Sidebar from "./sidebar"; 2 | 3 | function RootLayout({ children }) { 4 | return ( 5 |
6 | 7 |
{children}
8 |
9 | ); 10 | } 11 | 12 | export default RootLayout; 13 | -------------------------------------------------------------------------------- /src/layouts/sidebar/SubMenu.jsx: -------------------------------------------------------------------------------- 1 | import { useState } from "react"; 2 | import { motion } from "framer-motion"; 3 | import { BiCaretDown } from "react-icons/bi"; 4 | import { NavLink, useLocation } from "react-router-dom"; 5 | 6 | const SubMenu = ({ data }) => { 7 | const { pathname } = useLocation(); 8 | const [subMenuOpen, setSubMenuOpen] = useState(false); 9 | const childrenCount = data.children?.length || 0; 10 | return ( 11 | <> 12 |
  • setSubMenuOpen(!subMenuOpen)} 15 | > 16 |

    {data.title}

    17 | 18 |
  • 19 | 20 | 35 | {data.children?.map((child, i) => ( 36 |
  • 42 | 46 | {child.title} 47 | 48 |
  • 49 | ))} 50 |
    51 | 52 | ); 53 | }; 54 | 55 | export default SubMenu; 56 | -------------------------------------------------------------------------------- /src/layouts/sidebar/index.jsx: -------------------------------------------------------------------------------- 1 | import { useEffect, useState } from "react"; 2 | import { useRef } from "react"; 3 | import SubMenu from "./SubMenu"; 4 | import { motion } from "framer-motion"; 5 | import { Link } from "react-router-dom"; 6 | 7 | import { useMediaQuery } from "react-responsive"; 8 | import { MdMenu } from "react-icons/md"; 9 | 10 | import { useLocation } from "react-router-dom"; 11 | import { subMenusList } from "../../Constants"; 12 | import Search from "../../Components/Search"; 13 | 14 | const Sidebar = () => { 15 | let isTabletMid = useMediaQuery({ query: "(max-width: 768px)" }); 16 | const [open, setOpen] = useState(isTabletMid ? false : true); 17 | const sidebarRef = useRef(); 18 | const { pathname } = useLocation(); 19 | 20 | useEffect(() => { 21 | if (isTabletMid) { 22 | setOpen(false); 23 | } else { 24 | setOpen(true); 25 | } 26 | }, [isTabletMid]); 27 | 28 | useEffect(() => { 29 | isTabletMid && setOpen(false); 30 | }, [pathname]); 31 | 32 | const Nav_animation = isTabletMid 33 | ? { 34 | open: { 35 | x: 0, 36 | width: "16rem", 37 | transition: { 38 | damping: 40, 39 | }, 40 | }, 41 | closed: { 42 | x: -250, 43 | width: 0, 44 | transition: { 45 | damping: 40, 46 | delay: 0.15, 47 | }, 48 | }, 49 | } 50 | : { 51 | open: { 52 | width: "24rem", 53 | transition: { 54 | damping: 40, 55 | }, 56 | }, 57 | closed: { 58 | width: "4rem", 59 | transition: { 60 | damping: 40, 61 | }, 62 | }, 63 | }; 64 | 65 | return ( 66 |
    67 |
    setOpen(false)} 69 | className={`md:hidden fixed inset-0 max-h-screen z-[998] bg-black/50 ${open ? "block" : "hidden" 70 | } `} 71 | >
    72 | 81 |
    82 | {/* */} 87 | 88 |

    92 | PyLibLog 93 |

    94 | 95 | 96 |
    97 | 98 | 99 |
    100 |
    101 | 102 | 105 | 106 |
    107 | 108 | 109 |
      113 | {(open || isTabletMid) && ( 114 |
      115 | 116 | {subMenusList?.map((data, i) => ( 117 |
      125 | 126 |
      127 | ))} 128 |
      129 | )} 130 |
    131 | 132 | {open && ( 133 |
    134 |
    135 |
    136 |

    PyLibLog

    137 | From The Curious Community 138 |
    139 | {/*

    140 | Upgrade 141 |

    */} 142 |
    143 |
    144 | )} 145 |
    146 | { 148 | setOpen(!open); 149 | }} 150 | animate={ 151 | open 152 | ? { 153 | x: 0, 154 | y: 0, 155 | rotate: 0, 156 | } 157 | : { 158 | x: -10, 159 | y: -200, 160 | rotate: 180, 161 | } 162 | } 163 | transition={{ duration: 0 }} 164 | className="absolute w-fit h-fit md:block z-50 hidden right-2 bottom-3 cursor-pointer" 165 | > 166 | 167 | 168 |
    169 |
    setOpen(true)}> 170 | 171 |
    172 |
    173 | ); 174 | }; 175 | 176 | export default Sidebar; 177 | -------------------------------------------------------------------------------- /src/main.jsx: -------------------------------------------------------------------------------- 1 | import { StrictMode } from "react"; 2 | import ReactDOM from "react-dom/client"; 3 | import { BrowserRouter } from "react-router-dom"; 4 | import App from "./App"; 5 | import "./index.css"; 6 | ReactDOM.createRoot(document.getElementById("root")).render( 7 | 8 | 9 | 10 | 11 | 12 | ); 13 | -------------------------------------------------------------------------------- /tailwind.config.cjs: -------------------------------------------------------------------------------- 1 | /** @type {import('tailwindcss').Config} */ 2 | module.exports = { 3 | content: ["./index.html", "./src/**/*.{js,ts,jsx,tsx}"], 4 | theme: { 5 | extend: { 6 | fontFamily: { 7 | Montserrat: "Montserrat", 8 | }, 9 | colors:{ 10 | 'custom-purple' : '#9004FC' 11 | } 12 | }, 13 | }, 14 | plugins: [require("tailwind-scrollbar")], 15 | }; 16 | -------------------------------------------------------------------------------- /vite.config.js: -------------------------------------------------------------------------------- 1 | import { defineConfig } from "vite"; 2 | import react from "@vitejs/plugin-react"; 3 | 4 | // https://vitejs.dev/config/ 5 | export default defineConfig({ 6 | plugins: [react()], 7 | server: { 8 | host: true, 9 | watch: { 10 | usePolling: true, 11 | }, 12 | }, 13 | }); 14 | --------------------------------------------------------------------------------