Posts

5.Operators

Image
Operators are special symbols which represents computation. They are applied on operand(s), which can be values(constants) or variables. Same operator can behave differently on different data types. Operators when applied on operands form an expression Operators are categorised as Arithmetic Operators Comparison (Relational) Operators Assignment Operators Logical Operators Bit wise Operators Membership Operators Identity Operators Arithmetic Operators( Mathematical) Symbol Description Example 1 Example 2 + Addition 55+45 100  “Good” + “Morning” GoodMorning -   Subtraction 55-45 10 30-80 -50   *   Multiplication 55*45  “Good” * 3 GoodGoodGood   /   Division 17/5 3 17/5.0 3.4 17.0/5 3.4 28/3 9   %  Remainder/ Modulo 17%5 2  23%

4.Basic Python Data Types-Numbers and Strings,Type conversions

Every value in Python has a datatype. Since everything is an object in Python programming, data types are actually classes and variables are instance (object) of these classes. There are various data types in Python. Some of the basic types are listed below. Python Numbers Integers, floating point numbers and complex numbers fall under Python numbers category. They are defined as int, float and complex classes in Python. We can use the type() function to know which class a variable or a value belongs to. Similarly, the isinstance() function is used to check if an object belongs to a particular class. Integers can be of any length, it is only limited by the memory available. A floating-point number is accurate up to 15 decimal places. Integer and floating points are separated by decimal points. 1 is an integer, 1.0 is a floating-point number. Complex numbers are written in the form, x + yj, where x is the real part and y is the imaginary part. Here are some examples. >>>a=5 &

3.Identifiers,Variables and Keywords

 I dentifiers Identifiers are names used to identify variables, functions, classes, modules, and other objects in Python. Rules for framing identifiers 1.Identifiers can be a combination of letters in lowercase (a to z) or uppercase (A to Z) or digits (0 to 9) or an underscore _.  Names like myClass, var_1 and print_this_to_screen , all are valid example. 2.An identifier cannot start with a digit.  1variable is invalid, but variable1 is a valid name. 3.Keywords cannot be used as identifiers. Eg: global = 1 is invalid 4.We cannot use special symbols like !, @, #, $, % etc. in our identifier. a@=0 is invalid 5.An identifier can be of any length. Things to Remember Python is a case-sensitive language. This means, variable X and x are not the same. Always give the identifiers a name that makes sense. While c = 10 is a valid name, writing count=10 would make more sense, and it would be easier to figure out what it represents when you look at your code after a long gap. Multiple words can

2.Running Python Program-IDLE,Interactive Shell, Jupyter, How Python works

Image
  Download the latest release of Python from  www.python.org   depending on your OS Windows,Linux or Mac Complete the installation.This will also install IDLE( Integrated Development Environment). Visit  https://docs.python.org/3/library/idle.html  to get complete details of IDLE. 1.Open IDLE by clicking the application icon 2.Open File menu and click New File and type your first script ( Eg: print("welcome to Python") 3.Save your file with .py extension ( Eg:test.py) 4.From the  Run menu  click the  Run Module(  or press F5-short cut).This will run the script 5.From the  File  menu choose  Exit  to quit from IDLE How to Run Python Code Interactively A widely used way to run Python code is through an interactive session. To start a Python interactive session, just open a command-line or terminal and then type in python, or python3 depending on your Python installation, and then hit Enter. Here’s an example of how to do this on Linux: Open Terminal ( Control-Alt-T) $ python3  

1.Python Introduction

Image
Python was created by  Guido Van Rossum  in late 1980 when he was working at CWI (Centrum Wiskunde & Informatica) which is a National Research Institute for Mathematics and Computer Science in Netherlands.Python got its name from a BBC comedy series from seventies-  “Monty Python's Flying Circus”. The development of Python began in December 1989, and the first official release, Python 0.9.0, was made available in February 1991. Guido van Rossum created Python as a successor to the ABC language, with the intention of making a language that was easy to read and simple to use, while also being powerful and flexible. Python has since evolved significantly and has become one of the most popular programming languages in the world. Some of the features which make Python so popular are as follows: It is a general purpose programming language which can be used for both scientific and non scientific programming.  It is a platform independent programming language.  It is a very simple hig