Numbers in String - 1
Given a string, write a program to return the sum and average of the digits of all numbers that appear in the string, ignoring all other characters.
Input
The input will be a single line containing a string.
Output
The output should contain the sum and average of the digits of all numbers that appear in the string.
Note: Round the average value to two decimal places.
Explanation
For example, if the given string is "I am 25 years and 10 months old", the digits of all numbers that appear in the string are 2, 5, 1, 0. Your code should print the sum of all digits(8) and the average of all digits(2.0) in the new line.
Sample Input 1
I am 25 years and 10 months old
Sample Output 1
8
2.0
Sample Input 2
Tech Foundation 35567
Sample Output 2
26
5.2
Sample Input 3
Anjali25 is python4 Expert
Sample Output 3
11
3.67You've to develop table tennis fantasy league.Here're details of league:no. of team (4) and no. of player/team (3). Each team will have to play
other team twice,so you can calculate total number of matches.
1.addPlayers():add player data.
Sr. No. Name Type Point Availability
1 Name Player 1 Attacking 35.93 true
3.assignRanks(): Assign ranking to 4 teams on the basis of random number.
4.teamSelection(): Form team on basis of strategy,defensive team will prefer two defensive
players and one attacking player.Whereas an attacking team will prefer two attacking players and
one defensive player.
6.generateMatchStats():This function will generate match status.Assign winning team players’ point
b/w 10 & 20 randomly. For losing team assign them point between 5 & 10 randomly.
7.bestPlayersInMatch():Display information of best player of both teams
8.UpdatePlayerPoints():After match update ranking point of players
9.printLeaderBoard():Print sorted list of player in all teams
Briefly describe Insertion sort algorithm using the following array of numbers. 10, 5, 15, 3, 12 ii Write an algorithm in pseudocode for the Insertion sort. (15 marks ) (10 marks) Analysing the following algorithm given in pseudocode. After executing the program what will be printed on the screen, if n-5 and elements of the array A is initialized to (10,5,15, 3, 12), Write the steps to show how you decide your answer. I/ lambda 10 an array of n Funct (A, n) for 1=n-1 to 1 for 1 to i if A1 temp Al A(j) = A(j + 1) Aff + 11 = temp for 1 - 1ton print Alil A[j+1] elements -A(1,..n) (15 marks) According to the algorithm given in the above question 1.iii, how many times will the comparison statement be executed.
Mean, Median and Mode
Given a list of integers, write a program to print the mean, median and mode.
Mean - The average value of all the numbers.
Median - The mid point value in the sorted list.
Mode - The most common value in the list. If multiple elements with same frequency are present, print all the values with same frequency in increasing order.Input
The input will be a single line containing space-separated integers
Sample Input 1
2 4 5 6 7 8 2 4 5 2 3 8
Sample Output 1
Mean: 4.67
Median: 4.5
Mode: 2
Sample Input 2
2 6 3 1 8 12 2 9 10 3 4
Sample Output 2
Mean: 5.45
Median: 4
Mode: 2 3
.
convert to prefix:
( AX * ( BX * ( ( ( CY + AY ) + BY ) * CX ) ) )
What is the main difference between the PC and Apple?
Which of the following are not viewed as principles guiding design?
Numbers in String - 2
Given a string, write a program to return the sum and average of the numbers that appear in the string, ignoring all other characters.
Input
The input will be a single line containing a string.
Output
The output should contain the sum and average of the numbers that appear in the string.
Note: Round the average value to two decimal places.
Explanation
For example, if the given string is "I am 25 years and 10 months old", the numbers are 25, 10. Your code should print the sum of the numbers(35) and the average of the numbers(17.5) in the new line.
Sample Input 1
I am 25 years and 10 months old
Sample Output 1
35
17.5
Sample Input 2
Tech Foundation 35567
Sample Output 2
35567
35567.0
Numbers in String - 1
Given a string, write a program to return the sum and average of the digits of all numbers that appear in the string, ignoring all other characters.
Input
The input will be a single line containing a string.
Output
The output should contain the sum and average of the digits of all numbers that appear in the string.
Note: Round the average value to two decimal places.
Explanation
For example, if the given string is "I am 25 years and 10 months old", the digits of all numbers that appear in the string are 2, 5, 1, 0. Your code should print the sum of all digits(8) and the average of all digits(2.0) in the new line.
Sample Input 1
I am 25 years and 10 months old
Sample Output 1
8
2.0
Sample Input 2
Tech Foundation 35567
Sample Output 2
26
5.2Ordered Matrix
Given a M x N matrix, write a program to print the matrix after ordering all the elements of the matrix in increasing order.
Input
The first line of input will contain two space-separated integers, denoting the M and N.
The next M following lines will contain N space-separated integers, denoting the elements of each list.
Output
The output should be M lines containing the ordered matrix.
Note: There is a space at the end of each line.
Explanation
For example, if the given M is 3 and N is 3, read the inputs in the next three lines if the numbers given in the next three lines are the following.
1 20 3
30 10 2
5 11 15
By ordering all the elements of the matrix in increasing order, the ordered matrix should be
1 2 3
5 10 11
15 20 30
Sample Input 1
3 3
1 20 3
30 10 2
5 11 15
Sample Output 1
1 2 3
5 10 11
15 20 30
Sample Input 2
2 5
-50 20 3 25 -20
88 17 38 72 -10
Sample Output 2
-50 -20 -10 3 17
20 25 38 72 88