Posts

Showing posts from April, 2020

Python Bubble Sort Program using function

Image
#Python Bubble Sort Program using function Written By: Trilochan Tarai SILAN Technology,BBSR

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

Python Class & Object Tutorial

Image
In general a class is defined as grouping of objects having identical properties, common behavior, and shared some relationships to perform a specified task. For example, a computer system, a vehicle etc. But in programming point of view a class is a user-defined data type which fully defines an object. That means without a class, we cant declare an object An object is also called an instance of a class and the process of creating this object is known as instantiation. Once a class is declared, we can declare any no of objects belonging to that class. Syntax to declare an object: object_name=class_name() Example-1: Example-2: Note: When we define a function inside a class, it is mandatory to pass a self keyword as parameter to function. The self keyword act as a pointer which points to the current instance(object). That means what ever the object contains data, that data member will access by self keyword using dot operator. Regards: Tr...