Posts
Showing posts from August, 2022
Introduction to Python
- Get link
- X
- Other Apps
A programming language is a set of instructions which helps to interact with the computer. Programming language is used to build software as well as interact with the hardware. The software can be analytics software, machine learning software, web applications etc . To interact with computer we have one major problem, computers cannot understand English or any other languages that we speak. It can understand only 0s and 1s which are called bits. When we want to interact with computer we have to communicate in 0s and 1s. Any program written only using 0 and 1 are called Machine Language . Computer can easily understand the program written. Machine Language program executes very quickly. But its is very difficult for programmer to write Machine Language program. So solve the problem with machine language Assembly Language were developed. Assembly Language uses basic English commands instead of 0s and 1s. It is bit easier to understand and debug by programme...
Fibonacci sequence
- Get link
- X
- Other Apps
Fibonacci sequence are the series of numbers where each number is addition of previous two numbers.It starts with 0 and 1. So the third number is 0+1=1 and the fourth number is 1+1=2. Following is an example of the series, 0, 1, 1, 2, 3, 5, 8, 13, 21, ... Let us write an python program to generate the series. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 lenghtofseries = int ( input ( "Please enter the length of the series " )) a, b = 0 , 1 count = 0 if lenghtofseries <= 0 : print ( "Length of the must be a positive number" ) elif lenghtofseries == 1 : print (a) else : print ( "Fibonacci sequence:" ) while count < lenghtofseries: print (a) c = a + b a = b b = c count += 1 The output of the program is, Please enter the length of the series 11 Fibonacci sequence: 0 1 1 2 3 5 8 13 21 34 55
Prime Number using python
- Get link
- X
- Other Apps
Prime number is a positive number greater than 1 which can be divided by 1 and by itself. This means that it has only 2 factors, 1 and the number itself. Examples of prime numbers are: 2, 3, 7, 11 and so on. 1. First lets write program is check if the given number is prime number or not. def is_prime (number): for i in range (2, int (number/2)): if (number%i) == 0: return False return True print(is_prime(10)) print(is_prime(13)) Output: False True 2. Let us write another program to generate all the prime numbers between given range . start = 0 end = 100 print (" Prime numbers are: ") for number in range(start, end + 1): if number > 1: for i in range(2, number): if (number % i) == 0: break ...
IDEs for Python Beginners
- Get link
- X
- Other Apps
IDE stands for Integrated Development Environment(IDE). An IDE is a piece of software for writing, debugging and executing software codes. There are hundreds of IDEs available in the market today and they are all good in someway or other. But a beginner they might confuse you which one to choose from them. Here I will make a list of two of them to give you a kick start. If you search over internet you may get many other but they have very good learning curve. For example Visual Studio Code don’t support python out of the box. Pycharm is a heavy software and big learning curve. Once you very comfortable with the basics of python you may explore few of them. I will create another article for the IDEs for prfessionals. IDLE: This is the default IDE that you will get after installation. This is good for learning and best for building very very small applications. Few pros are Free to download Syntax highlighting with autocomplete and auto indentatio...
SELECTION SORT
- Get link
- X
- Other Apps
Selection sort is a sorting algorithm where a list/array of items are sorted by repeatably iterating through the list. In each loop we pick the lowest value and keep it the beginning of the list. Thus during looping it virtually creates two lists. One with sorted list and the another with the remaining unsorted list. Here is an example: Unsorted list: [54, 89, 22, 15, 67] First iteration: We traverse through the whole list and find the lowest value here its 15. So we pick 15 and swap it with the value in the first position so following is the result after first iteration [ 15 , 89, 22, 54 , 67] Second iteration: We start traversing through the whole list from second position and find the lowest value here its 22. So we pick 22 and swap it with the value in the second position so following is the result after second iteration [15, 22 , 89 , 54, 67] Third iteration: We start traversing through the whole list from third position and find the l...