Python is a cross platform, general purpose, high level, dynamic and interpreted programming language. As per google trend 2016, Python is the second most popular Programming(scripting) Language just next to Java. Python has been ranked as “Programming language of the year twice, in the year 2007 and in 2010”. Since the year 2003, Python has always remained in the list of Top Ten most popular programming languages. It was designed by Guido van Rossum 25 years ago on February 20, 1991. Python was the successor of programming language ABC and was able to handle exceptions.

My  Environment 

screenshot-from-2016-09-18-14-54-59

Lets   try to  play   with some variables in Python

  1. Set the variable my_variable equal to the value 10.
  2. Print the Variable

 

 

screenshot-from-2016-09-18-14-30-58

Booleans  : 

You just stored a number in a variable. Numbers are one data type we use in programming. A second data type is called a boolean.

A boolean is like a light switch. It can only have two values. Just like a light switch can only be on or off, a boolean can only be True or False.

Like  this  code  :

Reassigning Variables

You can change the value of a variable by “reassigning” it, like this frpm 1 to 4 :

Whitespace  in Python 

In Python, whitespace is used to structure code. Whitespace is important, so you have to be careful with how you use it.

Lets  try  to  run this  code :

The code is  correct  globally is corect .  but if you dont put  with good space . it  will fail .  please  see the  example  bellow

screenshot-from-2016-09-18-14-52-09

Multi-Line Comments:

The # sign will only comment out a single line. While you could write a multi-line comment, starting each line with #, that can be a pain.

Instead, for multi-line comments, you can include the whole block in a set of triple quotation marks:  ¨¨¨    ¨¨¨

Basic  Math  in Python

lets  make  this  small  exrcise

a = 25

b =  5

Python Strings

Strings are the most popular type in Python. We can create them simply by enclosing characters in quotes. please note Python treats single quotes the same as double quotes.
Creating strings is assigning a value to a variable. lets give some examples

This  is how   the  code look  like :

 

Let me run   the code

chmod +x Python script  file  & ./script.py

screenshot-from-2016-09-19-22-24-14

Python Lists

How  the  Python list  is  separated  from Python string

In the  Python list  , you have a large  non related  data separated    by commas and enclosed within square brackets ([]).

Example

screenshot-from-2016-09-19-22-45-10

Python Tuples

you can call call read only Python list .  the  values  are  inlosed with  () instead  of  []

screenshot-from-2016-09-19-22-53-15

Python  programming language is very  big and  very flexible, , maybe we  missed many things in this  tutorials  . your feedback  is very  important  to us. so that  we  can give more good example  for  this programming language

 

 

SHARE
Linux Engineer, born in Morocco, living in Amsterdam. with large knowledge of TUX and opensource. am Working with Linux from very long time , i have created this blog to serve people. please join us

LEAVE A REPLY

Please enter your comment!
Please enter your name here