Skip to main content

Posts

Showing posts from September, 2021

Operations on Matrix using Python | Addition | Subtraction | Multiplication | Transpose

  Problem:- Write a Python program to compute the following computation on the matrix:     a) Addition of two matrices     b) Subtraction of two matrices     c) Multiplication of two matrices     d) transpose of a matrix def   display_matrix ( matrix ):      for   i   in   range ( len ( matrix )):          print ( "[ " ,  end = '' )          for   j   in   range ( len ( matrix [ 0 ])):              print ( matrix [ i ][ j ],  end = ' ' )          print ( "]" )      print ( "" ) def   input_matrix ():      r = int ( input ( "Enter the no. of rows   : " ))      c = int ( input ( "Enter...

Program to perform addition and subtraction using inheritance in C++

Problem:-  Write a program to perform  addition and subtraction  using inheritance. (single inheritance,  multiple inheritance, multilevel type inheritance) #include   <iostream> using   namespace   std ; class   numbers {      protected:      int  x,y;      public:      void   input (){         cout<< "Enter the first no." ;         cin>>x;         cout<< "Enter the second no." ;         cin>>y;     }      void   display (){         cout<< "first no.:" ;         cout<<x<<endl;    ...

Manipulation of Strings using Python

  Problem Statement :- Write a Python program to compute the following operations on String:     a) To display word with the longest length     b) To determine the frequency of occurrence of a particular character in the string     c) To check whether the given string is palindrome or not     d) To display the index of the first appearance of the substring      e) To count the occurrences of each word in a given string. s= input ( "Enter the string: " ) lst=s.split( " " ) def   longword ():      long = ""      for  i  in   range ( len (lst)):          if ( len (lst[i])> len ( long )):              long =lst[i]      print ( "The longest word in the string is: " ,  long ) def   freqchar...

SET THEORY USING LIST IN PYTHON

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 the following:-     a) List of students who play both cricket and badminton     b) List of students who play either cricket or badminton or 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) Note :- Scroll horizontally to see the full line of code. def   Addelem ( A ,  a ):      for   i   in   range  ( a ):          elem = input ( "Enter the name of student:" )          if ( elem   ...