Home Show/Hide Menu
PYTHON TOPICS
➜ Introduction
➜ How to start
➜ Syntax
➜ Simple programs
➜ comment lines
➜ Assigning Values
➜ Dynamic Typing
➜ Input / Output
➜ Character Set
➜ Tokens
➜ Variables
➜ Operators
➜ Literals
➜ Numbers
➜ Type casting
➜ Strings
  - Python Strings
  - Format Strings
  - Slicing Strings
  - Modify Strings
  - String Concatenation 
  - Escape Characters
  - String Methods
➜ Booleans
➜ Lists
  - Access List Items
  - Change List Items
  - Add List Items
  - Remove List Items
  - List using Loop
  - List Comprehension
  - Sort Lists
  - Copy Lists
  - Join Lists
  - List Methods
➜ Tuples
  - Access Tuples
  - Update Tuples
  - Unpack Tuples
  - Tuples using Loops
  - Join Tuples
  - Tuples Methods
➜ Sets
  - Access Set Items
  - Add Set Items
  - Remove Set Items
  - Loop Sets
  - Join Sets
  - Set Methods
➜ Dictionaries
  - Access Items
  - Change Items
  - Add Items
  - Remove Items
  - Loop Dictionaries
  - Copy Dictionaries
  - Nested Dictionaries
  - Dictionaries Methods
➜ if...else
➜ For Loops
➜ While Loops
➜ Lambda
➜ Arrays
➜ Class / Objects
➜ Inheritance
➜ Iterators
➜ Scope
➜ Modules
➜ Dates
➜ Maths
➜ JSON
➜ RegEx
➜ PIP
➜ Try...Except
➜ User Input
➜ File Handling
  - File Handling
  - Read Files
  - Write/Create Files
  - Delete Files
➜ Python Modules
  - NumPy Tutorial
  - Pandas Tutorial
  - SciPy Tutorial
➜ Python Matplotlib
  - Intro
  - Get Started
  - Pyplot
  - Plotting
  - Markers
  - Line
  - Labels
  - Grid
  - Subplots
  - Scatter
  - Bars
  - Histograms
  - Pie Charts
➜ Machine Learning
  - Getting Started
  - Mean Median Mode
  - Standard Deviation
  - Percentile
  - Data Distribution
  - Normal Data Distribution
  - Scatter Plot
  - Linear Regression
  - Polynomial Regression
  - Multiple Regression
  - Scale
  - Train/Test
  - Decision Tree
➜ Python MySQL
  - Get Started
  - Create Database
  - Create Table
  - Insert
  - Select
  - Where
  - Order By
  - Delete
  - Drop Table
  - Update
  - Limit
  - Join
➜ Python MongoDB
  - Get Started
  - Create Database
  - Create Collection
  - Insert
  - Find
  - Query
  - Sort
  - Delete
  - Drop Collection
  - Update
  - Limit
➜ Python Reference
  - Python Overview
  - Python Built-in Functions
  - Python String Methods
  - Python List Methods
  - Python Dictionary Methods
  - Python Tuple Methods
  - Python Set Methods
  - Python File Methods
  - Python Keywords
  - Python Exceptions
  - Python Glossary
➜ Module Reference
  - Random Module
  - Requests Module
  - Statistics Module
  - Math Module
  - cMath Module
➜ Python How To
  - Remove List Duplicates
  - Reverse a String
  - Add Two Numbers
➜ Python Examples
  - Python Examples
  - Python Compiler
  - Python Exercises
  - Python Quiz
  - Python Certificate

How to start


Download and Install Python

Python works on Linux, Mac, Windows, and several other platforms. It comes preinstalled on macOS and on most Linux distributions. However, if you want to be up to date, then you probably need to download and install the latest version. You also have the choice of using different Python versions in different projects if you want to.

Installing Python From Binaries

Regardless of your operating system, you can download an appropriate version of Python from the official site. Go there and grab the appropriate 32-bit or 64-bit version for your operating system and processor.
Selecting and downloading a Python binary from the language's official site is often a good choice. However, there are some OS-specific alternatives:

  • macOS : You have the option of installing Python from Homebrew.
  • Linux : You can install several Python versions using your distribution's package manager.
  • Windows : You can install Python from the Microsoft Store.

You can also use the Anaconda distribution to install Python along with a rich set of packages and libraries, or you can use Miniconda if you want to install only the packages you need.


Working in Interactive Mode

You can do a quick test to ensure Python is installed correctly. Fire up your terminal or command line and run the python3 command. That should open a Python interactive session, and your command prompt should look similar to this:
While you're here, you might as well run your first line of code:



>>> print("HELLO")
HELLO
>>>

That's it! You've just written your first Python program! When you're done, you can use exit() or quit() to leave the interactive session, or you can use the following key combinations:

  • - macOS and Linux: Ctrl+D
  • - Windows: Ctrl+D and then press Enter

Working Python in Windows

To work in interactive mode follow the process given below:
i.  Click start button ⇨ All Programs ⇨ Python 3.7.4 ⇨ IDLE(Python GUI).
      OR
    Click Start button ⇨ All Programs ⇨ Python 3.7.4 ⇨ Python (command line).

Interactive commands and their output in Python Shell

Working in Script Mode (Python IDLE)

  • Interactive mode does not save the commands entered by you in the form of a program.
  • The output is sandwiched bet ween the command lines.

To save the program in a file you have to write your program in a script mode and save it in a file.
To create Module / script / Program File

  1. Click Start button ⇨ All Programs ⇨ Python 3.7.4 ⇨ IDLE
  2. Click File ⇨ New in IDLE Python Shell.
  3. In the New window that opens, type commands you want to save in the form of a program.
  4. Click File ⇨ Save and then save the file with an extension .py.
  5. To execute the program Click on Run ⇨ Run Module command. Or press F5 key.



ADVERTISEMENT