Word Count - 2
Given a sentence S, write a program to print the frequency of each word in S, where words are sorted in alphabetical order.
Input
The input will be a single line containing a string S.
Output
The output contains multiple lines, with each line containing a word and frequency of each word in the given string separated by ": ", where words are sorted in alphabetical order.
Explanation
For example, if the given sentence is "Hello world, welcome to python world", the output should be
Hello: 1
python: 1
to: 1
welcome: 1
world: 2
Sample Input 1
Hello world welcome to python world
Sample Output 1
Hello: 1
python: 1
to: 1
welcome: 1
world: 2
Sample Input 2
This is my book
Sample Output 2
This: 1
book: 1
is: 1
my: 1
A matrix m x n that has relatively few non-zero entries is called sparse matrix. It may be represented in much less than m n space. An mxn matrix with k non-zero entries is sparse if k<<m <n. It may be faster to represent the matrix compactly as a list of the non-zero indexes and associated entries. WAP to represent a sparse matrix using linked list.
Write a program to calculate gross and net pay of employee from
basic salary. Create employee class which consists of employee
name, emp_id, and basic salary as its data members. Use
parameterized constructor in the derived class to initialize data
members of the base class and calculate gross and net pay of the
employee in the derived class.
Gardening
We have a task to do Gardening.
Given two boolean values
isGrassTrimmerFound
and
isWaterHosePipeFound
Sample Input 1
Sample Output 1Sample Input 2Sample Output 2
Acronyms
You are given some abbreviations as input. Write a program to print the acronyms separated by a dot(
.) of those abbreviations.
Input
The first line of input contains space-separated strings.
Explanation
Consider the given abbreviation,
Indian Administrative Service. We need to consider the first character in each of the words to get the acronym. We get the letter I from the first string Indian, we get the letter A from the second word Administrative, and we get the letter S from the third word Service. So, the final output should be I.A.S.
Sample Input 1
Indian Administrative Service
Sample Output 1
I.A.S
Sample Input 2
Very Important Person
Sample Output 2
V.I.P
Average of Given Numbers
You are given space-separated integers as input. Write a program to print the average of the given numbers.
Input
The first line of input contains space-separated integers.
Output
The output should be a float value rounded up to two decimal places.
Explanation
In the example, input is
1, 0, 2, 5, 9, 8. The sum of all numbers present in the list is 25, and their average is 25/6.
So, the output should be
4.17.
Sample Input 1
1 0 2 5 9 8
Sample Output 1
4.17
Sample Input 2
1 2 3 4 5
Sample Output 2
3.0
Largest Number in the List
You are given space-separated integers as input. Write a program to print the maximum number among the given numbers.
Input
The first line of input contains space-separated integers.
Explanation
In the example, the integers given are
1, 0, 3, 2, 9, 8. The maximum number present among them is 9. So, the output should be 9.
Sample Input 1
1 0 3 2 9 8
Sample Output 1
9
Sample Input 2
-1 -3 -4 0
Sample Output 2
0