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

More distinct letters

you are given a list of strings, write a program to print the string with the maximum number of distinct letters. If there are more than one such strings, print the string which comes first in alphabetical order. Note: consider upper and lower case letters are different.

Input: The input is a single line containing the strings separated by a space.

Output: The output should be a single line containing the string with maximum distinct characters.

Explanation:

In the example, the given list of strings are raju , plays , golf. The word plays has the maximum number of distinct letters. So the output should be plays.


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.

Sample Input 1

2 -4 5 -1 2 -3

Sample Output 1

6

Sample Input 2

-2 -3 4 -1 -2 1 5 -3

Sample Output 2

7
Column Title
You are given a number that denotes a column in the Excel Sheet, write a program to calculate the column name in the Excel Sheet. The naming of columns in the Excel Sheet is as follows
Column Name Column Number
A 1
B 2
C 3
... ...
X 24
Y 25
Z 26
AA 27
AB 28
... ...
BA 53
... ...
ZZ 702
AAA 703
... ...
Input
The first line of input is a positive integer.
Output
The output should be a single line containing the column name.
Explanation
For example, if the given column number is 42.
The column names with single alphabets end at 26. Further column names will contain two alphabets.
Therefore, for the column number 42, the first alphabet in the column name is A and the remaining number is (42-26) is 16.
The second alphabet of the column name is the 16th alphabet, which is P.
So, the output should be AP.
def product(a,b):
    c=a+b
    return c
x=int(input("enter product"))
y=int(input(("enter price"))
print(product(x,y))




Suppose there is XYZ Company and there are different departments like production, marketing, finance, sales etc. Manager of the company want to know about the detail of the employees who are highly paid in each of the department. Write a program using the concept of classes to implement the same
Do Exercise 6.4 from your textbook using recursion and the is_divisible function from Section 6.4. Your program may assume that both arguments to is_power are positive integers. Note that every positive integer that has an exponent of 0 is a power of "1". This includes "0" and "1", itself.

After writing your is_power function, include the following test cases in your script to exercise the function and print the results:

print("is_power(10, 2) returns: ", is_power(10, 2))

print("is_power(27, 3) returns: ", is_power(27, 3))

print("is_power(1, 1) returns: ", is_power(1, 1))

print("is_power(10, 1) returns: ", is_power(10, 1))

print("is_power(3, 3) returns: ", is_power(3, 3))

Write a program to output the following:

  __
 ('')
 ( (
  ) )
 ( (
  ) )
 ( (
  ) )
 ( (
  ) )
   V




#loop through displayList
for i in range(0,len(displayList)):
#Test if the fist item in the current sub-list contains the text "Price Level
#Tip: Remeber that each sub-list is a (displayList). So you have
    #       to access its items via displayList followed by TWO indexes.
if
    #Extract the second item from the current sub-list into variable called priceLevel
        
    #Test if priceLevel is between previousPrice and currentPrice OR
    #        priceLevel == previousPrice OR
    #    priceLevel == currentPrice
    if priceLevel >= previousPrice and priceLevel <= currentPrice or priceLevel == previousPrice or priceLevel == currentPrice:


        #Sound the alarm. Pass in the frequency and duration.
        if self.__currentPrice > self.__previousPrice:
            frequency = 800
            duration = 700
        else:
            frequency = 400
            duration = 700
        winsound.Beep(frequency, duration)

        #Print the text 'Alarm' with a green background color, so that the user
        #can go back and check when the alarm was sounded.

given a sentence S. and a positive integer N. write a program to shift the sentence by N words to the right

INPUT

The first line pf input is a string S.

The second line of input is an integer N

OUTPUT

The output should be a single line containing the sentence by shifitng the N word to the right

EXPLANATION

in the example the sentence is python is a programming language and N is 2 shift the sentence two words to the right which means the last two words will be moved to the front.

so the output should be programming language python is a

sample input 1

Python is a programming language

2

sample output 1

programming language Python is a

sample input 2

Cats hate water

4

Sample output 2

water Cats hate



you given a list of prices where prices[i] is the price of a given stock o the i th day write a program to print the maximum profit by choosing a single day to buy a stock and choosing a different day in the future to sell that stock if these is no profit that can be achieved return 0

INPUT

the input is a single line containing space seperated integers

OUTPUT

the output should be an integer

Explanation

in the example the given prices are 7 1 5 3 6 4

buying stocks on day two having price 1 and selling them on the fifth day having price 6 would give the maximum profit which is 6 - 1

so the output should be 5.

sample input 1

7 1 5 3 6 4

sample output 1

5

sample input 2

1 11 13 21 19

sample output 2

20



LATEST TUTORIALS
APPROVED BY CLIENTS