Python 10 Programs for Beginners

0 Comments 0 tags

Program 1:Write a program to create a 2D array using NumPy. Output: Program 2: Write a program to convert a python list to a NumPy array. Output: Program 3: Write a program to create matrix of 3×3 from 11 to 30. Output: Program 4: Write a program to create a data frame to store data of candidates who appeared in

Find index of first occurrence when an unsorted array is sorted

0 Comments 0 tags

Find index of first occurrence when an unsorted an array is sorted Given an unsorted an array and a number x, find an index of first occurrence of x when

Find sum non repeating distinct elements array

0 Comments 0 tags

Find sum of non-repeating (distinct) elements in an array Given an integer an array with repeated elements, the task is to find the sum of all distinct elements in the

Find the only different element in an array

0 Comments 0 tags

Find the just distinct element in an array Given an array of integers where all elements are same except one element, find the just distinct element in the array. It

Queries to find first occurrence of a character in a given range

0 Comments 0 tags

Queries to find first occurrence of a character in a given range Given a string S of length N and an array Q[][] of dimension M X 3 consisting of

Program count occurrences of given character in string

0 Comments 0 tags

Program to count occurrence of a given character in a string Given a string S and a character ‘c’, the task is to count the occurrence of the given character

Find repeating element in sorted array of size n

0 Comments 0 tags

Find repeating element in a sorted array of size n Given a sorted an array of n elements containing elements in range from 1 to n-1 i.e. one element occurs

Find only non repeating element in a given array

0 Comments 0 tags

Find just non-repeating element in a given array Given an array A [] consisting of N (1 ? N ? 105) positive integers, the task is to find the just

Python replace all occurrences of a substring in a string

0 Comments 0 tags

Python – Replace all occurrences of a substring in a string Sometimes, when working with Python strings, we can have a problem in which we need to replace all occurrences

Count occurrences of a sub string with one variable character

0 Comments 0 tags

Count occurrences of a sub-string with one variable character Given two strings a and b, and an integer k which is the index in b at which the character can