Write a program that converts a string like "124" to an integer 124.
Write Java program which calculator your annual expenses
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.
Given two polynomials A and B, write a program that adds the given two polynomials A and B.
The first line contains a single integer M.
Next M lines contain two integers Pi, Ci separated with space, where Pi denotes power and Ci denotes co-efficient of Pi for polynomial A.
After that next line contains a single integer N.
Next N lines contain two integers Pj, Cj separated with space, where Pj denotes power and Cj denotes co-efficient of Pj for polynomial B.Output
if we get "0" after adding two polynomials it should print "0" as output
str_user = input('Enter your string: ')
# ord('A') = 65 ord('Z') =90
print (*[ord(i.upper())-64 for i in str_user if 65<= ord(i.upper()) <= 90],sep='-')
if we give space between two words it is printing "-"
if we give "sudheer kumar" it should print 19-21-4-8-5-5-18 11-21-13-1-18 like this.
but it is printing like this 19-21-4-8-5-5-18-11-21-13-1-18 with no space
def main():
#Read string
inputString = input()
outputString=""
for letter in inputString:
number=getNumber(letter)
if(number!=-1):
outputString+=str(number)+"-"
else:
outputString+=letter
print(outputString[:-1])
#This function convert letter to number
def getNumber(letter):
alphabet = "abcdefghijklmnopqrstuvwxyz"
for i in range(0,len(alphabet)):
if letter.islower() and letter==alphabet[i]:
return i+1
if letter.isupper() and letter==alphabet[i].upper():
return i+1
return -1
main()
if we give python foundation we did not get the answer
what we get the answer is p-y-t-h-o-n- f-o-u-n-d-a-t-i-o-n
M, N = list(map(int,input().split()))
matrix = []
for i in range(M):
z = [int(x) for x in input().split()]
matrix.append(z)
K = int(input())
values = []
k =0
l =0
while (((N - k) > 0) and ((M - l) > 0)) and ((N - k)*(M-l)) > K:
for i in range(k,N):
values.append(matrix[k][i])
for j in range(l+1,M):
values.append(matrix[j][N-1])
for i in range(N-2,k-1,-1):
values.append(matrix[M-1][i])
for j in range(M-2,l,-1):
values.append(matrix[j][k])
values = values[-K:] + values[:-K]
c = 0
for i in range(k,N):
matrix[k][i] = values[c]
c += 1
for j in range(l+1,M):
matrix[j][N-1] = values[c]
c += 1
for i in range(N-2,k-1,-1):
matrix[M-1][i] = values[c]
c += 1
for j in range(M-2,l,-1):
matrix[j][k] = values[c]
c += 1
values = []
k += 1, l += 1, M -= 1, N -= 1
for i in matrix:
print(i)
we are getting when input is
4 4
1 2 3 4
5 6 7 8
9 10 11 12
13 14 15 16
3
but the output is:
9 10 11
5 6 12
1 7 8
when input is:
3 4
1 2 3 4
5 6 7 8
9 10 11 12
2
Hi sir for the question:
Non-Adjacent Combinations of Two Words
Given a sentence as input, find all the unique combinations of two words and print the word combinations that are not adjacent in the original sentence in lexicographical order.
you answered like this:
((https://www.assignmentexpert.com/homework-answers/programming-and-computer-science/python/question-177142))
here in the solution we are inserting "be be" at index 0, but if we give other input, then also "be be" will be the first line of output right sir?
So can you please verify and answer it again?write a c program to
Create an array of character strings and fill it with arbitrary strings of your choice. Pass it into a function named
“printStrings”. It should print all the strings inside the array. Note: You need to create an array of type char*.
[3:32 AM]
please help me in this
Let a class Person contains data members name and age. A constructor with two arguments
is used to assign name and age. Person is of two types a) Student and b) Teacher. class
Student contains data members i)course ii) Roll Number and iii)Marks and method
display() to display data related to student. Similarly, class Teacher contains data members
i) subject_assigned (May take this as a String) ii) contact_hour and method display () to
display data related to teacher. Implement this program using base class constructor in
derived class