Python is a high-level, interpreted, general-purpose programming language. Its design philosophy emphasizes code readability with the use of significant indentation. Python is dynamically-typed and garbage-collected. It supports multiple programming paradigms, including structured, object-oriented and functional programming
2. 1
Table of Contents
Program to find GCD of two numbers......................................................... 3
Python Program to find the square root of a number by Newton’s
Method........................................................................................................... 5
Find the maximum of a list of numbers...................................................... 9
Linear Search.............................................................................................. 11
Binary Search.............................................................................................. 13
Python Program for Selection Sort........................................................... 15
Python Program for Insertion Sort............................................................ 17
Python Program for Merge Sort ................................................................ 19
Python program to find first n prime numbers ........................................ 21
Programs that take command line arguments (word count) .................. 24
Find the most frequent words in a text read from a file .......................... 26
Simulate elliptical orbits in Pygame.......................................................... 28
4. 3
Program to find GCD of two numbers
1 def gcd(m,n):
2 if m< n:
3 (m, n) = (n, m)
4 while (m % n != 0):
5 (m, n) = (n, m % n)
6 return n
7
8 m = int(input("Enter the first number: "))
9 n = int(input("Enter the second number: "))
10 print(gcd(m, n))