Questions: 5 831

Answers by our Experts: 5 728

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Search & Filtering


Given a matrix of order M*N and a value K, write a program to rotate each ring of the matrix clockwise by K elements. If in any ring has less than or equal to K elements, then don’t rotate that ring.Input


The first line of input will be two space-separated integers, denoting the M and N.

The next M lines will contain N space-separated integers.

The next line will contain an integer, denoting K.Output


The output should be M*N matrix by rotating the matrix by K elements.Explanation


Sample Input 1

4 4

1 2 3 4

5 6 7 8

9 10 11 12

13 14 15 16

3

Sample Output 1

13 9 5 1

14 7 11 2

15 6 10 3

16 12 8 4

Sample Input 2

3 4

1 2 3 4

10 11 12 5

9 8 7 6

2

Sample Output 2

9 10 1 2

8 11 12 3

7 6 5 4




Ask the user to pick a number between 0 and 9, then pull a country from a list to show the user the amount of species in each random country, the sample output is as follows:

To select a random country, type a number from 0 to 9: 7

Australia has 7155 different species.


Given an amount, write a program to find a minimum number of currency notes of different denominations that sum to the given amount. Available note denominations are 1000, 500, 100, 50, 20, 5, 1.

For example, if the given amount is 8593, in this problem you have to give the minimum number of notes that sum up to the given amount. Since we only have notes with denomination 1000, 500, 100, 50, 20, 5 and 1, we can only use these notes.

1000:8

500:1

100:0

50:1

20:2

5:0

1:3


You are given the temperature T of an object in one of Celsius, Fahrenheit, and Kelvin scales.

Write a program to print T in all scales viz Celsius, Fahrenheit, and Kelvin.

Formula to convert from Fahrenheit F to Celsius C is C = (F - 32) * 5 / 9.

Formula to convert from Kelvin K to Celsius C is C = K - 273.

Here "C", "F", "K" represent that the temperature scale is in Celsius, Fahrenheit and Kelvin scales respectively.

The input contains the temperature (a number) and the unit of the temperature scale (C, F, K) without any space.

The output contains temperature in Celsius, Fahrenheit and Kelvin scales in each line in the format similar to input and the value of the temperature is rounded to 2 decimal places.

For example, if the given temperature Value is 25C then Celsius value is 25.0C, Fahrenheit value is 77.0F, and Kelvin value is 298.0K.


You work for a bakery that sells two items: muffins and cupcakes. The number of muffins and cupcakes in your shop at any given time is stored in the <span style="text-decoration: none;">variables</span> muffins and cupcakes, which have been defined for you. 

Write a program that takes strings from standard input indicating what your customers are buying ("muffin" for a muffin, "cupcake" for a cupcake). If they buy a muffin, decrease muffins by one, and if they buy a cupcake, decrease cupcakes by 1. If there is no more of that baked good left, print ("Out of stock"). 

Once you are done selling, input "0", and have the program print out the number of muffins and cupcakes remaining, in the form "muffins: 9 cupcakes: 3" (if there were 9 muffins and 3 cupcakes left, for example).


Create a function that takes an argument. Give the function parameter a unique name. Show what happens when you try to use that parameter name outside the function. Explain the results.


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)


LATEST TUTORIALS
APPROVED BY CLIENTS