## Posts

Showing posts with the label python

### How to find the square root in python

Python program to find the square root In this program,you  will about the python program how to find the square root of any number by two method: By using exponent function  By using the cmath module.  For understand the program you have the knowledge: Python input,output. Python data types. Python operators. Example for square root of positive number Code:     # Python Program to calculate the square root for positive number number = 10 number_sqrt = number ** 0.5 print ( 'square root %0.3f is %0.3f' %(number ,number_sqrt)) Output:     square root 10.000 is 3.162 In the above program,value is store in the number variable and then exponent with help ** operator  with power 0.5(½) store in the number_sqrt variable.At the end of the program,display with  help of print function. Example for For real and complex number: Source code: `         import cmath   number = 2 + 2j   number_sqrt = cmath.sqrt(number) print ( 'square root  {0} = {1:0.3f}+{2:0.3f}j'   . format (num

### How to add number in python

Add number in Python To  understand how to add the two number in the python ,first of all you have know how to take input  in python and display output in python . Add the two number Following is the example code for add the two in python: # the following code  adds two numbers by assigning value to variables   number1 = 7 number2 = 4.7   # Add two numbers sum = number1 + number2   # Now Display the sum print ( 'The sum of {0} and {1} is {2}' . format (number1, number2, sum))     Now we will see how add numbers with the help of taking input from the user. Example code: Add the two number by user input    # the following code  taking two number from the user then  add into the sum variable.   number1 = input ( 'Enter first number: ' ) number2 = input ( 'Enter second number: ' )   # Add two numbers sum = float (number1) + float (number2)   # Now Display the sum print ( 'The sum of {0} and {1} is {2}' . format (number1, number2, sum))     In the above exa

### Python program to print Hello wolrd

How to print Hello world! In the python This program is very simple, It is usually used to illustrate the syntax of the specific programming language. To understand this program you have the knowledge of the python basic function of python. Source Code # python program print hello world print('Hello, world!') Output Hello, world! In the above example, we use the built-in print function of python. The string is the sequence of the character, In the python string enclosed in the single ‘’, double” “,  and triple  quotes