Posts

 #include <stdio.h> // Define a structure tag population with fields men and women struct population {     int men;     int women; }; // Create a structure within a structure using state and population struct state {     char name[50]; // Assuming the state name won't exceed 50 characters     struct population pop; }; int main() {     struct state s;     // Read data     printf("Enter state name: ");     scanf("%s", s.name);          printf("Enter number of men: ");     scanf("%d", &s.pop.men);          printf("Enter number of women: ");     scanf("%d", &s.pop.women);     // Display data     printf("\nState: %s\n", s.name);     printf("Population:\n");     printf("Men: %d\n", s.pop.men);     printf("Women: %d\n", s.pop.women);     return 0; } #include <stdio....
Image
 
 def sets1(s1,s2):     x=s1.intersection(s2)     print("Common letters in s1 and s2",x)     y=s1.difference(s2)     print("Letters present in s1 but not in s2",y)     a=s2.difference(s1)     print("Letters present in s2 but not in s1",a)     b=s1.symmetric_difference(s2)     print("Symmetric difference between s1 and s2",b) s1=set("salem") s2=set("sonacollege") sets1(s1,s2)   def pangram(st):     a=set('abcdefghijklmnopqrstuvwxyz')     st=set(st.lower())     if(len((a)-(st))==0):         print("Pangram")     else:         print("Not a Pangram") st=input("Enter the string to check pangram: ") pangram(st) def vowel_count(st):     vcount=0     ccount=0     vowel = set("aeiouAEIOU")     for i in st:         if i in vowel:             v...
 PROGRAM: clc % Matrix of size 1*3 a=[2 3 4]; b=[5 6 8]; % Square matrix of size 3*3 A=[8 -6 2; -6 7 -4; 2 -4 3]; B=[1 1 3; 1 5 1; 3 1 1]; C=[1; 2; 3] % Addition of a matrix disp("Addition of a Matrix :") c=a+b % Subtraction of a matrix disp("Subtraction of a Matrix :") d=a-b % Scalar Multiplication of a matrix disp("Scalar Multiplication of a Matrix :") e=A*B %ee=a*b %eee=a.*b % Array Multiplication of a matrix disp("Array Multiplication of a Matrix :") f=a.*b g=A.*B % Determinant of a matrix disp("Determinant of a Matrix :") h=det(A) aa=det(B) % Inverse of a matrix disp("Inverse of a Matrix :") %ab=inv(A) aab=inv(B) % adjoint of a matrix yy=adjoint(A) % Transpose of a matrix yyy=B' % Trace of a matrix xy=trace(B) px=trace(A) ___________________________________ PROGRAM: clc % Square matrix of size 3*3 A=[8 -6 2; -6 7 -4; 2 -4 3]; B=[1 1 3; 1 5 1; 3 1 1]; % Rank of a matrix disp("Rank of a Matrix :") Rank_of_A=ra...
 Exercises Write a program to perform the following operations using list and tuples. Create the list Update list using negative index Create a sub list using Slicing Display the elements in sorting order Delete the elements using Remove, pop, and clear Converts a list into tuple. Find the length, maximum and minimum value Concatenation Repetition Membership Iteration 2 Write a Python program for implementing binary search on a sorted array of N numbers. Write a python function, find_pairs_of_numbers() which accepts a list of positive integers with no repetitions and returns count of pairs of numbers in the list that adds up to n The function should return 0, if no such pairs are found in the list.. Sample Input 1,2,7,4,5,6 0,316 3,4,1,8,5,9,0,619 3 14 Expected Output 4. A teacher is in the process of generating few reports based on the marks scored by the students of her class in a project-based assessment. Assume that the marks of her 10 students are available in a tuple. The mar...