Question

Write a program that reads a line and a substring. It should then display the number of the occurrence of the given substring in the line.

Answer

Get the step-by-step solution for this question inside the Vidyadip app.

Get the answer in the app

Need a full question paper?

Generate a complete, print-ready paper with questions like this in minutes — across 16+ boards, with answer keys.

Start Generating Free

Similar questions

Write a program using function to accept the list from the user and sort the number using bubble sort.
Write a python program using function to accept a list as parameter and return the sum of all the list elements.
Write definition of a Method AFIND(CITIES) to display all the city names from a list of CITIES, which are starting with alphabet A.

For example:If the list CITIES contains[“AHMEDABAD”,”CHENNAI”,”NEW DELHI”,”AMRITSAR”,”AGRA”]The following should get displayedAHEMDABADAMRITSARAGRA

Write a script to create a list of 10 random integers. Using the concept of slicing, create two more lists –one containing first five elements of the original list, and the other containing last 5 elements of the original list. Then display all the three lists.

Write a program that accepts a comma separated sequence of words as input and prints the words in a comma-separated sequence after sorting them alphabetically.
Suppose the following input is supplied to the program:
hi,we,are,learning
Then, the output should be:
are,hi,learning,we

WAP using function to change the alternate index value of the element.

Consider the following table HOSPITAL.

Table: HOSPITAL

PNo Name Age Department DateofAdm Charges Sex
1 Mayank 65 Surgery 23/02/2018 600 M
2 Babita 24 ENT 01/01/2019 400 F
3 Kashish 45 Orthopaedic 19/12/2018 400 M
4 Tarun 12 Surgery 01/10/2018 600 M
5 Manisha 36 ENT 12/01/2018 400 F
6 Imran 16 ENT 24/02/2018 400 M
7 Ankita NULL Cardiology 20/08/2018 800 F
8 Zoya 45 Gynecology 22/02/2018 500 F
9 Kush 19 Cardiology 13/01/2019 800 M
10 Shalini 31 Medicine 19/02/2018 300 F

Note: PNo is the primary key in the above table.

Write SQL commands for the statements (a) to (g) on the table HOSPITAL.

(a) To display the details of all the patients whose name starts with the alphabet ‘Z’.

(b) To change the age of the patient Kush to 20.

(c) To increase the charges of all the patients by 5%.

(d) To remove the record of the patient whose Name is Tarun.

(e) To add another column DocName(Doctor Name) of the type varchar in the above table.

(f) To display patient detail whose age is missing(null).

(g) To decrease the charges by 5% of all the patients admitted to the ENT department.

Write a program to generate a dictionary that contains (i, i*i) such that it is an integral number between 1 and n (both included) and then the program should print the dictionary.
For the following input is supplied to the program:
Then, the output should be:
{1: 1, 2: 4, 3: 9, 4: 16, 5: 25, 6: 36, 7: 49, 8: 64}

WAP to find the sum of first n terms of the following series:
$x-x^2+x^3+\ldots$
Write a script to create a list of 10 random integers and display it. Then input an integer from the user and check whether it is present in the list. If it is present, find its location in the list using index() method and remove it from the list using pop() method. If the element is not present, then display an appropriate message.