Basics of Python | Python for beginners

0
213

What is Python?

Python is an interpreted, high-level, object-oriented and general-purpose programming language. The meaning of the 3 important words mentioned in the definition is

  1. Interpreted: goes through an interpreter, which turns code you write into the machine language.
  2. high-level: enable the programmer to write programs that are more or less independent of a particular type of computer.
  3. object-oriented: object-oriented programming (OOP) is a programming language model organized around objects rather than “actions” and data rather than logic.
  4. general-purpose: It can be used in various domains like data science, Artificial intelligence(AI), Machine-learning, etc.

Keywords, variables and expression in python

Keywords: Keywords are reserved words in python. In Python, keywords are case sensitive. We cannot use the keyword as a variable name and function. Only True, False and None start with a capital letter.

and         del       from        not       while    
as           elif       global      or        with     
assert     else      if             pass     yield    
break     except   import     print              
class      exec      in           raise              
continue  finally   is           return             
def          for       lambda   try

Variable:

A variable is a named location used to store data in the memory. Variables are a bucket that holds data that can be changed later in the program. A variable should not contain any special character except underscore(_).

Expression:

Expression statements are used to compute and write a value, or to call a procedure. Python expressions consist of identifiers, literals, and operators.

a)Identifiers: Any name used to define a class, function, variable module, or object is an identifier. 

b)Literals: These are language-independent terms in Python. Python literals are categories as string literals, byte literals, integer literals, floatingpoint literals, and imaginary literals. 

c)Operators: In Python, the operators are:

OperatorOperation
+Addition
Substraction
/Division
**Square
%Modulo operator(remainder)
<,>greater than, less than

Precedence of operation:

1)Parenthesis

2)Power

3)Division

4)Multiplication

5)Addition

6)Left to right

Why python is preferred?

a)In python user don’t need to define the type of variable

b)the time required to write code is less

c)Easy to learn

d)Used in various applications.