Monday, 6 July 2020

Group A Python Program for Matrix Addition, Substraction, Multiplication and Transpose


Problem Statement: 

Write a python program to compute following computation on matrix: 

a) Addition of two matrices 

b) Subtraction of two matrices 

c) Multiplication of two matrices 

d) Transpose of a matrix 

-------------------------------------------------------------------------------

Analysis of a Problem Statement: 

1. Given :

  Matrices are given in a problem statement.

2. Entity: 

  Matrix is an entity or object with no of rows and no of columns attribute.

3. Input:

 You have to accept n x n matrix values from the user to perform operations on it.

4. Data Structure:

To store/organize the matrix element in memory we required LIST as a data structure. 

5. Output: 

5.1 Addition of two Matrices
5.2 Subtraction of two Matrices
5.3 Multiplication of two Matrices
5.4 Transpose of a Matrix 

SOURCE CODE:

 








OUTPUT:

Basic Matrix Operation using Python
Welcome all in assignment no:03 from Group A
For Matrix operation we require some input from you Please.
Enter no of rows in first matrix: 3
Enter no of cols in first matrix: 3
Enter no of rows in second matrix: 3
Enter no of cols in second matrix: 3
1. Accept two matrices from user:
2. Show the matrices values:
3. Addition of Two Matrices:
4. Subtraction of Two Matrices:
5. Multiplication of Two Matrices:
6. Transpose of Matrix
7. Exit
Enter your choice:1
please enter the values for First Matrix:
Enter the value of matrix[0][0]:: 1
Enter the value of matrix[0][1]:: 2
Enter the value of matrix[0][2]:: 3
----------------------------
Enter the value of matrix[1][0]:: 4
Enter the value of matrix[1][1]:: 5
Enter the value of matrix[1][2]:: 6
----------------------------
Enter the value of matrix[2][0]:: 7
Enter the value of matrix[2][1]:: 8
Enter the value of matrix[2][2]:: 9
----------------------------
please enter the values for Second Matrix:
Enter the value of matrix[0][0]:: 1
Enter the value of matrix[0][1]:: 2
Enter the value of matrix[0][2]:: 3
----------------------------
Enter the value of matrix[1][0]:: 4
Enter the value of matrix[1][1]:: 5
Enter the value of matrix[1][2]:: 6
----------------------------
Enter the value of matrix[2][0]:: 7
Enter the value of matrix[2][1]:: 8
Enter the value of matrix[2][2]:: 9
----------------------------
1. Accept two matrices from user:
2. Show the matrices values:
3. Addition of Two Matrices:
4. Subtraction of Two Matrices:
5. Multiplication of Two Matrices:
6. Transpose of Matrix
7. Exit
Enter your choice:2
The Value of First matrix is as follows:
1 2 3
4 5 6
7 8 9
The Value of Second matrix is as follows:
1 2 3
4 5 6
7 8 9
1. Accept two matrices from user:
2. Show the matrices values:
3. Addition of Two Matrices:
4. Subtraction of Two Matrices:
5. Multiplication of Two Matrices:
6. Transpose of Matrix
7. Exit
Enter your choice:3
The addition of two matrices are as follows..
2 4 6
8 10 12
14 16 18
1. Accept two matrices from user:
2. Show the matrices values:
3. Addition of Two Matrices:
4. Subtraction of Two Matrices:
5. Multiplication of Two Matrices:
6. Transpose of Matrix
7. Exit
Enter your choice:4
The subtraction of two matrices are as follows..
0 0 0
0 0 0
0 0 0
1. Accept two matrices from user:
2. Show the matrices values:
3. Addition of Two Matrices:
4. Subtraction of Two Matrices:
5. Multiplication of Two Matrices:
6. Transpose of Matrix
7. Exit
Enter your choice:5
The Multiplication of two matrices are as follows..
30 36 42
66 81 96
102 126 150
1. Accept two matrices from user:
2. Show the matrices values:
3. Addition of Two Matrices:
4. Subtraction of Two Matrices:
5. Multiplication of Two Matrices:
6. Transpose of Matrix
7. Exit
Enter your choice:6
Before Transpose of Matrix the elements in matrix are as follows:
1 2 3
4 5 6
7 8 9
After applying Transpose on matrix elements are as follows:
1 4 7
2 5 8
3 6 9
1. Accept two matrices from user:
2. Show the matrices values:
3. Addition of Two Matrices:
4. Subtraction of Two Matrices:
5. Multiplication of Two Matrices:
6. Transpose of Matrix
7. Exit
Enter your choice:7






Thursday, 25 June 2020

Group A Assignment No 3 Python Program for Matrix Operation like Addition, Substraction, Multiplication and Transpose

Problem Statement: 

Write a python program to compute following computation on matrix: 

a) Addition of two matrices 

b) Subtraction of two matrices 

c) Multiplication of two matrices 

d) Transpose of a matrix 

-------------------------------------------------------------------------------

Now, the first question comes to our mind is how to declare a matrix in python ? how to store elements in python ?

Let's see......

Using List as a data structure  in Python,  we can create matrix in Python.

How ?

 

Output of this code is as Follows:

Matrix Creation and Storing value in it from user is as follows...
Enter number of rows in matrix:3
Enter number of cols in matrix:3
Enter the value for mat[0][0]:: 10
Enter the value for mat[0][1]:: 20
Enter the value for mat[0][2]:: 30
----------------------
Enter the value for mat[1][0]:: 40
Enter the value for mat[1][1]:: 50
Enter the value for mat[1][2]:: 60
----------------------
Enter the value for mat[2][0]:: 70
Enter the value for mat[2][1]:: 80
Enter the value for mat[2][2]:: 90
----------------------
The user entered elements in matrix are as follows...
10 20 30
40 50 60
70 80 90
>>>


Thursday, 18 June 2020

Group A Python program to store marks scored in subject “Fundamental of Data Structure” by N students in the class.

Problem Statement:  

Write a Python program to store marks scored in subject “Fundamental of Data Structure” by N students in the class. Write functions to compute following: 

a) The average score of class 

b) Highest score and lowest score of class 

c) Count of students who were absent for the test 

d) Display mark with highest frequency 

 

Hardware Requirement:

      Processor: Intel(R) Core(TM)2 Duo CPU  E7500 @ 2.93GHz

      Memory: 2.00 GB

      Operating System: 64-bit Open source


Software Requirement:

     Programming tool like PyCharm with Python 3.X.X Interpreter 

 

 

Source Program:  







Output:

GroupA Assignment No 02
Menu Driven Program For FDS Test of 30 Marks Analysis:
================== ****** ==============================
The Students gets the marks in FDS Test out of 30M are as follows...
['NA', 12, 22, 20, 23, 24, 25, 'AB', 25, 21, 25, 'AB', 22, 'AB', 25, 28]
>>> mainMenu()
1.The average score of class SEA
2.Highest score and lowest score of class
3.Count of Students who were absent for the test
4.Display mark with highest frequency
5.Exit
Enter your choice::1
1.The average score of class SEA:
Total Strength of Class SE A is:: 16
The Average Score of Class is:: 22.666666666666668
---------- ******* --------------------------------

1.The average score of class SEA
2.Highest score and lowest score of class
3.Count of Students who were absent for the test
4.Display mark with highest frequency
5.Exit
Enter your choice::2
2.Highest score and lowest score of class
The Highest Marks in FDS Test is: 28
The Lowest Marks in FDS Test is: 12
---------- ******* --------------------------------

1.The average score of class SEA
2.Highest score and lowest score of class
3.Count of Students who were absent for the test
4.Display mark with highest frequency
5.Exit
Enter your choice::3
3.Count of Students who were absent for the test

The Students gets the marks in FDS Test out of 30M are as follows...
['NA', 12, 22, 20, 23, 24, 25, 'AB', 25, 21, 25, 'AB', 22, 'AB', 25, 28]

Count of Students who were Absent for the FDS Test is: 3
---------- ******* --------------------------------

1.The average score of class SEA
2.Highest score and lowest score of class
3.Count of Students who were absent for the test
4.Display mark with highest frequency
5.Exit
Enter your choice::4
.Display mark with highest frequency
The marks in FDS Test are as Follows...
['NA', 12, 22, 20, 23, 24, 25, 'AB', 25, 21, 25, 'AB', 22, 'AB', 25, 28]
Count of each marks from 0 to 30 are as follows..
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, 1, 1, 4, 0, 0, 1, 0, 0]
Highest frequency of is: 4
Marks of highest frequency is: 25
---------- ******* --------------------------------

Note: In Enter your choice 4 if you run this code you will not get the output as above you will get error please correct this error and execute once again.

Sunday, 14 June 2020

How to design or write an algorithm for a given problem statement.....

How to write an Algorithm for a following Problem Statement:

Problem Statement:

In second year computer engineering class, group A student’s play cricket, group B students play badminton and group C students play football. 

Write a Python program using functions to compute following: -

a) List of students who play both cricket and badminton 

b) List of students who play either cricket or badminton but not both 

c) Number of students who play neither cricket nor badminton 

d) Number of students who play cricket and football but not badminton. 

(Note- While realizing the group, duplicate entries should be avoided, Do not use SET built-in functions) 

 

 

Solution:

First of all we have to analyze the problem statement, we have to find out the following things from the Problem statement.
1. What is given in the Problem statement? [Given]

2. Identify the entity and it's attributes. [Entity]
 
3. Identify the users actual requirements and what are the inputs we are accepting from user.[Input]

4. Identify to store and process the data which data structure is required? [Data Structure]

5. How many functions are there in Problem statement? [Output]


Analysis of Problem Statement by referring above five points: 

1. Given: 

In the above Problem Statement Given/Assume things are: 
a. Class SEA Student Roll numbers. that is whole class strength of SEA
b. Students Plays in Group_A Cricket: Group_B Badminton: and Group_C Football: 

2. Entity:

Here the entity is Class_SE_A and the attribute is Rollno.

3. Input:

As a input we have to accept following things from the user:

3.1 Group_A Cricket: The Rollno of students who plays Cricket from Class_SE_A.
3.2 Group_B Badminton: The Rollno of students who plays Badminton from Class_SE_A.
3.3 Group_C Football: The Rollno of students who plays Football from Class_SE_A.
3.4 Class_SE_A: we have to assume the N number of students in class SE A. 

4. Data Structure:

To Store and Process the data as per user requirement we are using LIST  as a data Structure in Python Programming Language.

5. Output:

As per the user requirement user wants following things as an output when he is going to process the data.
5.1 List of students who play both cricket and badminton.
5.2 List of students who play either cricket or badminton but not both.
5.3 Number of students who play neither cricket nor badminton.
5.4 Number of students who play cricket and football but not badminton.

In this way we are going to analyze each and every problem statement before designing the algorithm that is called as "Requirement Analysis" in Software Development Life Cycle.

So by referring the above analysis,
we comes to know that we have to design Four algorithms for  each and every Output.

Algorithms:

5.1 Algorithm for List of students who play both cricket and badminton.


  
5.2 Algorithm for List of students who play either cricket or badminton but not both.



5.3 Algorithm for Number of students who play neither cricket nor badminton.


 
5.4 Algorithm for Number of students who play cricket and football but not badminton.


Saturday, 13 June 2020

What is List in Python? What are the operations we can perform on List?

What is List in Python?

Lists are just like dynamic sized arrays.

Why we require List in Python? 

 

Lists need not be stored similar data types of elements always which makes it a most powerful tool in Python. A single list may contain different types of data like Float,Integers, Strings, as well as Objects. 

 

Just Try the following Code from your side and find out the answers of it.

Lists are mutable, and hence, they can be altered even after their creation.

List in Python are ordered and have a definite count. The elements in a list are indexed according to a definite sequence and the indexing of a list is done with 0 being the first index. Each element in the list has its definite place in the list, which allows duplicating of elements in the list, with each element having its own distinct place and credibility.

Note- Lists are a useful tool for preserving a sequence of data and further iterating over it.

More Function in List: 

Note: extend() simple adds the elements in existing list it doesn't make Nested list.

Next Function is insert( ) in Python


 

Introduction: From Problem to Data Structure (Problem, Logic, Algorithm, and Data Structure).


Introduction: From Problem to Data Structure (Problem, Logic, Algorithm, and Data Structure).

Here i m going to tell you the story of a boy who don't know how to instruct a computer to do some task (How to find out average of four numbers by computer)?
























Sunday, 7 June 2020

210247: Data Structures Laboratory Group A: Assignment No:02 SE Students FDS Subject Marks Computaion using pyhton List.

Problem Statement:

Write a Python program to store marks scored in subject “Fundamental of Data Structure” by N students in the class. Write functions to compute following:

a) The average score of class.

b) Highest score and lowest score of class.

c) Count of students who were absent for the test.

d) Display mark with highest frequency.

 

 

Analysis of a Problem Statement: 

1. Given :

  Marks scored in subject Fundamental of Data Structure” by N Students.

2. Entity: 

  Here in the Problem statement Entity is subject FDS and attribute of entity is Marks

3. Input:

 Here we have to accept subject FDS marks of N Students as a input from user. 

4. Data Structure:

To store/organize the marks in memory we required LIST as a data structure. 

5. Output: 

5.1 The average score of class
5.2 Highest Score and Lowest Score of a Class.
5.3 Count of a student who were absent for the Test.
5.4 Display marks with highest frequency.



Design of Algorithm:

5.1 To find out the average score of a class.



5.2 To find out Highest Score and Lowest Score of a class.

 



 5.3 To find out count of a student who were absent for the Test.