Showing posts with label Python. Show all posts
Showing posts with label Python. Show all posts

Friday 23 February 2024

Expert Lecture on Python

 Unit no 1 Problem Solving, Programming and Python Programming

General Problem-Solving Concepts: 

Problem Solving in everyday life.

Having no problems is the
 biggest problem of all.

What is Problem?
problem is a situation that is unsatisfactory and causes difficulties for people and needs to be dealt with or solved.
For Example, let's See what is the Alberto's Problem? I like Problem Alway's

Problem Solving Steps:

The problem-solving process typically includes the following steps:

1. Identify the issue: Recognize the problem that needs to be solved.

2. Analyze the situation: Examine the issue in depth, gather all relevant information, and consider any limitations or constraints that may be present.

3. Generate potential solutions: Brainstorm a list of possible solutions to the issue, without immediately judging or evaluating them.

4. Evaluate options: Weigh the pros and cons of each potential solution, considering factors such as feasibility, effectiveness, and potential risks.

5. Select the best solution: Choose the option that best addresses the problem and aligns with your objectives.

6. Implement the solution: Put the selected solution into action and monitor the results to ensure it resolves the issue.

7. Review and learn: Reflect on the problem-solving process, identify any improvements or adjustments that can be made, and apply these learnings to future situations.

Program Design Tools: Algorithm, Flowchart, Pseudo-codes.

Data Structures

Basics of Python Programming:

1. Features of Python: Click here to learn features

2. History of Python: Click here to learn more

3. Literal Constants: click here to learn more.

4. Keyword (reserved word), Variables, and Identifiers: Click here to learn more


5. Data Types: click here to learn more

6. Input Operation in Python: Click here to Learn More

7. Indentation in Python: Click here to learn more..

8. Operators in Python: Click here to learn more

9. Expressions in python: Click here

 

Friday 11 September 2020

Write python program to store 10th class percentage of students in array. Write function for sorting array of floating point numbers in ascending order using radix sort and display top five scores

 Problem Statement:

 Write python program to store 10th class percentage of students in array. Write function for sorting array of floating point numbers in ascending order using radix sort and display top five scores.

 Radix Sort Source Code For Integer Numbers:

Output: 

 Radix Sort For Floating point numbers:




OUTput:







































Friday 31 July 2020

Group B 12[b] Write a python program to store names and mobile numbers of your friends in sorted order on names. Search your friend from list using Fibonacci search. Insert friend if not present in phonebook.

Very good explanation of Fibbonacci Search

Problem Statement:

b) Write a python program to store names and mobile numbers of your friends in sorted order on names. Search your friend from list using Fibonacci search. Insert friend if not present in phone book.



Source Code:







Output:

Author: Nitin Mohan Shivale
Phone Book Application implementation using...
Fibbonacci Search Method:
The element inside phone book are as follows:
['amol', 1234567892]

['bavesh', 2132654522]

['chetan', 9923511212]

['dheeraj', 9823463224]

['eravati', 8530770714]

Total elements present in phonebook  are: 5


Enter friend name u want to search:Bhavana


bhavana
bhavana  is not present in phonebook


Record bhavana is now inserted in phonebook....


Enter mobile number of your friend:9923511212


['bhavana', 9923511212]


[['amol', 1234567892], ['bavesh', 2132654522], ['chetan', 9923511212], ['dheeraj', 9823463224], ['eravati', 8530770714], ['bhavana', 9923511212]]


but for Binary and Fibonnaci search record must be in sorted order in phonebook


****** after Sorting the data in phonebook...******
[['amol', 1234567892], ['bavesh', 2132654522], ['bhavana', 9923511212], ['chetan', 9923511212], ['dheeraj', 9823463224], ['eravati', 8530770714]]


Record  bhavana  added successfully in phone book....
>











Group B: 12 [a] a) Write a python program to store names and mobile numbers of your friends in sorted order on names. Search your friend from list using binary search (recursive and non-recursive). Insert friend if not present in phonebook


Problem Statement:

a) Write a python program to store names and mobile numbers of your friends in sorted order on names. Search your friend from list using binary search (non recursive and recursive). Insert friend if not present in phone book.


Source Code:






Recursive Function of Binary Search:



The main function calling from here.....


Monday 20 July 2020

Write a python program to store roll numbers of student in array who attended training program in random order. Write function for searching whether particular student attended training program or not, using Linear search and Sentinel search.

Problem Statement: 

a) Write a python program to store roll numbers of student in array who attended training program in random order. Write function for searching whether particular student attended training program or not, using Linear search and Sentinel search.

 

Theory: 

Linear Search : 

The idea behind linear search is to compare the search item with the elements in the list one by one (using a loop) and stop as soon as we get the first copy of the search element in the list. Now considering the worst case in which the search element does not exist in the list of size N then the Simple Linear Search will take a total of 2N+1 comparisons (N comparisons against every element in the search list and N+1 comparisons to test against the end of the loop condition).

 

 

Sentinel Linear Search : 

Here the idea is to reduce the number of comparisons required to find an element in a list. Here we replace the last element of the list with the search element itself and run a while loop to see if there exists any copy of the search element in the list and quit the loop as soon as we find the search element. See the code snippet for clarification.


Algorithm:

 

int last = array[N-1];                                                                                                                        
array[N-1] = item;    // Here item is the search element.
int i = 0;                 
while(array[i]!=item)            
{
    i++;  
}
array[N-1] = last;
if( (i < N-1) || (item == array[N-1]) )
{
    cout << " Item Found @ "<<i;
}
else
{
    cout << " Item Not Found";                                     
}

Analysis:

Here we see that the while loop makes only one comparison in each iteration and it is sure that it will terminate since the last element of the list is the search element itself. So in the worst case ( if the search element does not exists in the list ) then there will be at most N+2 comparisons ( N comparisons in the while loop and 2 comparisons in the if condition). Which is better than ( 2N+1 ) comparisons as found in Simple Linear Search.
Take note that both the algorithms have time complexity of O(n).

 Program :

 Output: 

Sentinel Search......
[1, 2, 3, 4, 5, 44, 55, 30]
8
30
[1, 2, 3, 4, 5, 44, 55, 30]
key found at location: 7