Learning Python : Day 1
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.
What can Python do?
Python can be used on a server to create web applications.
Python can be used alongside software to create workflows.
Python can connect to database systems. It can also read and modify files.
Python can be used to handle big data and perform complex mathematics.
Python can be used for rapid prototyping, or for production-ready software development.
Why Python?
Python works on different platforms (Windows, Mac, Linux, Raspberry Pi, etc).
Python has a simple syntax similar to the English language.
Python has syntax that allows developers to write programs with fewer lines than some other programming languages.
Python runs on an interpreter system, meaning that code can be executed as soon as it is written. This means that prototyping can be very quick.
Python can be treated in a procedural way, an object-oriented way or a functional way
Download Python.......
$ You can direct download python latest version as per your system requirement (windows/ Mac Os / Linux/ Raspberry pi).
$ other option is to download anaconda latest version as per your system and configure it in your PC by skip the registration process.
Your First Python Program -
Let's write your first Python file, called helloworld.py, which can be done in any text editor.
print("Hello, World!")
$ Let's Run the program and knock on the door of Python world.
Execute Python Syntax
As we learned in the previous page, Python syntax can be executed by writing directly in the Command Line:
\>>> print("Hello, World!")
Hello, World!
Python Indentation
Indentation refers to the spaces at the beginning of a code line.
Where in other programming languages the indentation in code is for readability only, the indentation in Python is very important.
Python uses indentation to indicate a block of code.
Example:
if 5 > 2:
print("Five is greater than two!")
Python Comments
Comments can be used to explain Python code.
Comments can be used to make the code more readable.
Comments can be used to prevent execution when testing code.
Comments starts with a #
, and Python will ignore them:
Download the latest version of Python according to your system requirements (Windows, Mac OS, Linux, Raspberry Pi).
Another option is to download the latest version of Anaconda for your system and configure it on your PC, skipping the registration process.
Your First Python Program
Let's write your first Python file, called helloworld.py, which can be done in any text editor.
print("Hello, World!")
Let's run the program and step into the world of Python.
Execute Python Syntax
As we learned earlier, Python syntax can be executed by writing directly in the Command Line:
>>> print("Hello, World!")
Hello, World!
Python Indentation
Indentation refers to the spaces at the beginning of a code line.
In other programming languages, indentation is for readability only, but in Python, it is very important.
Python uses indentation to indicate a block of code.
Example:
if 5 > 2:
print("Five is greater than two!")
Python Comments
Comments can be used to explain Python code.
Comments can make the code more readable.
Comments can prevent execution when testing code.
Comments start with a #
, and Python will ignore them:
# This is a comment
Python does not really have a syntax for multiline comments.
To add a multiline comment you could insert a #
for each line:
Example
#This is a Your First Python Program
Let's write your first Python file, called helloworld.py
, which can be done in any text editor.
print("Hello, World!")
Let's run the program and step into the world of Python.
Execute Python Syntax
As we learned earlier, Python syntax can be executed by writing directly in the Command Line:
>>> print("Hello, World!")
Hello, World!
Python Indentation
Indentation refers to the spaces at the beginning of a code line.
In other programming languages, indentation is for readability only, but in Python, it is very important.
Python uses indentation to indicate a block of code.
Example:
if 5 > 2:
print("Five is greater than two!")
Python Comments
Comments can be used to explain Python code.
Comments can make the code more readable.
Comments can prevent execution when testing code.
Comments start with a #
, and Python will ignore them:
# This is a comment
Python does not really have a syntax for multiline comments.
To add a multiline comment you could insert a #
for each line:
Example:
# This is a
# multiline
# comment Or, not quite as intended, you can use a multiline string.
Since Python will ignore string literals that are not assigned to a variable, you can add a multiline string (triple quotes) in your code, and place your comment inside it:
Example
"""
This is a comment
written in
more than just one line
"""
print("Hello, World!")