Final PYTHON NOTES
Final PYTHON NOTES
Easy to Learn
It has a very simple syntax.
It is case -sensitive language
It is platform independent programming
language
It is free to use and even free for commercial
products.
Integrated Development Environment
An IDE is a comprehensive software that contains the tools to
write, compile, debug the code and display the output.
Each programming language have exclusive IDEs that can be used
for writing lines of code.
There are IDEs that can be installed on a computer, as well as the
ones that can be accessed on the web.
The IDE used for Python is known as IDLE.
Script Mode:
In script mode, you write your Python code in a file with a .py
extension using a text editor.
You save the file and then execute it using the Python interpreter.
This mode is suitable for writing longer programs and reusing
code.
Example:
Input Command
The input() command/function is used to receive user input in
Python. It displays a prompt to the user and waits for input.
The input is stored as a string, so you might need to convert it to
the desired data type.
Example:
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
Python Variables
A variable is a named memory location where we can store any
value.
You can assign the same value to multiple variables in one line.
Variable names are case-sensitive (age, Age and AGE are three
different variables)
They are used to define the syntax and structure of the Python
language In Python, keywords are case sensitive.
In Python, Data Types are essential building blocks that enable developers
to create flexible and efficient applications. Python offers a rich set of built-
in Data Types catering to various data representations and computations.
You can get the data type of a variable with the type() function.
Integer: Integers are whole numbers, both positive and negative, without
any fractional part.
Eg : x = 10 y = -25 z=0
Float: Floats are numbers with decimal points, enabling the representation
of real numbers. They are used for more precise mathematical
calculations, including scientific and financial computations.
Arithmetic Operators:
They are used to perform arithmetical operations on the
operands.
+ Addition - Subtraction * Multiplication
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.
Concatenation
Combining a string, text or the other data in a series without any
gaps is known as concatenation. To display both text and variables
in same line, we can concatenate them using comma.
Eg : print (“ My name is”, name)