Given the number of the month, write a program to print the name of the month
I don't understand the above code with import tools. Can you please send the code without import tools like combinations.
write a python program to accept a string. do this continuosly until the user enters the enter key only. then save all those strings into a file named user_strings . text . open and read the saved file to print the number of occurence of the vowels and non-vowels.
Add two polynomials
write a program that adds the given two polynomials A and B.
Input
The first line contains a single integer M.
Next M lines contain two integers Pi, Ci of poly A
After that next line contains a single integer N.
Next N lines contain two integers Pj, Cj of poly B
Output
Print the addition of poly's A and B.
The format for printing polynomials is: Cix^Pi + Ci-1x^Pi-1 + .... + C1x + C0, where Pi's are powers in decreasing order, Ci is co-efficient and C0 is constant, there will be space before and after the plus or minus sign.
If co-eff is zero then don't print the term.
If the term with highest degree is negative, the term should be represented as -Cix^Pi.
For the term where power is 1 represent it as C1x instead of C1x^1.
If the degree of poly is zero and the constant term is also zero, then just print 0 to represent the poly.
For term Cix^Pi, if the coefficient of the term Ci is 1, simply print x^Pi instead of 1x^Pi.
Sample input
4
0 5
1 0
2 10
3 6
4
0 -5
1 0
2 -10
3 -6
Expected output
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.
can anyone please give the code?
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.
can anyone please give the code for this?
inputLine = input()
letters = "abcdefghijklmnopqrstuvwxyz"
secreMessage=""
for l in inputLine:
indexLetter=letters.find(l.lower())
if(indexLetter!=-1):
indexLetter+=1
secreMessage+=str(indexLetter)+"-"
else:
secreMessage+=l
print(secreMessage[:-1])
if we give input"sudheer kumar" it should print "s-u-d-h-e-e-r k-u-m-a-r" like this
but it is printing "s-u-d-h-e-e-r- k-u-m-a-r" like this
so can anyone please give correct code?
Write a program that simulates rolling a 6-sided die until you get 3 odd numbers in a row.
Sample run
Let’s roll some dice!
You rolled a 3
You rolled a 5
You rolled a 4
You rolled a 1
You rolled a 6
You rolled a 1
You rolled a 4
You rolled a 1
You rolled a 3
You rolled a 5
Three in a row in 10 rolls.
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