Basics of Python

Basics of Python Programming.

Python is an interpreted, interactive, and object-oriented and high-level programming language. It was created by Guido van Rossum 1985. python uses English keywords frequently and processed at runtime by the interpreter. Python is easy to learn, easy to read, and easy to maintain so let us start some basics of python programming.

Python is a widely-used programming language and there are various important applications of python include desktop applications, image processing applications, game-related apps, computational applications, scientific apps, operating systems, etc.

Python is a widely-used programming language in the field of machine learning and artificial intelligence and it is an open-source programming language that is developed using a community-based model and It can run on Windows and Linux environments so Let us take a deep dive for Basics of Python programming.

How to install python in Windows Operating System.

Download the latest version of python from the below link.
https://www.python.org/downloads/release/python-374/

C:\>python
'python' is not recognized as an internal or external command,
operable program or batch file.

Add a system environment variable for python


right-click on my computer and select an advanced system setting and just click on the environment variable button and define a new variable inside the system variable.

Basics of Python

Now add the path of your python directory inside path variable,just mark; at the last value and define your path like;c:\PYTHON34

C:>python --version 
Python 3.4.3

Keywords in python programming.

python keywords.

Identation in python.

Indentation  is spaces that are used at the beginning of any statement. The statements with the same indentation belong to the same block.

if True:
print(“we are learning python”)
else:
print(“wrong indentation”)

Error: expecting Identation
Solution:

if True:
    print(” we are learning python “)
else:
    print(“right indentation”)

Finally, we can say that space==INDENT in python programming.

if True:
     print (“I am going to execute”)
print (“True”)
else:
print (“I will print if TRUE is FALSE”)
print (“False”)

ERROR:
if True:
    print (” I am going to execute “)
    print (“True”)
else:
    print (” I will print if TRUE is FALSE “)
    print (“This is the wrong indent”)

 

Multiline Statement in python

x=”I am one”
y=”I am two”
z=”I am three”
sum = x + \
y + \
z
print(sum)

Multiple Assignment in Python.

a = b = c = 100
a,b,c = 100,200,”movies”

 

Python Data Types

 

  • Numbers
  • String
  • List
  • Tuple
  • Dictionary

EXAMPLE :- How to create a python List.

data = [“one”, “two”, “three”, “four”, “five”] #python List
print(data[1:4])
print(data[ : 3])
print(data[-4:])
print(data[-3:-1])

Dictionaries in Python.

Dictionaries is a data structure in python,it is different way to reprsent a record as an object that is more generally known as an associative array. dictionary consists of a collection of key-value pairs. Each key-value pair maps the key to its value.

In this example “name” is a key and “john” is value and contact is again a key and [“8800383838″,”9989767870″,”6534568345”] is a value that is a python list.

student={
“name”:”Jhon”,
“age”:22,
“email”:”[email protected]”,
“contact”:[“8800383838″,”9989767870″,”6534568345”]
}

print(type(student))
print(student)
student[“email”]=”[email protected]
print(student)
y=student[“contact”]
print(type(y))

Tuples in Python.

Tuples are immutable and collection of objects which means you cannot change the values of tuple objects(values inside tuple).

x=(“red”,”green”,”blue”,”yellow”)
print(type(x))
print(x)
print(x[3])

DELETE A TUPE IN PYTHON

x=(“red”,”green”,”blue”,”yellow”)
print(type(x))
print(x)
del x #use del keyword to delete any tuple.
print(x)

THANK YOU.