CODING Display the most fit trainee (or trainees) and
the highest average oxygen level.
There is a JAR full of candies for sale at a mall
counter. JAR has the capacity N, that is JAR Note:
can contain maximum N candies when JAR is
full. At any point of time.JAR can have M 1. The oxygen value entered should not be
number of Candies where M<=N. Candies are accepted if it is not in the range between 1
served to the customers. JAR never remains and 100.
empty as when last k candies are left. JAR if
refilled with new candies in such a way that 2. If the calculated maximum average oxygen
JAR get full. Write a code to implement above value of trainees is below 70 then declare the
scenario. Display JAR at counter with trainees as unfit with meaningful message as
available number of candies. Input should be ―All trainees are unfit‖
the number of candies one customer can
order at point of time. Update the JAR after 3. Average Oxygen Values should be
each purchase and display JAR at Counter. rounded.
Output should give number of Candies sold
and updated number of Candies in JAR. Example 1:
If Input is more than candies in JAR, return:
―INVALID INPUT‖ INPUT VALUES
Given, N=10, where N is NUMBER OF 95 92 95 92 90 92 90 92 90
CANDIES AVAILABLE
OUTPUT VALUES
K =< 5, where k is number of minimum
candies that must be inside JAR ever. Trainee Number: 1
Example 1:(N = 10, k =< 5) Trainee Number: 3
Input Value Note:
3 Input should be 9 integer values representing
oxygen levels entered in order as
Output Value
Round 1
NUMBER OF CANDIES SOLD: 3
Oxygen value of trainee 1
NUMBER OF CANDIES AVAILABLE: 7
Oxygen value of trainee 2
Example: (N=10, k<=5)
Oxygen value of trainee 3
Input Value
Round 2
0
Oxygen value of trainee 1
Output Value
Oxygen value of trainee 2
INVALID INPUT
Oxygen value of trainee 3
NUMBER OF CANDIES LEFT: 10
Round 3
Question 2
Oxygen value of trainee 1
Selection of MPCS exams include a fitness
test which is conducted on ground. There will Oxygen value of trainee 2
be a batch of 3 trainees, appearing for Oxygen value of trainee 3
running test in track for 3 rounds. You need to
record their oxygen level after every round. Output must be in given format as in
After trainee are finished with all rounds, above example. For any wrong input
calculate for each trainee his average oxygen
level over the 3 rounds and select one with final output should display “INVALID
highest oxygen level as the most fit trainee. If INPUT”
more than one trainee attains the same
highest average level, they all need to be
selected.
number of OFFSETs to shift the cipher
alphabet. Key can have basic shifts from 1 to
Question 3 25 positions as there are 26 total alphabets.
CODING: As we are designing custom Caesar Cipher, in
addition to alphabets, we are considering
Q1. WASHING MACHINE A Washing Machine numeric digits from 0 to 9. Digits can also be
works on the principle of a Fuzzy system; the shifted by key places.
weight of clothes put inside it for wash is
uncertain. But based on weight measured by For example, if given plain text contains any
sensors, it decides time and water levels digit with value 5 and key = 2, then 5 will be
which can be changed by menus given on the replaced by 7. ―-‖ (Minus sign) will remain as
machine control area. For low Water level, it is. Key value less than 0 should result into
time estimate is 25 minutes, where "INVALID INPUT"
approximate weight is 2000 grams or any Example 1:
non-zero positive number below that. For
Medium Water level, time estimated is Input:
35minutes, where approximate weight is
between 2001 grams and 4000 grams. For Enter your Plaintext: All the Best
High Water level, time estimated is 45 Enter the Key: 1
Minutes, where approximate weight is above
4000 grams. Assume the Capacity of the Output:
Machine is maximum 7000 grams. Where the
approximate weight is zero, the time The encrypted Text is: Bmm uif Cftu
estimate is 0 minutes. Write a function which Write a function custom Caesar Cipher (int
takes numeric weight in the range [0,7000] key, String message) which will accept
as input and produces estimated time as
output; if input is more than 7000, then plaintext and key as input parameters and
output is: "OVERLOADED!", and for all other returns its cipher text as output.
inputs, the output statement is "INVALID
INPUT‖. Exterior walls
Input should be in the form of integer value – 3. Surface Area of each Interior Wall in units
<integer> Output must have the following of square feet
format - Time Estimated: Minutes TCS 4. Surface Area of each Exterior Wall in units
Example 1 of square feet
Input Value If a user enters zero as the number of walls
then skip Surface area values as User may
2000 don‘t want to paint that wall.
Output Value Calculate and display the total cost of
painting the property
Time Estimated: 25 Minutes
Example 1:
Questionn 4
6
Q2. Caesar Cipher The Caesar cipher is a 3
type of substitution cipher in which each 12.3
15.2
alphabet in the plaintext or message is
12.3
shifted by a number of places down the 15.2
alphabet. 12.3
15.2
For example, with a shift of 1, P would be 10.10
replaced by Q, Q would become R, and so on. 10.10
To pass an encrypted message from one 10.00
person to another, it is first necessary that Total estimated Cost : 1847.4 INR
both parties have the 'key' for the cipher, so
Note: Follow in input and output format as
that the sender may encrypt it and the
given in above example
receiver may decrypt it. the key is the
―HARINIWASCIRCLE‖ = ―HA‖,
―TEENHATHNAKA‖ = ―TE‖, ―LUISWADI‖ =
―LU‖,
―NITINCOMPANYJUNCTION‖ = ―NI‖,
―CADBURRYJUNCTION‖ = ―CA‖
Question 5 Given, n=8, where n is number of total
BusStops.
A City Bus is a Ring Route Bus which runs in
BusStops = [ ―TH‖, ‖GA‖, ‖IC‖, ‖HA‖, ‖TE‖,
circular fashion.That is, Bus once
‖LU‖, ‖NI‖,‖CA‖ ]
starts at the Source Bus Stop, halts at each
Write a code with function getFare(String
Bus Stop in its Route and at the end it
Source, String Destination) which take
reaches the Source Bus Stop again.
Input as source and destination stops(in the
If there are n number of Stops and if the bus format containing first two characters
starts at Bus Stop 1, then after nth
of the Name of the Bus Stop) and calculate
Bus Stop, the next stop in the Route will be and return travel fare.
Bus Stop number 1 always.
Example 1:
If there are n stops, there will be n paths.One
Input Values
path connects two stops. Distances
ca
(in meters) for all paths in Ring Route is given
in array Path[] as given below: Ca
Path = [800, 600, 750, 900, 1400, 1200, Output Values
1100, 1500]
INVALID OUTPUT
Fare is determined based on the distance
covered from source to destination stop Example 2:
as Distance between Input Source and Input Values
Destination Stops can be measured by
NI
looking at values in array Path[] and fare can
HA
be calculated as per following criteria:
Output Values
If d =1000 metres, then fare=5 INR
23.0 INR
(When calculating fare for others, the
calculated fare containing any fraction value Note: Input and Output should be in format
given in example.
should be ceiled. For example, for distance
900n when fare initially calculated is Input should not be case sensitive and output
should be in the format <FLOAT>
4.5 which must be ceiled to 5)
INR
Path is circular in function. Value at each
index indicates distance till current stop Solution in Python:
from the previous one. And each index
position can be mapped with values at same
index in BusStops [] array, which is a string
array holding abbreviation of names
for all stops as-
―THANERAILWAYSTN‖ = ‖TH‖, ―GAONDEVI‖
= ―GA‖, ―ICEFACTROY‖ = ―IC‖,