What is Python?
Python is a high-level easy use computer programming language.
It is the most powerful object-oriented, high-level computer programming language for making any programme by Guido van Rossum.
It is a general-purpose computer programming language. It has many applications, including web development and a mathematical and graphic user interface.
The language Python is very easy to learn and understandable among all computer languages.
Its syntax is very simple to write and read the programming coding.
Computer Applications and Programme that use Python
- YouTube
- IBM
- Netflix
- Firefox
- NASA
- DropBox
Features of the Python
- Free where and shareware
- Object-Oriented
- Easy to learn and understand
- It is easy to portable.
- Executable in any Operating System
- High-Level Interpreted Language
- Large Standard Libraries
- Codes lengths are shorts
Data Types and Variables
Integers (Numbers)
x = (23)
Float (Decimals)
x=(34.56)
Strings
m =(“Rana Mehtab Alam”)
Multi Variables
m, n = (8, 9)
Commands in Python
abs (Get output in absolute value)
ceil (round up the numeric value as 9.6 = 10)
cos (cosine in radians)
floor (round down the numeric value)
log (logarithm, base e)
log10 (logarithm, base 10)
sqrt (find the square root of a numeric value)
round (round up the decimal values to the nearest as 1.2 = 1 and 1.9 = 2)
sin (sine, in radians)
max (find the maximum number from the numbers list)
min (find the minimum number from the numbers list)
Rules of typing commands and defining variables.
Python is a case-sensitive software so we type commands and use variables in lowercase.
There is a list of reserved words in Python that we can’t use in the variables.
- and
- assert
- break
- class
- continue
- def
- del
- elif
- else
- except
- exec
- finally
- for
- from
- global
- if
- import
- in
- is
- lambda
- not
- or
- pass
- raise
- return
- try
- while
Constant
e = 2.7182818…..
pi = 3.1415926….
How to change the line in Python?
Whitespaces
We use \ to go to the next line in python
Comments in python
#This is a comment line
Typing coding in Python
print (“Rana Mehtab Alam Lunar Computer College”)
Output
Rana Mehtab Alam Lunar Computer College
a = (“Rana”)
print (a)
Output
Rana
Arithmetic Operators
Operator | Name | Example |
+ | Addition | a + b |
– | Subtraction | a – b |
* | Multiplication | a * b |
/ | Division | a / b |
% | Modulus | a % b |
** | Exponentiation | a ** b |
// | Floor Division | a // b |
Assignment Operators for python
Operator | Example | Same As |
= | a = 9 | a = 9 |
+= | a += 6 | a = a + 6 |
-= | a -= 2 | a = a – 2 |
*= | a *= 8 | a = a * 8 |
&= | a & = 7 | a = a & 7 |
>>= | a >> 3 | a = a >> 3 |
<<= | a << 1 | a = a << 1 |
Comparison Operators for python
Operator | Name | Example |
== | Equal | a == b |
!= | Not Equal | a != b |
< | Less Than | a < b |
> | Greater Than | a > b |
<= | Lesser and Equal | a <= b |
>= | Greater and Equal | a >= b |
Logical Operators for Python
Operator | Uses | Example |
and | Both conditions should be true | a<80 and a>70 |
or | Anyone’s condition should be true | a<80 or a>70 |
not | Returns false if the result is true | not(a<80 and a>70) |
Identity Operators for Python
Operator | Uses | Example |
is | same values for variables | a is b |
is not | values are not the same | a is not b |
How to type the first code and save it in Python?
print (“Welcome to the first code for Python”)
to save in Python it is compulsory to type .py at the end of the file name suppose if you want to type the file name abc then you will type abc.py