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 -3Sample Output 1
6Sample Input 2
-2 -3 4 -1 -2 1 5 -3Sample Output 2
7def product(a,b):
c=a+b
return c
x=int(input("enter product"))
y=int(input(("enter price"))
print(product(x,y))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