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

Tuesday, May 24, 2022

Data structure(Searching linear and binary)

Linear search :-इस Search सर्च में element को एक-एक करके search किया जाता है और जहां element  मिल जाता है search complete.
(Compare element one by one)
Time taking 
  •     Best Case = O(1)
  •     Average Case = O (n)
  •     Worst Case Complexity O(n)
Assume Find K = 41 



Program

# Linear Search in Python


def linearSearch(array, n, x):

    # Going through array sequencially
    for i in range(0, n):
        if (array[i] == x):
            return i
    return -1


array = [2, 4, 0, 1, 9]
x = 1
n = len(array)
result = linearSearch(array, n, x)
if(result == -1):
    print("Element not found")
else:
    print("Element found at index: ", result)
Binary seach :-( Worked with sorted Array)
हमारे पास elements (a+b/2)  को Check किया जाता है और उसके हिसाब से Half parts  को eleminate कर दिया जाता है और आगे के Parts  को ऐसे ही तरीके से सर्च किया जाता है.



Program for Binary Search by iteration and recursion method


Selection sort :- Selection सिलेक्शन Sort में सबसे पहला सबसे छोटा आइटम सर्च किया जाता है और उस छोटे आइटम को swap कर दिया जाता है first एलिमेंट से इसी प्रकार से 2nd smallest element एलिमेंट फिर 3,4 so on. और ऐसे करके elements को सही पोजीशन पर लगाया जाता है

Step 0


Step 1


Step 2


Step 3


Program for Selection sort
Bubble sort :- swap to nex element. (link for example and programs )

Insertion sort :- select any element and sorted fully (sort like 2elemt . 3 elements >..)

Monday, May 23, 2022

Python (Syllabus)

 Python Syllabus

UNIT - I

 Planning the computer program: concept of problem solving, problem definition, program design, debugging, types of errors in programming, documentation. Techniques of problem solving: flowcharting, decision table, algorithms, structured programming concepts, programming methodologies viz. Top-down and bottom-up programming. Overview of programming: structure of a python program, elements of python. 

UNIT - II 

Introduction to python: python interpreter, using python as calculator, python shell, indentation. Atoms, identifiers and keywords, literals, strings, operators (arithmetic operator, relational operator, logical or Boolean operator, assignment, operator, ternary operator, bit wise operator, increment or decrement operator) Creating python programs: input and output statements, control statements(branching, looping, conditional statement, exit function, difference between break, continue and pass.), defining functions, default arguments, errors and exceptions. Iteration and recursion: conditional execution, alternative execution, nested conditionals, the return statement. 

UNIT - III 

Recursion, stack diagrams for recursive functions, multiple assignment, the while statement, tables, two-dimensional tables (English) Strings and lists: string as a compound data type, length, traversal and the for loop, string slices, string comparison, a find function.

UNIT - IV

 Looping and counting, list values, accessing elements, list length, list membership, lists and for loops, list operations, list deletion. Cloning lists, nested lists Object oriented programming: introduction to classes, objects and methods, standard libraries.(English)

 UNIT - V 

Data structures: (LINK) ENGLISH arrays, list, set, stacks and queues. Searching and sorting: linear and binary search, bubble, selection and insertion sorting.   

Saturday, April 9, 2022

Python Syllabus

 Python

  1. Programming Basic
  2. Technique of Problem Solving: Flow Chart, Decision Table,  Algorithm
  3. Programming Approach Top Down, Bottom Up, Moduler  
  4. Python Introduction
  5. Python Comments
  6. Python Installation
  7. Python Variable
  8. Python Data Types
  9. Python List , String, Tuple, Set  Dictionary
  10. Python Keywords & atoms
  11. Python Literals , Keywords
  12. Python Operator
  13. If Else
  14. Loop - For , While
  15. Break & Continue & Pass
  16. Function ( find,
  17. Error & Exceptions
  18. Iteration and Recursion 
  19. Modules
  20. Two Dimensional Tables
  21. String -slices, String Comparison, Length
  22.  Loops Operation - accessing Element, length, membership.
  23. Object Oriented : Class - Objects, Method Standard Libraries.
  24. Data Structure : Array, list, set, Stacks, Queues.
  25. Searching and Sorting: Linear and binary Search, Bubble, Selection & Sorting.


Thursday, March 31, 2022

Python Loop

 Loop : The execution of a specific code may need to repeated several number of times.

1. For Loop

2. While Loop

 

 Program 1

N  = Int (Input (" Enter any no ")

For i in range (1,11 ):
        c = n*i
        print ( N , "*", i , " = ", C)

Program 2. 

i = 1
While ( i < = 10 ):
        Print ( i )
        i = i +1

 










Python (conditional Statement)

 If Conditional Statement

1. if 

2. if .. Else

3. nested

Program:1 IF

    Num = Int(input("Please enter any no"))

    If num%2 = = 0 :

            print ("Number is even ")


Program 2 if ... else

    Num = Int(input("Please enter any no"))

    If num%2 = = 0 :

            print ("Number is even ")

    Else :

            Print (" no is odd")


Program 3

    Num = Int(input("enter any No."))

    if  Num = = 10 :

        Print ("num is    Equal to 10 ")

    elif Num = = 50:

        Print ("No is equal to 10 ")

    Else:

        Print (" no. is not equal to 10 and 50 )



Refrence

Day - 6 Python (keywords & Operator)

(Keywords are special reserved words)

TrueFalseNoneandas
assetdefclasscontinuebreak
elsefinallyelifdelexcept
globalforiffromimport
raisetryorreturnpass
nonlocalinnotislambda

Python Operator
  • Arithmetic (+,-,*, %(remainder), ** exponent, // floor )
  • Comparison Operator (==, != , <= , <=,>,<
  • Assignment Operator ( =, +=,-=, *= , %=, **= (power) ,//= (floor)
  • Logical Operators  (and , or, not )
  • Bitwise Operator ( & (and) , |  (or) ,^ (xor), ~ (nor) , << (left Shift) , << (right shift)
  • Membership Operator (in, not in )
  • Identity Operator ( is, is not)

Wednesday, March 30, 2022

Day -5 Python Datatypes

 Python Data types

1. Number

    a. Integer (10, 2, 29, -20 )

    b. Float (1.9, 9.902, 15.2)

    c. Complex (2.0 + 2.3j)


2. Sequence

    1. String ("hello yunus sir")

    2. List ( ["yunus" , 877, 125]) - use Square 

    3. Tuple (("yunus" , 877, 125)) - use Parentheses


3.Boolean
4. Set ({"james",4,5})- no dublicate entry
5.Dictionary ({1:'yunus',2:'Digital'})


day -4 python String

 Strings Are Array (examples)

1. 


2.     

3.

4.
5. 




Day 3 Python variable (Hindi and english notes)

 Variable :- Direct Assign value

        Rules : -use only alphabets and _underscore in starting & it is case sensitive .

        example: x = "John" ,x = 'John'

Casting : Specify the datatype of a variable

        X = Str(3)  #it will show x contain integer

Note important function - type(x)  output : <class 'int'>

Cases :- Camel Case : myVariableName = "John"

        Pascal Case : MyVariableName = "John"

        Snake Case : my_variable_name = "John"

    Assign Values

1.   x, y, z = "Orange""Banana""Cherry"
2. x = y = z = "Orange"
3.fruits = ["apple""banana""cherry"]
  x, y, z = fruits


Global Variables : variable created outside of function.(by using Global keyword use can change the vaule.)


Python datatypes:
x = "hello yunus sir "        -    Str
x = 20                        -    int
x = 20.5                      -   float
x = 4j                        -   Complex
x = [ "apple", "banana"]      -    List
x = ("apple", "banana")       -    Tuple
x = range(6)                  -     range
x = True                      -     bool
x = {"apple","banana"}        -    set (no duplicate value)

Note : Random.randrange(1,10) print : 6 any use random Module

Tuesday, March 29, 2022

Day - Python (Programming Basic )

 Python 

1. Algorithm :- Write easy and simple steps to solve any problem.

2. Flowchart :- To describe any problem solution using special chart or pictorial representation of any program flow.


Day 2 Python (Introduction)

                                Python


 Introduction:- 

        Python Created by Guido Van Rossum in 1991. & its High Level language

Used

1. Web Development 

2. Software Development

3.Mechine learning

4. AI

6. Data Mining

Advantages:

  • 1. Works on different Platform( Window, Mac, Linux, )
  • 2. Simple, easy and use Interpreter System to run the code
  • 3.Python Version Python -1, Python 2, Python -3
  • 4. Case sensitive language (like AGE, age, Age are different variable)

Installation 

Goto  https://www.python.org/  or Click here

Software for Run Python :- Visual Studio Code Download , Pycharm Download