Python Answers

Questions answered by Experts: 5 288

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

Prefix Suffix


write a program to check the overlapping of one string's suffix with the prefix of another string.


Sample input 1

ramisgood

goodforall

Sample output 1

good


Sample input 2

finally

restforall


Sample output 2

No overlapping


4. The Positive Ones

by CodeChum Admin

There are different kinds of numbers, but among them all, the most commonly used numbers in our daily lives are those positive ones. So, I only want you to count all the positive numbers from the 4 outputted values and print out the result.


Go and search for the positive ones among these four!


Input

A line containing four numbers (may contain decimal places) separated by a space.

2·-4·3.6·1

Output

A line containing an integer.

3




write a program to print the first prime number in the given inputs .


Rotate Matrix Rings

Given a matrix of order M*N and a value K, write a program to rotate each ring of the matrix clockwise by K elements. If in any ring has less than or equal to K elements, then don’t rotate that ring.

Input


The first line of input will be two space-separated integers, denoting the M and N.

The next M lines will contain N space-separated integers.

The next line will contain an integer, denoting K.

Output

The output should be M*N matrix by rotating the matrix by K elements.

Explanation

Therefore, by rotating each ring in clockwise direction by 3 elements will give (13, 9, 5, 1, 2, 3, 4, 8, 12, 16, 15, 14) and (10, 6, 7, 11). So the output should be

4 8 12 16

3 10 6 15

2 7 11 14

1 5 9 13

Sample Input 1

4 4

1 2 3 4

5 6 7 8

9 10 11 12

13 14 15 16

3


Sample Output 1

13 9 5 1

14 7 11 2

15 6 10 3

16 12 8 4


Sample Input 2

3 4

1 2 3 4

10 11 12 5

9 8 7 6

2

Sample Output 2

9 10 1 2

8 11 12 3

7 6 5 4


Write a program to output the following:

**********
*        *
* PYTHON *
*        *
**********





Charles wants to buy a nuckles in which

write a program to print frequency of each word


Maximum Product of the Digits

Given a range represented by two positive integers L and R. Find the number lying in the range having the maximum product of the digits.

Input


The first line of input will be an integer, denoting the number of test cases T.

The next T lines will contain two space-separated integers, denoting the L and R.

Output


The output should be T lines containing the the number with the maximum product of the digits in the range L and R for each test case.

Explanation


For example, if the given T is 2, read the L and R of the first test case in the next line. If the given L and R are 1 and 10 respectively. As 9 is the number with the maximum product of digits, the output for the first test case should be 9.

If the L and R are 15 to 30 respectively. The product of the digits of number 29 is 18. As 18 is the maximum product in the range, the output should be 29.

Sample Input 1

2

1 10

15 30

Sample Output 1

9

29


Sample Input 2

4

100 200

51 62

10 30

20 80

Sample Output 2

199

59

29

79


Write a PYTHON program to find the path with the largest sum. Tree can be in N level and draw the binary tree and accept a perfect and imperfect binary tree as an option from the user.



Enter the level of binary tree:4

This code generates binary tree with minimum 4 levels

The maximum sum is 341

The maximum sum path is 65 89 83 53 51




Enter the level of binary tree:2

This code generates binary tree with minimum 2 levels

The maximum sum is 341

The maximum sum path is 65 89 83 53 51  

----Both the sum values are same..but i want based on levels


Did you know that in lotteries, a 3-digit number with the same numbers in all digits like 777 will hit the jackpot in a casino? In the same manner, let's make a program that will test if a certain 3-digit number hits a jackpot or not by identifying if all the digits of a given number is the same as the second inputted number. If it is, print "Jackpot!"; else, print "Nah".

Let's try this out now!


Input

A line containing two integers separated by a space.


777·7

Output

A line containing a string.


Jackpot!
LATEST TUTORIALS
APPROVED BY CLIENTS