This document provides an overview of the Python programming language. It describes Python as a popular programming language created by Guido van Rossum in 1991. Python can be used for web development, software development, mathematics, and system scripting. The document discusses why Python is useful due to its simple syntax, ability to work on different platforms, and because it can be treated procedurally, object-orientedly, or functionally. It also provides examples of tasks Python can perform like creating web applications, databases, workflows, and handling big data. The document concludes by covering Python syntax, variables, comments, and how to install and run a Python file.
3. 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.
What is Python?
4. 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.
5. 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.
What can Python do?
6. To check if you have python installed on Windows PC,run the
following command line in start bar (cmd.exe)
C:UsersYour 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/
Installation Check
7. The way to run a python file on the command line:
C:UsersYour 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:UsersYour Name>python helloworld.py
Here is output: Hello,World!
Get Started
8. 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!")
Python Syntax
9. Comments
Comments can be used to explain Python code.
Comments start with # ,Python will ignore while
execution.
#This is a comment
print(“Hello world”)
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
10. 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
11. 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))
Variables