integers = [int(number) for number in input("Enter array of integers: ").split()]
K = int(input("K = "))
triplets = []
for i in range(len(integers)):
for j in range(i+1,len(integers)):
for k in range(j+1, len(integers)):
a = integers[i]
b = integers[j]
c = integers[k]
if b+c == K:
triplets.append(tuple((a,b,c)))
if len(triplets)!=0:
for triplet in triplets:
print(triplet)
else:
print("No Matching Triplets Found")
Output:(0, 12, 17)
(0, 8, 21)
(12, 8, 9)
The outout should be like this:(0, 8, 21)
(0, 12, 17)
(8, 9, 12)
M, N = input().split(' ')
M, N = int(M), int(N)
matrix = []
for _ in range(M):
row = [int(x) for x in input().split(' ')]
matrix.append(row)
K = int(input())
values = matrix[0][:-1] + [x[-1] for x in matrix][:-1] + matrix[-1][::-1][:-1] + [x[0] for x in matrix][::-1][:-1]
values = values[-K:] + values[:-K]
output = matrix
idxs = [(0, j) for j in range(N)][:-1] + [(i, N - 1) for i in range(M)][:-1] + [(M - 1, j) for j in range(N)][::-1][:-1] + [(i, 0) for i in range(M)][::-1][:-1]
idx =0
input:4 4
1 2 3 4
5 6 7 8
9 10 11 12
13 14 15 16
output:13 9 5 1
14 6 7 2
15 10 11 3
16 12 8 4
the output should be like this :
13 9 5 1
14 7 11 2
15 6 10 3
16 12 8 4
Given an array n integers, find and print all the unique triplets (a, b, c) in the array which give the sum K. (a+b+c=K).Input
The first line of the input will be space separated integers, denoting the elements of the array. The second line of the input will be an integer denoting the required sum KOutput
The output should be multiple lines, each line containing a unique triplet. The elements of the triple must be sorted in increasing order and all the triplets printed must be sorted in increasing order. Print "No Matching Triplets Found" if there are no triplets with the given sum.Explanation
When the given array is [0, 1, 2, 3, 5, 7, 13, 17, 19, 19] and the required sum is 22, the triplets (0, 3, 19), (0, 5, 17), (1, 2, 19), (2, 3, 17) and (2, 7, 13) have the given sum 22.
Q; Write a function to display the result of examination of students. Following requirements must be
fulfilled:
i. Read the names and marks of at least 5 students, data should be acquired from the user
and saved as dictionary (using a function named get info)
ii. Rank the top three students with highest marks (make a function named top3)
iii. Give cash rewards. Rs. 5000 for first rank, Rs. 3000 for second rank, Rs. 1000 for
third rank. Value cannot be modified (function name should be cashprize)
Q; Write a function to display the result of examination of students. Following requirements must be
fulfilled:
i. Read the names and marks of at least 5 students, data should be acquired from the user
and saved as dictionary (using a function named get info)
ii. Rank the top three students with highest marks (make a function named top3)
iii. Give cash rewards. Rs. 5000 for first rank, Rs. 3000 for second rank, Rs. 1000 for
third rank. Value cannot be modified (function name should be cashprize)
Write a function to display the result of examination of students. Following requirements must be fulfilled: i. Read the names and marks of at least 5 students, data should be acquired from the user and saved as dictionary (using a function named getinfo) ii. Rank the top three students with highest marks (make a function named top3) iii. Give cash rewards. Rs. 5000 for first rank, Rs. 3000 for second rank, Rs. 1000 for third rank. Value cannot be modified (function name should be cashprize)
How do you convert between the different python data types? What data quality issues arise when converting data types?
Given an MxN matrix filled with
The first line of input will be containing two space-separated integers, denoting M and N.
The next M lines will contain N space-separated integers, denoting the elements of the matrix.
The output should be a single line containing the area of the maximum square.
input:4 4 output :[13, 9, 5, 1, 2, 3, 4, 8, 12, 16, 15, 14]
[[13, 9, 5, 1], [14, 6, 7, 2], [15, 10, 11, 3], [16, 12, 8, 4]]
1 2 3 4
5 6 7 8
9 10 11 12
13 14 15 16
3
the ouput should be like this:
13 9 5 1
14 7 11 2
15 6 10 3
16 12 8 4
can anyone give the code correct?
Input: 6(number of students) {4 , 9 , 5 , 3 , 2 , 10}
Output: {0 , 0 , 1 , 3 , 4 , 0}