Reverse the Sentence
This Program name is Reverse the Sentence. Write a Python program to Reverse the Sentence, it has two test cases
The below link contains Reverse the Sentence question, explanation and test cases
https://docs.google.com/document/d/1LuMChyEPcL8qBRrDAap5By4hclNuodwH/edit?usp=sharing&ouid=104486799211107564921&rtpof=true&sd=true
We need exact output when the code was run
Diamond
Given an integer value N, write a program to print a number diamond of 2*N -1 rows as shown below.
Input
The first line of input is an integer N.
Explanation
In the given example, the number of rows in the diamond is
5.So, the output should be
. . . . 0 . . . .
. . . 0 0 0 . . .
. . 0 0 0 0 0 . .
. 0 0 0 0 0 0 0 .
0 0 0 0 0 0 0 0 0
. 0 0 0 0 0 0 0 .
. . 0 0 0 0 0 . .
. . . 0 0 0 . . .
. . . . 0 . . . .
Sample Input 1
5
Sample Output 1
. . . . 0 . . . .
. . . 0 0 0 . . .
. . 0 0 0 0 0 . .
. 0 0 0 0 0 0 0 .
0 0 0 0 0 0 0 0 0
. 0 0 0 0 0 0 0 .
. . 0 0 0 0 0 . .
. . . 0 0 0 . . .
. . . . 0 . . . .
Sample Input 2
4
Sample Output 2
. . . 0 . . .
. . 0 0 0 . .
. 0 0 0 0 0 .
0 0 0 0 0 0 0
. 0 0 0 0 0 .
. . 0 0 0 . .
. . . 0 . . .
Sum of N terms in Harmonic series:
Given integer N as input, write a program to display the sum of the first N terms in harmonic series. The series is: 1 + 1/2 + 1/3 + 1/4 + 1/5 ... + 1/N (N terms).
The first line of input is an integer N.
Output
Print the sum rounded up to 2 decimal places.
For
N = 5The sum of first 5 terms in harmonic series is 1 + 1/2 + 1/3 + 1/4 + 1/5
So, the output should be
2.28.
Sample Input 1
5
Sample Output 1
2.28
Sample Input 2
3
Sample Output 2
1.83
Diamond Crystal
Given an integer value N, write a program to print a diamond pattern of 2*N rows as shown below.
Input
The first line of input is an integer N.
Explanation
In the given example, the number of rows in the diamond is
2*5 = 10.So, the output should be
/\
/ \
/ \
/ \
/ \
\ /
\ /
\ /
\ /
\/
Sample Input 1
5
Sample Output 1
/\
/ \
/ \
/ \
/ \
\ /
\ /
\ /
\ /
\/
Sample Input 2
3
Sample Output 2
/\
/ \
/ \
\ /
\ /
\/
The game is played as follows:
The game consists of 3 turns, and the aim of the game is to score as many points as possible,Each turn begins with a roll of 6 standard dice,Matching dice (2 or more of the same number) can be set aside for points, and the remaining dice can then be re-rolled in an attempt to score more points 5s Points are “amount of dice * number on dice”, e.g. rolling three 5s is worth 15 points,The player chooses whether to set matching dice aside and whether to re-roll remaining dice, If the player chooses not to re-roll the dice, the points accumulated in the turn are added to their score and the turn ends, If no dice can be put aside after a roll, the player loses the points the potential points and the turn ends – hence, the player must decide how far to push their luck with additional rolls,The game involves quite a lot of luck, but there is also a small amount of strategy in choosing whether to set matching dice aside and whether to re-roll the remaining dice.
Two Words Combination
Given a sentence as input, print all the unique combinations of two words in lexicographical order.Input
The input will be a single line containing a sentence.Output
The output should be multiple lines, each line containing the unique combination of two words in lexicographical order.Explanation
For example, if the given sentence is "raju plays cricket", the possible unique combination of two are (cricket, plays), (cricket, raju), (plays, raju). So the output should be
cricket plays
cricket raju
plays rajuSample Input 1
raju plays cricket
Sample Output 1
cricket plays
cricket raju
plays raju
Sample Input 2
python is a programming language
Sample Output 2
a is
a language
a programming
a python
is language
is programming
is python
language programming
language python
programming python
Max Contiguous Subarray
Given a list of integers, write a program to identify contiguous sub-list that has the largest sum and print the sub-list. Any non-empty slice of the list with step size 1 can be considered as contiguous sub-list.Input
The input will contain space-separated integers, denoting the elements of the list.Output
The output should be space-separated integers.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. So the output should be 5 -1 2
Sample Input 1
2 -4 5 -1 2 -3
Sample Output 1
5 -1 2
Sample Input 2
-2 -3 4 -1 -2 1 5 -3
Sample Output 2
4 -1 -2 1 5
Last half of List
This Program name is Last half of List. Write a Python program to Last half of List, it has two test cases
The below link contains Last half of List question, explanation and test cases
https://docs.google.com/document/d/12r-Wk4K7GMmpiGxHWymMhcXkUMBy8Okg/edit?usp=sharing&ouid=104486799211107564921&rtpof=true&sd=true
We need exact output when the code was run
First and Last Elements of List
This Program name is First and Last Elements of List. Write a Python program to First and Last Elements of List, it has two test cases
The below link contains First and Last Elements of List question, explanation and test cases
https://docs.google.com/document/d/1LSR6d1QTXfpHGouv_GmIKkL595o6R_IK/edit?usp=sharing&ouid=104486799211107564921&rtpof=true&sd=true
We need exact output when the code was run