Python

What is Python?

Python

Python 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 a wide range of applications such as Web development, Mathematical and Graphics User Interface.


Python is very easy to learn and understandable among all the computer languages.

Its syntax is very simple to write and read the programming coding.


Computer Applications and Programme that use Python

  • Google
  • YouTube
  • FaceBook
  • 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 length 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


Python Commands

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 numbers list)

min (find the minimum number from 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 reserve 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
  • print
  • raise
  • return
  • try
  • while

Constant using in Python

e = 2.7182818…..

pi = 3.1415926….


Whitespaces

We use \ to go to next line in python


How to Add comments in Python

#This is a comment line


Typing coding in the 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

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

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

Operator Uses Example
and Both conditions should be true a<80 and a>70
or Anyone 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

Operator Uses Example
is same values for variables a is b
is not values are not the same a is not b

 

Spread the love
Rana Mehtab Alam Lunar Computer College.