Given an integer number N as input. Write a program to print the double triangular pattern of N lines using an asterisk(*) character as shown below.There is space after each asterisk character.
Explanation: N = 4 there should be 2 triangle pattern with 4 lines each.
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
If M = 4 and for polynomial A
For power 0, co-efficient is 5
For power 1, co-efficient is 0
For power 2, co-efficient is 10
For power 3, co-efficient is 6.
If N = 3 and for polynomial B
For power 0, co-efficient is 1
For power 1, co-efficient is 2
For power 2, co-efficient is 4.
Then polynomial A represents "6x^3 + 10x^2 + 5", the polynomial B represents "4x^2 + 2x + 1" and the addition of A and B is "6x^3 + 14x^2 + 2x + 6"
program to count how many hours we have to get coming newyear
how to sort the m*n matrix elements in ascending order
Product of Elements in the List
You are given a space-separated list of integers as input. Write a program to print the product of these numbers.
The first line of input contains space-separated integers.
In the example, there are
6 numbers, 1, 2, 3, 4, 5, 6.The product of list elements is
1 x 2 x 3 x 4 x 5 x 6 So, the output should be 720.
Sample Input :
1 11 13 21 19
Sample Output:
57057
Average of Given Numbers
You are given space-separated integers as input. Write a program to print the average of the given numbers.
The first line of input contains space-separated integers.
The output should be a float value rounded up to two decimal places.
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.
First Prime Number
You are given
N inputs. Write a program to print the first prime number in the given inputs.
Input
The first line of input is an integer
N. The next N lines each contain an integer.
Explanation
In the given example of
5 integers
1
10
4
3
2
The output should be
3.
Sample Input 1
5
1
10
4
3
2
Sample Output 1
3
Sample Input 2
4
2
3
5
7
Sample Output 2
2
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 15By ordering all the elements of the matrix in increasing order, the ordered matrix should be
1 2 3
5 10 11
15 20 30Sample Input 1
3 3
1 20 3
30 10 2
5 11 15sample out:
1 2 3
5 10 11
15 20 30 INPUT 2
2 5
-50 20 3 25 -20
88 17 38 72 -10sample output 2
-50 -20 -10 3 17
20 25 38 72 88