Replace Elements with Zeros
Given a MxN matrix, write a program to replace all elements that do not belong to principal-diagonal & anti-diagonal with Zeros.
Principal-diagonal elements are the set of elements of a matrix that lie on the line joining the top left corner to the bottom right corner.
Input
The first line of input will contain two space-separated integers, denoting MxN matrix.
The next M lines will contain N space-separated integers.
Output
Sample Input 1
5 5
4 3 7 6 4
4 4 7 7 6
9 5 8 5 9
3 6 6 2 4
3 7 4 4 3
Sample Output 1
4 0 0 0 4
0 4 0 7 0
0 0 8 0 0
0 6 0 2 0
3 0 0 0 3
Sample Input 2
10 10
73 18 100 29 91 98 5 45 16 18
11 25 81 76 95 71 22 80 81 11
28 82 87 24 65 43 21 4 47 98
99 30 62 87 30 60 80 33 71 38
61 15 64 4 86 39 49 24 95 100
78 45 30 87 28 9 75 50 3 75
Sample Output 2
73 0 0 0 0 0 0 0 0 18
0 25 0 0 0 0 0 0 81 0
0 0 87 0 0 0 0 4 0 0
0 0 0 87 0 0 80 0 0 0
0 0 0 0 86 39 0 0 0 0
0 0 0 0 28 9 0 0 0 0K 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 m1.Cite a situation in which you can apply the knowledge of peer to peer network and client/server network.
2. What are the importance of computer network?
3. Cite a situation in which you can apply the knowledge of the types of computer network and network devices
what are the importance of network cable? (Two to three sentences) Thank you!
: 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
Memory sticks (USB Flash drives) are used widely in lots of organizations. List two (2) benefits and two (2) drawbacks of using memory sticks in business establishments
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