Showing posts with the label PYTHON LABORATORY MANUALShow all
To write a Python program to multiply matrices.
To write a Python program to find first n prime numbers.
To write a Python Program to perform Merge sort.
To write a Python Program to perform insertion sort.
To write a Python Program to perform selection sort.
To write a Python Program to perform binary search.
To write a Python Program to perform Linear Search
To write a Python Program to find the maximum from a list of numbers.
To write a Python program to find the exponentiation of a number.
To write a Python Program to find the square root of a number by Newton’s Method. Algorithm: 1. Define a function named newtonSqrt(). 2. Initialize approx as 0.5*n and better as 0.5*(approx.+n/approx.) 3. Use a while loop with a condition better!=approx to perform the following, i. Set approx.=better ii. Better=0.5*(approx.+n/approx.) 4. Print the value of approx.. Program: def newtonSqrt(n): approx = 0.5 * n better = 0.5 * (approx + n/approx) while better != approx: approx = better better = 0.5 * (approx + n/approx) return approx print('The square root is' ,newtonSqrt(100)) Sample Output:
To write a Python program to find GCD of two numbers.