fbpx

Introduction to Python | Learn python programming for beginners Free

4.9
(26)

Python is the Object Oriented Programming language to model and implement the real world entities. It is dynamically typed language which carries out the type checking at run time. Python is an interpreted language which executes programs one instruction at a time.

Python History:

Designed in the late 1980s by Guido van Rossum. Developed and released in 1991 by Python Software Foundation. While derived many good features of ABC the predecessor language, Python Overcome many bugs in ABC Inspiration of the name Python came from a popular BBC TV show “Monty Python’s Flying Circus”. The cut short version of this name became “Python”.

Introduction To Python | Python Programming For Beginners

Python features:

  • Simple and Easy
  • Interpreted Language
  • Platform Independent and portable
  • Open source and Free
  • Object Oriented
  • Extensive libraries
  • Integrated
  • Database connectivity

How to Download and Install Python

Download and Installation Process

Installation of Python in your system requires following steps to be completed:

  1. Visit https://www.python.org/downloads/ and download the latest version of Python suitable for your Windows version. Installation is as easy and similar as any other software in Windows.
  2. Run the downloaded file which makes the Python installation wizard appear on the screen.
  3. Click “Install now”.
  4. Accept the default settings and wait until the installation finish.

In order to check Python is already installed on your system:

  1. Open a command prompt window (press Windows+R, type in cmd, and hit enter).
  2. Just type “python” on the command line and see if you get an error or not.
  3. If you see a response from a Python interpreter it will include a version number in its initial display.

Success, now you can start programming on Python ..

Setting environment variable:

To run Python from command prompt, it is necessary to change the default environment variables in Windows. For the temporary setting of environment variables open command prompt and use the set command.

 C:>set PATH=C:Program FilesPython 3.6;%PATH%

Python modes of operations:

There are two modes of Python programming:

  1. Interactive mode
  2. Scripting mode

Interactive mode:

  • It is the quick way of executing the Python code.
  • Python instructions are executed as commands in the command prompt provided in the Python Shell.
  • Python interpreter executes every statement independently and returns the result Interactive mode is handy and useful for the beginners of the Python.

Invoking Python Shell:

The following are the steps to be followed to invoke Python shell:

  • Search in the task bar Python and select Python 3.8(64 bit) or Search IDLE and select IDLE 3.8(64 bit)
  • When a prompt >>> appears in the IDLE screen the IDLE is in interactive mode and is ready to accept instructions.
  • Enter the Python statements in after the prompt and press “Enter” in the keyboard.
  • Python interpreter executes the command and returns the result.
  • If there is an error in the statement IDLE reports the error immediately.

Learn C Programming in Hindi

Scripting mode:

  • Scripting mode is otherwise called as batch mode
  • A group of Python statements written in a file in anyone of these editors or IDEs.
  • Editors:
    • Notepad
    • Notepad++
    • editPlus
    • nano
    • gedit
    • IDLE Etc..
  • IDEs:
    • pycharm
    • Eric
    • Eclipse
    • Netbeans Etc..
  • Save the file with extension “py” (.py)
  • Execute the Run command in the IDE and get the result in the output screen.

Hello World Program

First Python program:

Writing a program to print “Hello world” on the screen is so simple in Python comparing to other programming languages like C,C++ or Java. Python doesn’t require the formalities of writing main function. The following are the steps to write a simple Python program in IDLE to print “Hello world” on the screen:

  • Open Python IDLE.
  • Select New File option from File menu.
  • A new untitled Python file opens.
  • Write the statement in Python to print “Hello world” on the screen.

Example

1
print("Hello world")
  • Click Run Module in the Run menu.
  • Click Ok in the Save Before Run or Check dialog box.
  • Type a relevant file name in the appearing Save As dialog box and click Save button.
  • See the output “Hello world” printed on the screen.

What is Comments

Comments:

Comments are the statements in Python code to give description about the components of the code. Python code with comments is more readable. The comments are not involving in the execution of the code.

There are two types of comments:

  1. Single line comment
  2. Multiline comment

Single line comment:

Single line comments in Python Starts with #. Python interpreter will skip the statements which starts with # and not involving them in execution.

Example

1
#First Python program 
 print("Hello world") 

Output:

Hello world

Multiline comment:

Python does not have any special syntax for multiline comments. To include multiline comments, add # at the beginning of every line.

Example

 
1
2
3
4
#First Python porgram
#Python version 3.8.3
#IDE-Pycharm
print("Hello world")

Output:

Hello world

I hope You like this post Introduction to Python | Learn python programming for beginners Free

How useful was this post?

Click on a star to rate it!

Average rating 4.9 / 5. Vote count: 26

No votes so far! Be the first to rate this post.

As you found this post useful...

Follow us on social media!

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?

Leave a Reply