Q1. Find the nature and roots of the quadratic equation.
Algorithm :-
       1.   Start
       2.   Input values of the variables a, b and c.
       3.   Calculate the discriminant D = b2 – 4ac
       4.   To determine the nature :
     If D>0D > 0D>0: The equation has two distinct real roots.
     If D=0D = 0D=0: The equation has one real and repeated root.
     If D<0D < 0D<0: The equation has two complex conjugate roots.
       5. To calculate the roots : x = (-b+math.sqrt(D))/(2*a)
                                      , (-b-math.sqrt(D))/(2*a)
       6. Obtain the output.
       7. Stop.
       Psuedocode-
       START
         INPUT a, b, c
         COMPUTE D = b² - 4ac
         IF D > 0 THEN
           PRINT "Roots are real and distinct"
           COMPUTE r1 = (-b + sqrt(D)) / (2a)
           COMPUTE r2 = (-b - sqrt(D)) / (2a)
           PRINT r1, r2
         ELSE IF D = 0 THEN
           PRINT "Roots are real and equal"
           COMPUTE root = -b / (2a)
           PRINT root
         ELSE
           PRINT "Roots are complex"
           COMPUTE real_part = -b / (2a)
           COMPUTE imaginary_part = sqrt(-D) / (2a)
           PRINT real_part, imaginary_part
       STOP
  Q2. To find sum of n numbers.
Algorithm :-
    1. Start
    2. Take input n.
    3. Create a list l and a variable s.
    4. Create a for loop to get input of all numbers in the list.
       for i in range(n):
               a=int(input())
               l.append(a)
    5. Create another for loop to add all the numbers.
       for i in range(n):
               s=s+l[i]
    6. Display sum.
    7. Stop.
         Psuedocode-
         BEGIN
           INPUT n
           INITIALIZE list l as empty
           INITIALIZE s = 0
           FOR i = 1 TO n DO
             INPUT a
             APPEND a TO l
           ENDFOR
           FOR i = 1 TO n DO
             s = s + l[i]
           ENDFOR
           PRINT s
         END
Q3. To reverse a string.
Algorithm :-
   1. Start.
   2. Input a string and name it str.
   3. Store the length of the string in a variable str_len.
   4. Take another variable n and its value at -1.
   5. Create a for loop from 0 to str_len.
   6. Use str and n to store the value in the reversed form in a new variable.
   7. Display the reversed string.
   8. Stop.
     Psuedocode-
     BEGIN
       INPUT str
       str_len = LENGTH(str)
       n = -1
       reversed_str = ""
       FOR i = 0 TO str_len - 1 DO
         reversed_str = reversed_str + str[n]
         n=n-1
       ENDFOR
       PRINT reversed_str
     END
Q4. To Find palindrome number
     Answer:-
     1. Start.
     2. Take an input as a.
     3. Create a for loop to reverse the integer with the body:
     a = n%10
       n=n//10
       s=s*10+a
     4. Check if the integer n matches the reversed integer.
     5. Display result.
     6. Stop.
        Psuedocode
        BEGIN
          INPUT n
          original_n = n
          s=0
           WHILE n > 0 DO
             a = n % 10
             n = n // 10
             s = s * 10 + a
           ENDWHILE
           IF original_n = s THEN
             PRINT "Palindrome"
             ELSE
               PRINT "Not a Palindrome"
             ENDIF
           END
Q5 To Find Leap Year or not
          1. Start.
          2. Take an input integer as n.
          3. Check if the number is divisible by 4.
          4. If so, check if the number is divisible by 100.
          5. If yes, check if the number is divisible by 400.
          6. Display leap year if the number is divisible by 4, 100 and 400.
          7. Display not a leap year if the number is not divisible by 4 or if divisible by 4 and
             100 but not by 400.
          8. Stop.
Psuedocode
BEGIN
  INPUT n
  IF n MOD 4 = 0 THEN
    IF n MOD 100 = 0 THEN
       IF n MOD 400 = 0 THEN
         PRINT "Leap Year"
       ELSE
         PRINT "Not a Leap Year"
       ENDIF
    ELSE
       PRINT "Leap Year"
    ENDIF
  ELSE
    PRINT "Not a Leap Year"
  ENDIF
END
Q6. To Swap Two Numbers with temporary variable
Algorithm.
   1. Start.
   2. Take two numbers as inputs a and b.
   3. Now enter the algorithm:
      c=a
      a=b
      b=c
   4. Display the reversed numbers.
   5. Stop.
       Psuedocode
       BEGIN
         INPUT a, b
            c=a
            a=b
            b=c
         PRINT a, b
       END
Q7. To Count vowels in a string
       Answer:
       1.   Start.
       2.   Take an input string as str.
       3.   Declare integer variable i=0.
       4.   Use a for loop to check for each index if there is a, e, i, o or u.
       5.   If there is , i = i+1.
       6.   Display i.
       7.   Stop.
            Pseudocode-
            BEGIN
              INPUT str
              i=0
              vowels = "aeiouAEIOU"
              FOR each character IN str DO
                IF character IN vowels THEN
                  i=i+1
                ENDIF
              ENDFOR
              PRINT i
            END
Q8. To Find the Anagrams of the given string
           1.   Start.
           2.   Input the string (s).
           3.   Generate all possible permutations of the characters in str.
           4.   Store each permutation in a list or set.
           5.   Output all unique anagrams.
           6.   End.
Psuedocode-
BEGIN
  INPUT s
  SET anagrams = EMPTY SET
  FUNCTION PERMUTE(current, remaining):
    IF LENGTH(remaining) = 0 THEN
      ADD current TO anagrams
    ELSE
      FOR i = 0 TO LENGTH(remaining) - 1 DO
        NEW_CURRENT = current + remaining[i]
        NEW_REMAINING = remaining WITHOUT remaining[i]
        CALL PERMUTE(NEW_CURRENT, NEW_REMAINING)
      ENDFOR
    ENDIF
  END FUNCTION
  CALL PERMUTE("", s)
  PRINT anagrams
END
Q9 Decimal to binary conversion
   1. Start.
   2. Take an input of decimal integer as n.
   3. Use the command;
      m= bin(n)
   4. Display m.
   5. Stop.
Psuedocode-
BEGIN
  INPUT n
  m = CONVERT n TO BINARY
  PRINT m
END
Bubble sort
   1.   Start.
   2.   Ask for input for the number of elements to be entered.
   3.   Enter all the elements in a list a.
   4.   Create the first for loop with the range x.
   5.   Create another nested loop with range x – i – 1.
   6. Use the following commands:
       if(a[j]>a[j+1]):
         a[j]=a[j]+a[j+1]
     a[j+1]=a[j]-a[j+1]
         a[j]=a[j]-a[j+1].
   7. Close both the active loops.
   8. Display a.
   9. Stop.
Psuedocode-
BEGIN
  INPUT x // Number of elements
  CREATE list a
  FOR i = 0 TO x - 1 DO
    INPUT a[i] // Enter elements
  ENDFOR
  FOR i = 0 TO x - 1 DO
    FOR j = 0 TO x - i - 2 DO
      IF a[j] > a[j+1] THEN
        a[j] = a[j] + a[j+1]
        a[j+1] = a[j] - a[j+1]
        a[j] = a[j] - a[j+1]
      ENDIF
    ENDFOR
  ENDFOR
  PRINT a // Sorted list
END