Write a program to check the overlapping of one string's suffix with the prefix of another string.
You are given a square matrix A of dimensions NxN. You need to apply the below given 3 operations on the matrix A.
Rotation: It is represented as R S where S is an integer in {90, 180, 270, 360, 450, ...} which denotes the number of degrees to rotate. You need to rotate the matrix A by angle S in the clockwise direction. The angle of rotation(S) will always be in multiples of 90 degrees.
Update: It is represented as U X Y Z. In initial matrix A (as given in input), you need to update the element at row index X and column index Y with value Z.
After the update, all the previous rotation operations have to be applied to the updated initial matrix.
how to print vowels and consonants and spaces are not counted
Case Conversion
Given a string in camel case, write a python program to convert the given string from camel case to snake case.Input
The input will be a single line contain a string.Output
The output should contain the given word in snake case.Explanation
For example, if the given word is "Python Learning" in camel case, your code should print given word in snake case "python_learning".
Sample Input 1
Python Learning
Sample Output 1
Python_learning
Write a program to check the overlapping of one string's suffix with the prefix of another string.
Input
The first line of the input will contain a string A.
The second line of the input will contain a string B.
Output
The output should contain overlapping word if present else print "No overlapping".
Explanation
For example, if the given two strings, A and B, are "ramisgood" "goodforall"
The output should be "good" as good overlaps as a suffix of the first string and prefix of next
Given two polynomials A and B, write a program that adds the given two polynomials A and B.
input:
4
0 5
1 0
2 10
3 6
4
0 -5
1 0
2 -10
3 -6
expected output:
your output:
(nothing)
input:
4
0 5
1 0
2 10
3 6
3
0 1
1 2
2 4
output:
6x^3 + 14x^2 + 2x + 6
Errors/Warnings:
Traceback (most recent call last):
File "main.py", line 69, in <module>
a = input_polinom()
File "main.py", line 2, in input_polinom
n = int(input())
EOFError: EOF when reading a line
expected output:
6x^3 + 14x^2 + 2x + 6
How to convert the string from camel case to snake case using iterate over the words and using string slicing approximately
def max_sub_list(l:list):
if len(l) == 0:
print(0)
else:
max_sum = l[0]
for i in range(len(l)):
for j in range(i, len(l)):
if sum(l[j-i:j+1]) > max_sum:
max_sum = sum(l[j-i:j+1])
print(max_sum)
while True:
try:
arr = list(map(int,input().split()))
except ValueError:
continue
max_sub_list(arr)
Output:6
Traceback (most recent call last):
File "main.py", line 13, in <module>
arr = list(map(int,input().split()))
EOFError: EOF when reading a line
Can anyone give correct code
Summary
Code
DESCRIPTION
DISCUSS
Max Contiguous Subarray
Given a list of integers, write a program to identify the contiguous sub-list that has the largest sum and print the sum. Any non-empty slice of the list with step size 1 can be considered as a contiguous sub-list.
Input
The input will contain space-separated integers, denoting the elements of the list.
Output
The output should be an integer.
Explanation
For example, if the given list is [2, -4, 5, -1, 2, -3], then all the possible contiguous sub-lists will be,
[2]
[2, -4]
[2, -4, 5]
[2, -4, 5, -1]
[2, -4, 5, -1, 2]
[2, -4, 5, -1, 2, -3]
[-4]
[-4, 5]
[-4, 5, -1]
[-4, 5, -1, 2]
[-4, 5, -1, 2, -3]
[5]
[5, -1]
[5, -1, 2]
[5, -1, 2, -3]
[-1]
[-1, 2]
[-1, 2, -3]
[2]
[2, -3]
[-3]
Among the above contiguous sub-lists, the contiguous sub-list [5, -1, 2] has the largest sum which is 6.
Input
The input will be a single line containing two integers and operator(+, -, *, /, and %) similar to 3 + 5.
Output
If the given operator is "+", print the sum of two numbers.
If the given operator is "-", print the result of the subtraction of the two numbers.
If the given operator is "*", print the multiplication of the two numbers.
If the given operator is "/", print the result of the division of the two numbers.
If the given operator is "%", print the result of the modulus operation of the two numbers.