A Readable, Dynamic,
Pleasant, Flexible, Fast
And Powerful Language.
Introduction
Why Python
Overview Syntax
Comments
Variables
What is Python?
Python is a popular programming language. It was
created by Guido van Rossum, and released in 1991.
It is used for:
• Web development (server-side),
• Software development,
• Mathematics,
• System scripting.
Why Python?
Works on different platforms
Has a simple syntax similar to the English language.
Can be treated in a procedural way, an object-oriented way
or a functional way.
What can Python do?
It can be used on a server to create web applications.
To create workflows.
To connect database systems.
To read and modify files.
To handle big data and perform complex mathematics.
Installation Check
To check if you have python installed on Windows PC,run the
following command line in start bar (cmd.exe)
C:\Users\Your Name>python --version
To check on a Linux or Mac, then on Linux open the command
line on Mac open the terminal and type:
python --version
If you do not have installed , you can download it free from
https://www.python.org/
Get Started
The way to run a python file on the command line:
C:\Users\Your Name>python hell0world.py
helloworld.py is the name of python file can be done in text editor.
helloworld.py
print(“Hello,world”)
Save and run your file on command line.
C:\Users\Your Name>python helloworld.py
Here is output: Hello,World!
Python Syntax
Indentation refers to the spaces at the beginning of a code line.
Python uses indentation to indicate a block of code.
if 5 > 2:
print("Five is greater than two!")
Python will give you an error if you skip the indentation
Syntax error:
if 5 > 2:
print("Five is greater than two!")
Comments can be used to explain Python code.
Comments start with # ,Python will ignore while
execution.
#This is a comment
print(“Hello world”)
Comments Comments does not have to be text that explain code
Can also used to prevent execution when testing code.
#print(“Hello World”)
Print(“Cheers”)
Python does not have syntax for multi line comments,
insert # for each line to add multi line comment
Variables
Variables are containers for storing data values.
A variable is created the moment you first assign a value to
it,there is no command to declare.
x = 5
y = "John"
print(x)
print(y)
Data type of a variable can be done with casting.
x = str(3) # x will be '3’
y = int(3) # y will be 3
z = float(3) # z will be 3.0
Variables
Variable names are case-sensitive.
String variables can be declared either by using single or
double quotes,
Can get the type of variable with the type() function.
x=5
print(type(x))
Queries
Thank you