Python basics

                        Python Basics-

Introduction to python-

  1. Python is a Simple programming language.
  2. It is free & open source
  3. It is a High level programming language.
  4. Developed by Gudio van Rossum.
  5. It is portable on all Operating systems.

Python Character Set-

  1. Letters ( A-Z and a-z) means it is case sensitive languages in python Uppercase and Lowercase letters are different.
  2. Digits (0-9).
  3. Special symbols  (- + * / etc.)
  4. White spaces (blank Space, tab, Carriage return, newline, form feed.)
  5. Other character set - Python can access all ASCII and UNICODE characters .

Variables-

A variable is a name given to a memory location in a program. Meaning of variable is that its value can change (Vary).

Memory-

In memory of the Computer there would be a place of variables inside the memory and the value will be stored inside a variable.

example-
a=2

in mathematics a=2 (the value of a is equal to 2 but in Programming it means that the 2 is stored inside the variable a.)



Rules for Identifiers-

  1. Identifiers can be combination of Uppercase  and lowercase letters, digits, or an Underscore(_)
  2. An Identifier can not start with digit. So while Variable1 is valid ,  1Variable is not valid as a variable name. 
  3. We can not use special symbols like (!, #, @,%,$ etc.)
  4. identifier can be of any length. 

Variables name should be:

  • Simple
  • Short
  • Meaningful

                                            Data Types




Main Data types in python are-

  • Integers- (+ve, -ve, (negative infinity to positive infinity)) int
  • Strings - (names, sentences, paragraphs) str " ", ' ', ''' '''.
  • Float- (Decimal Values - 1.2, 2.0, 34.5)
  • Boolean-(True and False.)
  • None- Where we do not want to store any kind of value.


Keywords-




Python Keywords

Keywords in Python are reserved words that can not be used as a variable name, function name, or any other identifier.

List of Keywords in Python

Keyword

 Description

Keyword

 Description

Keyword

Description

and 

It is a Logical Operator

False

Represents an expression that will result in not being true.

nonlocal

It is a non-local variable

as

It is used to create an alias name

finally

It is used with exceptions

not

It is a Logical Operator

assert

It is used for debugging

for

It is used to create Loop

or

It is a Logical Operator

break

Break out a Loop

from

To import specific parts of a module

pass

pass is used when the user doesn’t 

want any code to execute

class

It is used to define a class

global

It is used to declare a global variable

raise

raise is used to raise exceptions or errors.

continue

Skip the next iteration of a loop

if

To create a Conditional Statement

return

return is used to end the execution

def

It is used to define the Function

import

It is used to import a module

True 

Represents an expression that will result in true.

del

It is used to delete an object

is

It is used to test if two variables are equal

try

Try is used to handle errors

elif

Conditional statements, same as else-if

in

To check if a value is present in a Tuple, List, etc.

while

While Loop is used to execute a block of statements

else

It is used in a conditional statement

lambda

Used to create an anonymous function

with

 with statement is used in exception handling

except

try-except is used to handle these errors

None

It represents a null value

yield

yield keyword is used to create a generator function

image source: Geeks for Geeks.

Keywords are reserved words in python. we cannot make keywords as variables. 






































































Comments

Popular posts from this blog

My first blog