For this program, I want an exact output with all test cases passed
M, N = input('Enter M, N: ').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('Enter K: '))
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
for i, j in idxs:
output[i][j] = values[idx]
idx += 1
for i in output:
for j in i:
print(j, end=' ')
print()
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
For this program, I want an exact output with all test cases passed and it should not have any brackets.
def rotate1(matrix, n):
a = len(matrix)
n = int(a)
b = int(n/2)
for row in range(0, b):
for col in range(row, (n- row - 1)):
temp = matrix[row][col]
matrix[row][col] = matrix[n - 1 - col][row]
matrix[n - 1 - col][row] = matrix[n - 1 - row][n- 1 - col]
matrix[n - 1 - row][n - 1 - col] = matrix[col][n - 1 - row]
matrix[col][n - 1 - row] = temp
return matrix
matrix = [[1, 2, 3, 4],[5, 6, 7, 8],[9, 10, 11, 12],[13, 14, 15, 16]]
n = len(matrix)
array = rotate1(matrix, n)
for col in array:
print(col, sep=" ")
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
Build a GPA calculator that inputs grades of 3 different subjects along with the credit hours
from the user and displays the user’s GPA. The input grades and their corresponding grading
points are given below.Grade Points
A 4.0
A- 3.67
B+ 3.33
B 3.0
B- 2.67
C+ 2.33
C 2.0
C- 1.67
D+ 1.33
D 1.0
F 0
Similar to most ATM terminals, the program should intake some input from the user and depending on the user’s action request, it should intereact with the database (in this case, the database.csv file provided) to execute the action.
At first, the user should be asked to enter his/her card number (we assume it to be a 6-digit number). If the format of the number entered is verified with the database, then the user should be asked to enter the corresponding PIN code (we assume it to be a 4-digit number). If either the card number or PIN code is incorrect, then the program should display the error and ask the user to enter the number. The program should display the information, which shold be retrieved from the database (Assume USD to KZT to USD xchange rate to be 1 USD = 450 KZT):
P.S I don't know how to upload provided excel document
Write a C program. The program should output the average of quizzes, laboratory exercises and assignments and compute the equivalent percentage by getting the 40%. Input the major examination and get the equivalent by getting the 60% of it. The program should output the Prelim Grade: Prelim Grade = class participation + major examination
Remarks: if the grade is greater than or equal to 75 display PASSED, otherwise FAILED
SAMPLE RUN:
Class Participation
Quiz 1: 90
Quiz 2: 95
Quiz 3: 89
Quiz 4: 80
Average: 88.5
Lab. 1: 100
Lab. 2: 95
Lab. 3: 80
Lab 4: 70
Average: 86.25
Assignment 1: 100
Assignment 2: 80
Assignment 3: 89
Assignment 4: 75
Average: 86
Class Participation: 34.73
Prelim Exam: 95
%: 57.00
Prelim Grade: 91.73
Remarks: PASSED
For this program, the output should not have any brackets
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 = []
k = 0
l = 0
while (((N - k) > 0) and ((M - l) > 0)) and ((N - k)*(M-l)) > K:
for i in range(k,N):
values.append(matrix[k][i])
for j in range(l+1,M):
values.append(matrix[j][N-1])
for i in range(N-2,k-1,-1):
values.append(matrix[M-1][i])
for j in range(M-2,l,-1):
values.append(matrix[j][k])
values = values[-K:] + values[:-K]
c = 0
for i in range(k,N):
matrix[k][i] = values[c]
c += 1
for j in range(l+1,M):
matrix[j][N-1] = values[c]
c += 1
for i in range(N-2,k-1,-1):
matrix[M-1][i] = values[c]
c += 1
for j in range(M-2,l,-1):
matrix[j][k] = values[c]
c += 1
values = []
k += 1
l += 1
M -= 1
N -= 1
for i in matrix:
print(i)You are required to create a class called BuyDiesel so that you can represent your purchase information related to Diesel.
The class should include five pieces of information in the form of instance variable
1. the station’s location (type String)
2. the type of Diesel (type String)
3. the quantity (type int) of the purchase in liters
4. the price per liter (double)
5. the percentage discount (double) which is in terms of how much percentage is off.
Your class should have a constructor that initializes the five instance variables. Provide a set and a get method for each instance variable.
In addition, provide a method named getPurchaseAmount that calculates the net purchase amount
(i.e., multiplies the quantity by the price per liter) minus the discount, then returns the net amount you had to pay as a double value.
Write an application class named Diesel that demonstrates the capabilities of class Diesel
Purchase.
Shortest Job First Algorithm: Step1:Get the number of process. Step2:Get the id and service time for each process. Step3:Initially the waiting time of first short process as 0 and total time of first short is process the service time of that process. Step4:Calculate the total time and waiting time of remaining process. Step5:Waiting time of one process is the total time of the previous process. Step6:Total time of process is calculated by adding the waiting time and service time of each process. Step7:Total waiting time calculated by adding the waiting time of each process. Step8:Total turn around time calculated by adding all total time of each process. Step9:calculate average waiting time by dividing the total waiting time by total number of process. Step10:Calculate average turn around time by dividing the total waiting time by total number of process. Step11:Display the result.
First Come First Serve Algorithm: Step1: Create the number of process. Step2: Get the ID and Service time for each process. Step3: Initially, Waiting time of first process is zero and Total time for the first process is the starting time of that process. Step4: Calculate the Total time and Processing time for the remaining processes. Step5: Waiting time of one process is the Total time of the previous process. Step6: Total time of process is calculated by adding Waiting time and Service time. Step7: Total waiting time is calculated by adding the waiting time for lack process. Step8: Total turn around time is calculated by adding all total time of each process. Step9: Calculate Average waiting time by dividing the total waiting time by total number of process. Step10: Calculate Average turn around time by dividing the total time by the number of process. Step11: Display the result
Instructions: You should submit your answer to this question as a Python code
with .py extension to the corresponding question in Google Classroom.
Attention: Make sure to write your name, surname, and student ID number.
Question:
(Average speed) Assume a runner runs 14 kilometers in 45 minutes and 30 sec-
onds. Write a program that displays the average speed in miles per hour. (Note that
1 mile is 1.6 kilometers.)