Thursday 28 May 2020

What is Python? Why do we learn Python? How we learn Pyhton?

1.What is Python? 

 

 

 

 

 

1. Simplicity: Python has made programming fun because it's simple

2. Open Source: It is free for anyone to use. Modification in python is also allowed

3. Portability: Write your code and you can share your anyone u want.

4. Extendible & Extensible: Python supports adding code of other languages.

5. Interpreted: Management of memory, CPU and debugging the code is simpler

6. Huge Libraries: python has a huge library support which helps you in problem

7. Object Orientation: Python supports oops

 

2.Why do we learn Python? 

 

 

 

 

3.How we learn Python?

Tuesday 26 May 2020

How to create a Menu driven Program in Python

How to create a Menu driven Program in Python..

Step 1. Open your python command prompt.
Step 2. Write the following code into it.
Step 3. Execute it / Test the output for various inputs.
Step 4. Now move towards the study parts of python like how to declare and define function in python.
Step 5. To study function more in detail please click on the following link

 The code to write in Step 2 are as follows:
(base) C:\Users\Admin>python
Python 3.7.6 (default, Jan  8 2020, 20:23:39) [MSC v.1916 64 bit (AMD64)] :: Ana
conda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> def mainMenu():
...  print("1. Adition")
...  print("2. Substraction")
...  print("3. Exit")
...  choice=int(input("Enter u r choice"))
...  if choice==1:
...   add()
... elif choice==2:
  File "<stdin>", line 8
    elif choice==2:
       ^
SyntaxError: invalid syntax   Note: indentation of code is too much important in python otherwise you will get error like this.

 # Following is the code of main function in python.
>>> def mainMenu():
...  print("1. Adition")
...  print("2. Substraction")
...  print("3. Exit")
...  choice=int(input("Enter u r choice"))
...  if choice==1:
...   add() #when choice is equals to 1 we call add() function from mainMenu()
...  elif choice==2:
...   sub() #when choice is equals to 2 we call sub() function from mainMenu()
...  elif choice==3:
...   exit  #when choice is equals to 3 we call exit function from mainMenu()
...  else:
...   print("Invalid choice, Enter valid choice1-3")
...   mainMenu()
...# to come out from function press two times Enter key.

# To call mainMenu function for execution.
>>> mainMenu()
1. Adition
2. Substraction
3. Exit
Enter u r choice5   # here we are testing our code for invalid input.
Invalid choice, Enter valid choice1-3
1. Adition
2. Substraction
3. Exit
Enter u r choice3   # for valid inputs its works fine




# Definition of add() function that is actual logic of addition function how it behaves after calling.
>>> def add():
...  print("Enter no1:")
...  x=int(input())
...  y=int(input("Enter no2:"))
...  z=x+y
...  print("The add is:",z)
...  mainMenu()
...
>>>  mainMenu()  # space is not allowed while calling function
  File "<stdin>", line 1
    mainMenu()
    ^
IndentationError: unexpected indent

>>> mainMenu()
1. Adition
2. Substraction
3. Exit
Enter u r choice1 #Execution or calling of sub() function
Enter no1:
2
Enter no2:2
The add is: 4
1. Adition
2. Substraction
3. Exit
Enter u r choice4
Invalid choice, Enter valid choice1-3
1. Adition
2. Substraction
3. Exit
Enter u r choice3


 
# Definition of sub() function that is actual logic of substraction function how it behaves after calling.
>>> def sub():
...  a=int(input("enter no1"))
...  b=int(input("enter no2"))
...  print("The sub is:",a-b)
...  mainMenu()
...
>>> mainMenu()
1. Adition
2. Substraction
3. Exit
Enter u r choice2 #Execution or calling of sub() function
enter no120
enter no210
The sub is: 10
1. Adition
2. Substraction
3. Exit
Enter u r choice3
>>>






Monday 25 May 2020

Syllabus: (2019 Course) Fundamentals of Data Structures (FDS)

SECOND YEAR COMPUTER ENGINEERING (2019 COURSE) A. Y : 2020-2021

Note: ROUGH SYLLABUS YET NOT FINALISE:

Savitribai Phule Pune University Second Year of Computer Engineering (2019 Course) 

210242: Fundamentals of Data Structures 

Teaching Scheme:  TH: 03 Hours/Week
Credit: 03
Examination Scheme:  Mid_Semester(TH): 30 Marks
                                       End_Semester(TH): 70 Marks

Unit I Introduction to Algorithm and Data Structures (07 Hrs)

Introduction: From Problem to Data Structure (Problem, Logic, Algorithm, and Data Structure). Data Structures: Data, Information, Knowledge, and Data structure, Abstract Data Types (ADT), Data Structure Classification (Linear and Non-linear, Static and Dynamic, Persistent and Ephemeral data structures) Algorithms: Problem Solving, Introduction to algorithm, Characteristics of algorithm, Algorithm design tools: Pseudo-code and flowchart Complexity of algorithm: Space complexity, Time complexity, Asymptotic notation- Big-O, Theta and Omega, Finding complexity using step count method, Analysis of programming constructs-Linear, Quadratic, Cubic, Logarithmic.
Algorithmic Strategies- Introduction to algorithm design strategies- Divide and Conquer, and Greedy strategy.
#Exemplar/Case Studies
Multiplication technique by the mathematician Carl Friedrich Gauss and Karatsuba algorithm for fast multiplication.

Unit II Linear Data Structure Using Sequential Organisation (07 Hrs)


Concept of Sequential Organisation, Overview of Array, Array as an Abstract Data Type, Operations on Array, Merging of two arrays, Storage Representation and their Address Calculation: Row major and Column Major, Multidimensional Arrays: Two-dimensional arrays, n-dimensional arrays. Concept of Ordered List, Single Variable Polynomial: Representation using arrays, Polynomial as array of structure, Polynomial addition, Polynomial multiplication. Sparse Matrix: Sparse matrix representation using array, Sparse matrix addition, Transpose of sparse matrix- Simple and Fast Transpose, Time and Space tradeoff. 
#Exemplar/Case Studies Study use of sparse matrix in Social Networks and Maps. Study how Economists use polynomials to model economic growth patterns, how medical researchers use them to describe the behaviour of Covid-19 virus.

Unit III Searching and Sorting (06 Hrs)

Searching: Search Techniques-Sequential Search/Linear Search, Variant of Sequential Search- Sentinel Search, Binary Search, Fibonacci Search, and Indexed Sequential Search. Sorting: Types of Sorting-Internal and External Sorting, General Sort Concepts-Sort Order, Stability, Efficiency, and Number of Passes, Comparison Based Sorting Methods-Bubble Sort, Insertion Sort, Selection Sort, Quick Sort, Shell Sort, Non-comparison Based Sorting Methods-Radix Sort, Counting Sort, and Bucket Sort, Comparison of All Sorting Methods and their complexities.
 #Exemplar/Case Studies Use of Fibonacci search in non-uniform access memory storage and in Optimization of Unimodal Functions. Timsort as a hybrid stable sorting algorithm

Unit IV Linked List (07 Hrs)


Introduction to Static and Dynamic Memory Allocation, Linked List: Introduction, of Linked Lists, Realization of linked list using dynamic memory management, operations, Linked List as ADT, Types of Linked List: singly linked, linear and Circular Linked Lists, Doubly Linked List, Doubly Circular Linked List, Primitive Operations on Linked List-Create, Traverse, Search, Insert, Delete, Sort, Concatenate. Polynomial Manipulations-Polynomial addition. Generalized Linked List (GLL) concept, Representation of Polynomial using GLL.
 #Exemplar/Case Studies Garbage Collection.

Unit V Stack (07 Hrs)

Basic concept, stack Abstract Data Type, Representation of Stacks Using Sequential Organization, stack operations, Multiple Stacks, Applications of Stack- Expression Evaluation and Conversion, Polish notation and expression conversion, Need for prefix and postfix expressions, Postfix expression evaluation, Linked Stack and Operations. Recursion- concept, variants of recursion- direct, indirect, tail and tree, Backtracking algorithmic strategy, use of stack in backtracking. #Exemplar/Case Studies Android- multiple tasks/multiple activities and back-stack , Tower of Hanoi, 4 Queens problem.

Unit VI Queue (06 Hrs)

Basic concept, Queue as Abstract Data Type, Representation of Queue using Sequential organization, Queue Operations, Circular Queue and its advantages, Multi-queues, Linked Queue and Operations. Deque-Basic concept, types (Input restricted and Output restricted), Priority Queue- Basic concept, types(Ascending and Descending). 
#Exemplar/Case Studies Priority queue in bandwidth management.

Learning Resources

Text Books: 
 Horowitz and Sahani―Fundamentals of Data Structures in C++, University Press, ISBN 10: 0716782928 ISBN 13: 9780716782926. 
 Michael T. Goodrich, Roberto Tamassia, Michael H. Goldwasser, Data Structures and Algorithms in Python, Wiley Publication, ISBN: 978-1-118-29027-9

Reference Books: 
1. Brassard & Bratley ―Fundamentals of Algorithmic Prentice Hall India/Pearson Education, ISBN 13-9788120311312. 
2. Allen Downey, Jeffery Elkner, Chris Meyers-How to think like a Computer Scientist: Learning with Python, Dreamtech Press, ISBN:9789351198147. 
3. R. Gillberg, B. Forouzn ―Data Structures: A Pseudo code approach with C, Cenage Learning, ISBN: 9788131503140. 
4. M. Weiss―Data Structures and Algorithm Analysis in C++, 2nd edition, Pearson Education, 2002, ISBN-81-7808-670-0.

Other: 
 Know Thy Complexities! (https://www.bigocheatsheet.com/) (https://github.com/RehanSaeed/.NET-Big-O-Algorithm-Complexity-Cheat-Sheet) 
 Data Structure Visualizations (https://www.cs.usfca.edu/~galles/visualization/Algorithms.html)


Monday 30 September 2019

Step by Step guide to connect login page with database using HTML, CSS, PHP, MySQL

Problem statement:
 Design HTML pages for Registration/login and connect that pages with database also generate 
 several reports as per the application requirement in your project.
Objective:
 1. create login and registration page.
   1.1 when user enters username and password check either it is valid display the message login succesfull..or if not.
   1.2 if it is not valid store his information in database and make him valid and again perform the
         login if login successfull display the appropriate message login successfull.
Solution:
 A. First install XAMPP server on your machine as per the machine operating system and also
     download sublime Text editor. (Errors may be like this:>api-ms-win-crt-runtime-|1-1-0.dll
     reinstall)
 B. Start Apache and MySQL services.
 C. Go to browser and type localhost/phpmyadmin
 D. Create database eg:login after that Create table eg:users inside this database and insert
      one row value in it like testuser and password testuserpass.
 E. Create one folder inside C:/Program file/XAMPP --> htdoc ---> create your project folder like
      LoginProj
 F. inside this LoginProj folder store three files in it. 1.login.php 2. style.css  3.process.php
 G. Now inside login.php write the code of login form design with form action=process.php and
      method="POST"
 H. After that go to Browser and check either login form design is proper or not so for that type
      localhost/LoginProj/login.php.
 I. When we click on login button it take us to process.php page.
 J. Now go to style.css page and write all code neccessary for login form design.
 K. Now go to process.php page and write code
        //1.to get values passes from form in login.php file.
      <?php
         $username=$_POST['username']; //username must be id="username" value in login.php file
         $password=$_POST['password']; //password must be id="password" value in login.php file
       //2.to prevent mysql injection. Ref:https://www.youtube.com/watch?v=arqv2YVp_3E
         $username=stripcslashes($username);
         $password=stripcslashes($password);
         $username=mysql_real_escape_string($username);       
         $password=mysql_real_escape_string($password);
       //3.connect to the server and select database.
         mysql_connect("localhost","root","");
         mysql_select_db("login");
       //4.query the database for user.
        $result=mysql_query("select * from users where username = '$username' and password =
        '$password'") or die("Failed to query database" .mysql_error());
        $row = mysql_fetch_array($result);
        if($row['username']==$username && $row['password']==$password)
       {
         echo "Login success!!! Welcome".$row['username'];
       }
       else
       {
         echo "Failed to login...";
       }
     ?>
 L. Now go to browser and type localhost/LoginProj/login.php. enter user and password and click on login button appropriate message gets displayed.

/*HERE IS THE CODE FOR ALL PAGES*/ 

 1. login.php
 <html>
<head>
 <title> Login and Registration Form Design</title>
 <link rel="stylesheet" href="style.css">
</head>
<body>
 <div class="login-page">
 <div class="form">
  <form class="register-form">
  <input type="text" placeholder="username" name="useri" id="user"/>
  <input type="text" placeholder="password" name="pasw" id="pass"/>
  <input type="text" placeholder="email id" name="emaill" id="email"/>
  <button>Create</button>
  <p class="message"> Already Registered?<a href="#"> Login</a></p>
  </form>
  <form class="login-form" action="process.php" method="POST">
  <input type="text" placeholder="username" id="username" name="usr"/>
  <input type="password" placeholder="password" id="password" name="passw"/>
  <button>Login</button>
  <p class="message">Not Registered?<a href="#"> Register</a></p>
 </div>
 </div>
 <script src='https://code.jquery.com/jquery-3.4.1.min.js'>
 </script>
 <script>
  $('.message a').click(function(){
  $('form').animate({height:"toggle",opacity:"toggle"},"slow");
  });
 </script>

</body>
</html>


2. style.css 

body{
 background-image:linear-gradient(rgba(0,0,0,0.6),rgba(0,0,0,0.6)),url(Lighthouse.jpg);
 height:100vh;
 background-size:cover;
 background-position:center;
}
.login-page{
 width:360px;
 padding:10% 0 0;
 margin:auto;
}

.form{
 position:relative;
 z-index:1;
 background:rgba(7,40,195,0.8);
 max-width:360px;
 margin:0 auto 100px;
 padding:45px;
 text-align:center;
}

.form input{
 font family:"Roboto",sans-serif;
 outline:1;
 background:#f2f2f2;
 width:100%;
 border:0;
 margin:0 0 15px;
 padding:15px;
 box-sizing:border-box;
 font-size:14px;
}

.form button{
 font family:"Roboto",sans-serif;
 text-transform:uppercase;
 outline:0;
 background:#4cAF50;
 width:100%;
 border:0;
 padding:15px;
 color:#ffffff;
 font-size:14px;
 cursor:pointer;
}

.form button:hover,.form button:active{
 background:#43A047;
}

.form .message{
 margin:15px 0 0;
 color:aliceblue;
 font-size:12px;
}

.form .message a{
 color:#4CAF50;
 text-decoration:none;
}

.form .register-form{
 display:none;
}

3. process.php

<?php
        $con=mysqli_connect("localhost","root","","login");
        // Check connection
           if (mysqli_connect_errno()) {
           echo "Failed to connect to MySQL: " . mysqli_connect_error();
          }
          // escape variables for security
          $uname = mysqli_real_escape_string($con, $_POST['usr']);
          $password = mysqli_real_escape_string($con, $_POST['passw']);

         //query to the database

          $sql="select * from users where username = '$uname' and password = '$password'";
          $result=mysqli_query($con,$sql);

          if (!mysqli_query($con,$sql)) {
              die('Error: ' . mysqli_error($con));
              }
              else
              {

                $row=mysqli_fetch_array($result,MYSQLI_ASSOC);

                if($row['username']==$uname && $row['password']==$password)
                {
                 echo "Login success!!! Welcome ".$row['username'];
                }
                else
                {
                 echo "Failed to login...";
                }

              }

            mysqli_close($con);      
     ?>