Home Tutorials Python Tutorials Python Complete Series – 02

Python Complete Series – 02

Learn Python Complete Series.

Lecture 2: Outline

  • Python Installation
  • Command line
  • Python’s Syntax
  • Indentation
  • Variables

Python Installation:

Many PCs (personal computers) and Mac(s) have python already installed, you can check it by self.

Check whether it is installed on your computer Windows PC(s), go to the ‘SEARCH’ bar in the windows start menu or type the following text on the cmd (cmd.exe):

C:\Users\you’rname>python –version

While checking on “Linux” or “Mac,” systems open the command line for Linux and on Mac open the Terminal to see the status. Type the following text in a command line:

Python –version

In this way, you can check the installed version of Python on Windows, Linux, or Mac OS (operating system).

If there is no version installed on your system, you can get it quickly from Python’s site. Download and install it in your pc: www.python.org

Click here for all tutorials of Python Series

 

Let’s quick start:

As we know, Python works as on interpreter; it is an interpreted programming language. In simple words, as a user or developer, you type Python [.py] files in a text editor and then put this whole code into the Python’s interpreter to run or execute code for the desired output.

C:\Users\you’rname>python hellooworld.py

Above is the name of python file where .py is the extension for Python.

Let’s start our first python file named hellooworld.py

print(‘’Hello, World|‘’):

First, save your file then open it in cmd and press enter. Here you see the Hello World is the output of written code command.

Finally, you have done your first program.

The Command-Line:

There is an easy and quick way to write or test a short piece of code instead of writing code in a file. It can also be run in (cmd) command line.

Type the following command on Windows, Mac OS, or Linux PC’s.

drive:\Users \You’re name>python

In case “python” command didn’t work, try” py”

C:\Users \You’re name>py

Here you could write any code line program.

Here you can see the Hello, World|.

When you complete the task, simply close it by the following exit command.

exit()

Python’s Syntax:

As we see in the previous that Python syntax can be executed by writing directly in the Command Line:

Just create the .py name file extension and run it in the command line.

Python’s Indentation:

The “Indentation” is the space(s) used at the start or beginning of line codes.

In other programming languages, the indentation of code is only for clear readability, but in Python it is so important and useful while writing code.

Indentation indicates the block of code.

Example

See the Syntax Error below;

You will get an error if you skip the “indentation.”

It’s all up to you to add any number of spaces, but at least one space should be added to it.

One more thing uses the same number of spaces in the same block of code. Otherwise, Python will give an error, look below;

Syntax error, because spaces are not the same as the same block of code. You have to use the same spaces on the same block.

Python’s Variables:

Variables can store the value, are created when you assign a value to it.

When assigning a value, you need to create a variable first, then allocate value to it.

Here x and y are variables that store the values. X has the value of 5 and y stores Hello, World|. This python series will enable you to become an expert.

Also, visit the official site of Python, here.

eskort - web tasarım - werbung -

https://www.vozolkapida.com/

Exit mobile version