Teachnique
      CourseRoadmaps
      Login

      OverviewCommentsUser InputNumbersBooleansHistoryHello World ProgramEnvironment SetupSyntaxVariablesData TypesType CastingUnicode SystemLiteralsOperators

      Control FlowBreak StatementContinue StatementPass StatementNested LoopsDecision MakingIf StatementIf-else StatementNested IF StatementMatch-Case StatementLoopsFor LoopsFor-else LoopsWhile Loops

      FunctionsBuilt-in FunctionsDefault ArgumentsKeyword ArgumentsKeyword-Only ArgumentsPositional ArgumentsPositional-Only ArgumentsArbitrary ArgumentsVariable ScopeFunction AnnotationsModules

      StringSlicing StringsModify StringsString ConcatenationString FormattingEscape CharactersString MethodsString Exercises

      ListsList ExercisesAccess List ItemsChange List ItemsAdd List ItemsRemove List ItemsLoop ListsList ComprehensionSort ListsCopy ListsJoin ListsList Methods

      TuplesAccess Tuple ItemsUpdate TuplesUnpack Tuple ItemsLoop TuplesJoin TuplesTuple MethodsTuple Exercises

      SetsAccess Set ItemsAdd Set ItemsRemove Set ItemsLoop SetsJoin SetsCopy SetsSet OperatorsSet MethodsSet Exercises

      DictionariesDictionary ExercisesAccess Dictionary ItemsChange Dictionary ItemsAdd Dictionary ItemsRemove Dictionary ItemsDictionary View ObjectsLoop DictionariesCopy DictionariesNested DictionariesDictionary Methods

      ArraysAccess Array ItemsAdd Array ItemsRemove Array ItemsLoop ArraysCopy ArraysReverse ArraysSort ArraysJoin ArraysArray MethodsArray Exercises

      File HandlingWrite to FileRead FilesRenaming and Deleting FilesDirectoriesFile Methods

      OOP ConceptsDynamic BindingDynamic TypingAbstractionObject and ClassesEncapsulationInterfacesPackagesInner ClassesAnonymous Class and ObjectsSingleton ClassWrapper ClassesEnumsReflectionClass AttributesClass MethodsStatic MethodsConstructorsAccess ModifiersInheritancePolymorphismMethod OverridingMethod Overloading

      Feedback

      Submit request if you have any questions.

      Course
      Environment Setup

      Python Tutorial

      This Python tutorial has been written for the beginners to help them understand the basic to advanced concepts of Python Programming Language. After completing this tutorial, you will find yourself at a great level of expertise in Python, from where you can take yourself to the next levels to become a world class Software Engineer.

      Environment Setup

      First step in the journey of learning Python is to install it on your machine. Today most computer machines, especially having Linux OS, have Python pre-installed. However, it may not be the latest version.
      Python is available on a wide variety of platforms including Linux and Mac OS X. Let's understand how to set up our Python environment.

      Windows

      1. Download Python: Go to the official Python website (python.org) and download the latest version of Python for Windows. Choose the executable installer.
      1. Install Python:
      1. Run the downloaded executable.
      1. Check the box next to "Add Python X.X to PATH" at the bottom of the installation window (X.X refers to the version number).
      1. Click on "Install Now".
      1. Verify Installation:
      1. Open Command Prompt (cmd).
      1. Type python --version and press Enter. You should see the Python version number if the installation was successful.
      1. Install pip (Python's package manager): Pip is included with Python versions 3.4 and later, but if for some reason it's not installed, you can install it by downloading get-pip.py from the official pip website and running it using Python.
      1. Setting up a Virtual Environment:
      1. In Command Prompt, navigate to your project directory.
      1. Run python -m venv myenv (replace "myenv" with your desired environment name).
      1. Activate the environment:On Windows, run myenv\Scripts\activate.

      macOS

      1. Install Python:
      2. Python 2.7 comes pre-installed on macOS, but it's recommended to use Python 3.
      3. You can install Python 3 via Homebrew (a package manager for macOS). If you don't have Homebrew installed, you can install it by running /bin/bash -c “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)” in the Terminal.
      4. After installing Homebrew, run brew install python .
      5. Verify Installation:
      6. Open Terminal and type python3 --version to verify Python 3 is installed.
      7. Install pip:
      8. Pip is included with Python 3 installations from Homebrew.
      9. Setting up a Virtual Environment:
      10. In Terminal, navigate to your project directory.
      11. Run python3 -m venv myenv.
      12. Activate the environment by running source myenv/bin/activate.

      Linux

      1. Install Python:
      2. Most Linux distributions come with Python pre-installed. You can verify this by typing python3 --version in the Terminal.
      3. If Python is not installed, you can install it using your distribution's package manager. For example, on Ubuntu or Debian, run sudo apt-get update followed by sudo apt-get install python3.
      4. Verify Installation:
      5. Type python3 --version in the Terminal to verify the installation.
      6. Install pip:
      7. If pip is not installed, you can install it by running sudo apt-get install python3-pip (on Ubuntu/Debian).
      8. Setting up a Virtual Environment:
      9. Navigate to your project directory in the Terminal.
      10. Run python3 -m venv myenv.
      11. Activate the environment by running source myenv/bin/activate.
      
      For all systems, once you have your virtual environment activated, you can use pip to install Python packages locally within the environment (e.g., pip install package_name). This setup ensures that your project's dependencies are isolated from the system-wide Python environment.