Posts

Python Program for Bubble Sort

Image
Bubble sort is one of the simplest sorting technique to sort the data items. #Python Bubble Sort Program arr=[50,40,10,30,60] length=len(arr) for i in range(length):     for j in range(0,length-i-1):         if arr[j]>arr[j+1]:             temp=arr[j]             arr[j]=arr[j+1]             arr[j+1]=temp print("the sorted list is:") for i in range(length):     print(arr[i]) Output: Written By: Trilochan Tarai SILAN Technology,BBSR

Python Function Basics Tutorial

Python Function: A function is a block of code to perform a specified task. In this context, there is a function call and there is a function definition. When a function is calling then the function definition is executing. We can pass data known as parameters(arguments) into a function. At the time of function call whatever we take arguments, is known as actual arguments and at the time of function call, we take arguments is known as formal arguments. Here actual arguments equals to the formal arguments. A function can return a value as result. In python a function is defined by using def keyword. Example(without arguments): def show():     #function definition     print('python means SILAN Technology') show()      #function call output: python means SILAN Technology Example(with arguments) def area(base,height):      #function definition     a=...

Python program to generate a Fibonacci series using recursion

def fibonacci(n):     if n<=1:         return n     else:         return fibonacci(n-1)+fibonacci(n-2) no_of_terms=int(input("enter the no.of terms")) if no_of_terms<=0:     print("please enter a positive integer") else:     print("fibonacci sequence is:")     for k in range(no_of_terms):         print(fibonacci(k)) Output: enter the no.of terms7 fibonacci sequence is: 0 1 1 2 3 5 8   Regards: Trilochan Tarai Silan Technology, BBSR Call Us : 0674-2361252 Our Services: JAVA Training || Python Training  ||  DataScience with Python Training  ||  Machine Learning with Python Training  || Projects