Menu Close

Find the integer and its number of occurrences

Find the given integer in the given list of integers and print the number of occurrences of that integer in the list.

INPUT
Enter the Elements:  64 34 7 12 22 11 7 
Enter the integer to find:  7

OUTPUT
2   # Prints the no:of occurrences of the integer 7 as given in input
Elements = list(map(int,input("Enter the Elements: ").split(" ")))
S = int(input("Enter the integer to find: "))
count=0
for i in range(len(Elements)):
    if Elements[i] == S:
        count = count+1
print(count)

INPUT_1:
Enter the Elements:   64  34  7  12  22  11  7
Enter the integer to find:   7

OUTPUT:
2


INPUT_2:
Enter the Elements:  7  64  34  45  34  24  29  34
Enter the integer to find:   34

OUTPUT:
3


INPUT_3:
Enter the Elements:  69  58  42  32  2  5  165  25  2000
Enter the integer to find:   2000

OUTPUT:
1


INPUT_4:
Enter the Elements:  56  98  45  25  99  98
Enter the integer to find:   98

OUTPUT:
2


ILLUSTRATION

Executed using python 3 in terminal linux


Morae Q!

  1. OS operating system module using path parameter.
  2. Find the smallest and largest integers after sorting using bubble sort.
  3. Find the integer and its number of occurrences.
  4. Algorithm complexity – Big O Notation with Examples.
  5. Linear search.
  6. Map module using series mapping and parallel mapping.
  7. Mapping and Transposing with Map Module.
  8. Map Module/built-in Function.
  9. Linux commands for managing files.
  10. Program which takes two lists and maps two lists into a dictionary.
  11. Splitting strings and substituting using regular expressions regex.
  12. Basics of regular expression Regex.
  13. Find the square value of the dictionary.
  14. Check whether the given key is present in the dictionary.
  15. Matching an expression only in specific places using regular expressions.
  16. Escaping special characters using regular expressions.
  17. Check the key.
  18. Grouping and sub-grouping using regular expressions.
  19. Generate a Dictionary that Contains Numbers in the Form (x , x*x).
  20. Algorithm complexity Big-Theta, Big-Omega and Big-O Notations.