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:
I am 25 years and 10 months old
output:
35
17.5sample Input:
Lear4 python7
output:
11
5.5
Write a python statement for the following. Assigns the product of 10 and 15 to the variable product. Then Subtracts the variable down_payment from the variable total and assigns the result to the variable due. And Multiplies the variable subtotal by 0.15 and assigns the result to the variable total. Then Prompts the user to enter his or her favorite color and assigns the user’s input to a variable named color.and Assume the variable sales references a float value 56.3355. Round the value to two decimal points.
First Perfect Square
Given two integers (M and N), write a program to print the first perfect square in a given range.Input
The first line of input will contain a positive integer (M).
The second line of input will contain a positive integer (N).Output
The output should be a single line containing the first perfect square in a given range.Explanation
For example, if the given numbers are M is 4 and N is 16, the perfect squares from 4 to 16 are 4(2 * 2), 9(3 * 3), and 16(4 * 4), as the first perfect square is 4. So the output should be 4.
Sample Input 1
4
16
Sample Output 1
4
Sample Input 2
5
8
Sample Output 2
No Perfect Square
string A is "Tea is good for you", k is 3 then output should be "is good."
Here words "Tea", "for", "you" length is equal to 3, so these words are removed from string.
Ordered 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 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 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
String Rotation
Given two strings(S1 and S2), write a program to determine if a string S2 is a rotation of another string S1.
Input
The first line of the input will be a string S1.
The second line of the input will be a string S2.Output
If string S2 is a rotation of another string S1, print number of right rotations made by string S1 to match the string S2. Otherwise, print "No Match".
Where right rotation means all elements are moving towards the right side by one place where the last element will be placed in the first place example, one right rotation of "python" is "npytho"
For example, if the given strings S1 and S2 are "python" and "onpyth",
The first right rotation of s1 is "npytho" which is not equal to string S2"onpyth"
The second right rotation of s2 is "onpyth" which is equal to string S2 "onpyth".
So output 2
Sample Input 1
python
onpyth
Sample Output 1
2
Sample Input 2
Python
Python
Sample Output 2
Please follow the introduction to write Python code for rounding withour use round function .screenshot and explanation request!Thanks in advance!
1. first need to check if the number is positive or negative and save
2. Get rid of any numbers you don't need.
4. Get the last digit.
5. if >5 add 1 , If less than 5, leave it , If equal to 5, the last number should be even.
6. Convert it back to decimal
Write a function round(number[, ndigits]) that models the behavior of the built-in function.
Input: a float number, and an optional argument, a non-negative integer ndigits. The default parameter
value for ndigits is 0.
Output: if ndigits is 0, an integer, else a float, rounded to ndigits after the decimal point. If the first
dropped digit is greater than 5, round up; if the first dropped digit is less than 5, round down; else round
in such a way that the remaining digit in the smallest position is even.
write a python program to add two polynomials.
Polynomial1 = 6x^3 + 10x^2 + 5
Polynomial2 = 4x^2 + 2x + 1
output
6x^3 + 14x^2 + 2x + 6
NOTE: Use string formatting to Display the Output
Make two 2D-points, points in cartesian plane. Calculate the distance between these points.
Given a sentence S, write a program to print the frequency of each word in S. The output order should correspond with the word's input order of appearance.