Skip to main content

Basic Knowledge of Python part 1

Basic Mathematics equations using Python-

As we know python is a simple and easy to learn programming language. In this section we learn how to done mathematics equations using python. To perform this we use our basic operators +,-,/,* . 
To perform python we have to open python interpreter. In this interpreter you can type simple equation like 5+5, 4/2 etc. For example:


The integer number (e.g. 1,2,3....) have type int and the number with fractional part (e.g. 2.5,2.1,4.5...) have type float.

Note:- The division type always returns float.

To get only an integer result of division you can use the // operator and to get remainder from division result you can use % operator.


In python you can easily calculate power of the number by using ** operator.


Like this you can easily calculate mathematics equation. Now we see how to find area of rectangle. Area = length*width is the formula to find area of rectangle.


Here '=' sign is used to store value to the variable. You can also calculate area using fractional point.



Comments

Popular posts from this blog

Python | Introduction

Python is developed by Guido van Rossum . Guido van Rossum started implementing python in 1989. Python is very simple programming language so if you are new to programming, you can learn python without facing any issue. Features of Python Free and Open Source -                                                                                      Python is a open source language. We can easily install python.It is freely available at python's official website . High level language -                                                                                             Easy to learn and use that means it is user friendly programming language. Python language is more expressive means that it is more understandable and readable.  Interpreted language-                                                                                         Python is a interpreted programming language means that python code directly runs from its source code. There is no compiler to compile python so

Python | Control Flow Tools

Control Flow Tools In this session we will see about control flow tools of python. 1) if Statement:- In the programming language if statement is important statement. Now we see how to write if statement in the python program. For Example:- >>> x = int(input("Please Enter an integer")) Please Enter an integer 50 >>> if x<0:      x=0      print("Negative change to zero") elif x==0: print("Zero") elif x==1: print("One") else: print("More") More >>>  Here is the program of if statement. You can add one or more elif part in the program. else part is the optional.      In the program we take the value of x is 50. In the if statement we write x<0 condition which is false because 50 is not less than 0 so it will go to the next part of the code which is first elif part, here we give condition x==0 this condition is also false so it will go to the second elif part which is x==1 this condition is also f