Questions: 5 831

Answers by our Experts: 5 728

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Search & Filtering

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?

The volume of a sphere is 4/3 pi r cube. write a function called print_volume(r) that takes an argument for the radius of the sphere and print the volume of the sphere. Call your print_volume function three times with different values for radius


Given polynomial, write a program that prints polynomial in Cix^Pi + Ci-1x^Pi-1 + .... + C1x + C0 format.


Input

The first line contains a single integer N.

Next N lines contain two integers Pi, Ci separated with space, where Pi denotes power and Ci denotes coefficient of Pi.


Output

Print the polynomial in the format Cix^Pi + Ci-1x^Pi-1 + .... + C1x + C0, where Pi's are powers in decreasing order, Ci is coefficient, and C0 is constant. There will be space before and after the plus or minus sign.

If the coeff is zero, then don't print the term.

If the term with the highest degree is negative, the term should represent -Cix^Pi.

For the term where power is 1, represent it as C1x instead of C1x^1.

If the polynomial degree is zero and the const term is also zero, then print 0 to represent the polynomial.

For term Cix^Pi, if the coeff of the term Ci is 1, print x^Pi instead of 1x^Pi.


Constraints

N <= 100 0 <= Pi < 1000 -1000 <= Ci <= 1000


Sample Input

5

0 2

1 3

2 1

4 7

3 6

Output:


7x^4 + 6x^3 + x^2 + 3x + 2

Given a list of numbers, write a program to print the smallest positive integer missing in the given numbers.Input


The input will be a single line containing numbers separated by space.Output


The output should be a single line containing the smallest missing number from given numbers.Explanation


For example, if the input numbers are 3, 1, 2, 5, 3, 7, 7.

The number 1, 2, 3 are present. But the number 4 is not. So 4 is the smallest positive integers that is missing from the given numbers.




Given date-time D, write a program to print the time left for the next New Year.Input


The input will be a single line containing the date-time in the string format similar to "Dec 30 2020 02:43 PM".Output


The output should be a single line containing hours and minutes left for the next new year in the format similar to "33 hours 17 minutes".Explanation


For example, if the given date-time is "Dec 30 2020 02:43 PM", the difference between "Dec 30 2020 02:43 PM" and "Jan 1 2021 00:00 AM" is 1 day 9 hours 17 minutes. The difference in hours and minutes is 1 * 24 + 9 hours and 17 minutes. So the output should be "33 hours 17 minutes".




Given two dates D1 and D2, write a program to count the number of Saturdays and Sundays from D1 to D2 (including D1 and D2).

The date in string format is like "8 Feb 2021".Input


The first line of input will contain date D1 in the string format.

The second line of input will contain date D2 in the string format.Output


The output should be a single line containing two integers separated by space.Explanation


For example, if the given dates are "25 Jan 2021" and "14 Feb 2021", the Saturdays and Sundays dates from "25 Jan 2021" to "14 Feb 2021" are

"30 Jan 2021" is a Saturday

"31 Jan 2021" is a Sunday

"6 Feb 2021" is a Saturday

"7 Feb 2021" is a Sunday

"13 Feb 2021" is a Saturday

"14 Feb 2021" is a Sunday

So the output should be

Saturday: 3

Sunday: 3




Implement the following features:

  • the board should be stored as a three-element list, while each element is another three-element list (the inner lists represent rows) so that all of the squares may be accessed using the following syntax:

board[row][column]

  • each of the inner list's elements can contain 'O', 'X', or a digit representing the square's number (such a square is considered free)
  • the board's appearance should be exactly the same as the one presented in the example.

Drawing a random integer number can be done by utilizing a Python function called randrange(). The example program below shows how to use it (the program prints ten random numbers from 0 to 8).

Note: the from-import instruction provides an access to the randrange function defined within an external Python module called random.

from random import randrange

for i in range(10):

   print(randrange(8))


LATEST TUTORIALS
APPROVED BY CLIENTS