K Sum Unique Combinations
Given a list of integers, write a program to print the count of all possible unique combinations of numbers whose sum is equal to K.
Input
The first line of input will contain space-separated integers.
The second line of input will contain an integer, denoting K.
Output
The output should be containing the count of all unique combinations of numbers whose sum is equal to K
All possible unique combinations of the given list are
(6,) (2,) (4,) (1,) (3,)
(2, 4) (1, 2) (3, 4) (4, 6) (1, 4) (2, 3) (2, 6) (3, 6) (1, 6) (1, 3)
(3, 4, 6) (2, 3, 6) (1, 2, 6) (1, 2, 3) (1, 4, 6) (1, 3, 4) (2, 3, 4) (1, 3, 6) (2, 4, 6) (1, 2, 4)
(2, 3, 4, 6) (1, 2, 3, 4) (1, 2, 4, 6) (1, 2, 3, 6) (1, 3, 4, 6)
(1, 2, 3, 4, 6)
-1 4 5 6 7 8 2 4 5 2 3 8
7
The unique combinations with the sum equal to 7 are
7
-1 8
3 4
2 5
-1 3 5
-1 4 4
-1 2 6
2 2 3
-1 2 2 4
Sample Input 1
2 4 6 1 3
6
Sample Output 1
3
Sample Input 2
-1 4 5 6 7 8 2 4 5 2 3 8
7
Sample Output 2
9
Word Mix
Given a sentence, write a program to mix the words based on their index locations. The first word in the output should contain the first letter of each word in the given sentence and the second word should contain the second letter of each word in the given sentence and so on.
Note: The nth word in the output should contain nth letter of each word in the given sentence. The letters of the output word should be in same order as the words in the given sentence. If a word in the given sentence doesn't have n-letters, you can skip it while considering the letters of the n-th word.
Input
The input will be a single line containing a string.
Welcome to your first problem Mix Word
W t y f p Wtyfp
e o o i r eooir
l u r o luro
c r s b crsb
o t l otl
m e me
e m em
So the output should be
Wtyfp eooir luro crsb otl me em
Sample Input 1
Welcome to your first problem
Sample Output 1
Wtyfp eooir luro crsb otl me em
Sample Input 2
Do you eat ice cream
Sample Output 2
Dyeic ooacr utee a m: Write a small program that plays a simple number-guessing game. The user will try to guess the secret number until they get it right. That means it will keep looping as long as the guess is different from the secret number. You must store the secret number in a variable, and use that variable throughout. The secret number itself must not appear in the program at all, except in the one line where you store it into a variable. Sample output is as follows:
I have chosen a number between 1 and 10. Try to guess it.
Your guess: 5
That is incorrect. Guess again.
Your guess: 4
That is incorrect. Guess again.
Your guess: 8
That is incorrect. Guess again.
Your guess: 6
That's right! You guessed it.
Call your function from Example 1 three times with different kinds of arguments: a value, a variable, and an expression. Identify which kind of argument is which
Write a program factorial.py that accepts an integer from the user and displays its factorial.
Using your program evaluate the factorials of the integers from 1 - 5 and print the results. Sample output is as follows:
X Factorial of X
5 120
Write a program that asks the user about the number of values he/she wants to enter. Then prompt user to enter the values as per the required number, calculate its sum. The sample output is as follows:
Enter the number of values to be input: 5
Enter the number: 20
Enter the number: 10
Enter the number: 50
Enter the number: 4
Enter the number: 65
The sum is: 149
Adjust the code you wrote for the last problem to allow for weighted classes. Add a parameter weighted (1 = yes, 0 = no) and then return the correct number for the GPA. Weighted classes get one extra point on the GPA value.
Input: Letter GradeExpected output: Non-weighted GPA valueExpected output: Weighted GPA valueA45B34C23D12F01Anything elseInvalidInvalid
Enter your Letter Grade: B
Is it weighted? (1 = yes, 0 = no) 1
Your GPA score is : 4Enter your Letter Grade: B
Is it weighted? (1= yes, 0= no) 0
Your GPA score is: 3Enter your Letter Grade: a
Is it weighted?(1 = yes, 0 = no) 0
Your GPA score is : 4Create a program with nested list and displays this kind of output:
sample output:
[['Egg', 'Milk', 'Meat', ], ['Potato', 'Carrot', 'Turnip', ],['Apple', 'Orange', 'Grape', ]]
Milk
Turnip
Grape
Given an integer N, write a program to print the sandglass star pattern, similar to the pattern shown below.
* * * * *
* * * *
* * *
* *
*
* *
* * *
* * * *
* * * * * Input
The input will be a single line containing a positive integer (N).Output
The output should contain the asterisk(*) characters in the sandglass star pattern.
Note: There is a space after each asterisk(*) character.Explanation
For example, if the given number is 5, the pattern should contain 9 rows and 9 columns as shown below.
* * * * *
* * * *
* * *
* *
*
* *
* * *
* * * *
* * * * * Sample Input 1
5
Sample Output 1
* * * * *
* * * *
* * *
* *
*
* *
* * *
* * * *
* * * * *
Who will pay the bill?
In London restaurants, it is not uncommon for a group of diners to pay the bill via card. To make it more fun, each of them bring the card and the restaurant server will pick one randomly and will pay the bill.
As a programmer, recreate this event through a python program. It will accept names separated by comma and space (“, “). Make a list out of the entered names and pick one randomly that will pay the bill.
Sample output:
Enter names: carlo,fedrick,jhon,icy
carlo will pay the bill
HINT:
1. Use split function
2. Use random module
3. Use len function