Draw flow charts to find whether the sum of two numbers is greater than 50
Days Conversion
Given a number of days (N) as input, write a program to convert N to years (Y), weeks (W), and days (D).
Input
The input will be a single line containing a positive integer (N).
Output
The output should be a single line containing years, weeks, days values separated by spaces.
Explanation
For example, if the given number of days (N) is 1329.
1329 = 365*3 + 33*7 + 3
So the output is 3 years 33 weeks 3 days
Sample Input 1
1329
Sample Output 1
3 years 33 weeks 3 days
Sample Input 2
960
Sample Output 2
2 years 32 weeks 6 days
Modify class for Client that it only shows "Client creating" on screen for the object initialization only.
Create a static integer field that keeps a count across all instances(objects) of a class. Create 3 or 4 object in derived class and then check total instances.
"use strict";
process.stdin.resume();
process.stdin.setEncoding("utf-8");
let inputString = "";
let currentLine = 0;
process.stdin.on("data", (inputStdin) => {
inputString += inputStdin;
});
process.stdin.on("end", (_) => {
inputString = inputString.trim().split("\n").map((str) => str.trim());
main();
});
function readLine() {
return inputString[currentLine++];
}
/* Please do not modify anything above this line */
class Mobile {
constructor(brand, ram, battery, isOnCall, song) {
this.brand = brand;
this.ram = ram;
this.battery = battery;
this.isOnCall = isOnCall;
this.song = song;
this.isOnCall = false;
}
onCall() {
this.isOnCall = true;
}
onCall() {
this.isOnCall = false;
}
removeCharging() {
console.log("Please remove charger");
}
charging() {
if (this.battery < 100) {
this.battery = 100;
console.log(`Mobile Charged ${this.battery}%`);
} else {
console.log(`Mobile is fully charged`);
this.removeCharging();
}
}
playMusic() {
this.song = this.song;
console.log(`Playing ${this.song} song`);
}
stopMusic() {
this.song = this.song;
console.log('Music stopped');
}
makeCall() {
console.log("Calling...");
}
endCall() {
if (this.isOnCall === false) {
this.isOnCall = true;
console.log('No ongoing call to end');
} else {
console.log('Call Ended');
}
}
}
/* Please do not modify anything below this line */
function main() {
const brand = readLine();
const ram = readLine();
const battery = parseInt(readLine());
const song = readLine();
const isOnCall = JSON.parse(readLine());
const myMobile = new Mobile(brand, ram, battery, isOnCall, song);
console.log(`Mobile charged ${myMobile.battery}%`); // The Mobile battery charged percentage
myMobile.charging(); // The Mobile charging
myMobile.playMusic(); // The Mobile will start playing a song
myMobile.stopMusic(); // The Mobile will stop playing a song
myMobile.endCall(); // The Mobile will end a call.
myMobile.makeCall(); // The Mobile will make a call.
myMobile.endCall(); // The Mobile will end a call.
}
Sample Input 1
Apple
2 GB
90
Waka Waka
false
Sample Output 1
Mobile charged 90%
Mobile charged 100%
Playing Waka Waka song
Music stopped
No ongoing call to end
Calling...
Call Ended
Sample Input 2
Samsung
8 GB
100
Gangnam Style
true
Sample Output 2
Mobile charged 100%
Mobile is fully charged
Please remove charging
Playing Gangnam Style song
Music stopped
Call Ended
Calling...
Call Ended
there is some error in the testcases, help me for getting this out.
Matrix Rotations
You are given a square matrix A of dimensions NxN. You need to apply the below given 3 operations on the matrix A.
Rotation: It is represented as R S where S is an integer in {90, 180, 270, 360, 450, ...} which denotes the number of degrees to rotate. You need to rotate the matrix A by angle S in the clockwise direction. The angle of rotation(S) will always be in multiples of 90 degrees.
Update: It is represented as U X Y Z. In initial matrix A (as given in input), you need to update the element at row index X and column index Y with value Z.
After the update, all the previous rotation operations have to be applied to the updated initial matrix.
Querying: It is represented as Q K L. You need to print the value at row index K and column index L of the matrix A. Input
The first line contains a single integer N.
Next N lines contain N space-separated integers Aij (i - index of the row, j - index of the column).
Next lines contain various operations on the array. Each operation on each line (Beginning either with R, U or Q).
-1 will represent the end of input.Output
For each Query operation print the element present at row index K and colum index L of the matrix in its current state.Explanation
For Input:
2
1 2
3 4
R 90
Q 0 0
Q 0 1
R 90
Q 0 0
U 0 0 6
Q 1 1
-1
Initial Matrix
1 2
3 4
For R 90, clockwise rotation by 90 degrees, the matrix will become
3 1
4 2
For Q 0 0, print the element at row index 0 and column index 0 of A, which is 3.
For Q 0 1, print the element at row index 0 and column index 1 of A, which is 1.
Again for R 90, clockwise rotation by 90 degrees, the matrix will become
4 3
2 1
For Q 0 0, print the element at row index 0 and column index 0 of A, which is 4.
For U 0 0 6, update the value at row index 0 and column index 1 in the initial matrix to 6. So the updated matrix will be,
6 2
3 4
After updating, we need to rotate the matrix by sum of all rotation angles applied till now(i.e. R 90 and R 90 => 90 + 90 => 180 degrees in clockwise direction).
After rotation the matrix will now become
4 3
2 6
Next for Q 1 1, print the element at row index 1 and column index 1 of A, which is 6.
output
3
1
4
6
Sample Input 1
2
1 2
3 4
R 90
Q 0 0
Q 0 1
R 90
Q 0 0
U 0 0 6
Q 1 1
-1
Sample Output 1
3
1
4
6
Sample Input 2
2
5 6
7 8
R 90
Q 0 1
R 270
Q 1 1
R 180
U 0 0 4
Q 0 0
-1
Sample Output 2
5
8
8
11
46
output:
Errors/Warnings:
Traceback (most recent call last):
File "main.py", line 46, in <module>
query(matrix, args)
File "main.py", line 23, in query
i, j = map(int, _args)
ValueError: too many values to unpack (expected 2)
Expected:
11
46
23
Describe an autokey cipher and use it with initial key K1=6 to
encrypt a plaintext “Information”.
2. Describe Random Mapping Cipher and use the following table
to encrypt a plaintext ‘tutorial’ and ‘Homework’
3. Use the additive cipher with K=10 to encrypt a plaintext
“Homework”.
Note that: Operation is in modulo 26
4. Describe Playfair Cipher, and use the following table to encrypt
a plaintext ‘university’
Explain and Use Vigenere cipher to encrypt the message
“homework” using keyword “student”.
6. Use an affine cipher with K=(7,2) to encrypt “security”.
Explain and Use Unkey Transpositional ciphering to encrypt the
message “Information Technology”
Note that both parties agreed on the number of columns which
is 4
8. Explain and Use Keyed columnar transposition cipher to encrypt
a plaintext “Meet me at the park” with key “Study”
Note: both parties agreed on the number of columns is 5.
– If a programmer chooses java, a special approach is used. Identify one feature of this special approach.
Why Is Method main Declared static?
prefixes = 'JKLMNOPQ'
suffix = 'ack'
for letter in prefixes:
print(letter + suffix)
Put this code into a Python script and run it. Notice that it prints the names "Oack" and "Qack".
Modify the program so that it prints "Ouack" and "Quack" but leaves the other names the same.
Include the modified Python code and the output in your submission.
2. Give at least three examples that show different features of string slices. Describe the feature illustrated by each example. Invent your own examples. Do not copy them for the textbook or any other source.