0% found this document useful (0 votes)
29 views19 pages

Giet Cse AIML 3

giet_cse_AIML_3

Uploaded by

nalithalapathy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views19 pages

Giet Cse AIML 3

giet_cse_AIML_3

Uploaded by

nalithalapathy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 19

Quest 1

ion
Num
ber

Lang Python
uage

Topic Conditional Statements

Subto If-elif-else
pic

Type coding

Quest Calculate the Tax


ion
Title

Quest Write a Program to accept the cost price of a bike and display the
ion road tax to be paid according to the following criteria:
Descri Cost price (in Rs) Tax
ption above 1 lakh 15%
above 50 thousand and below 1 lakh 10%
Below 50 thousand 5%

Const Not Applicable


raints

Soluti bike_price = int(input())


on if bike_price>100000:
tax = (15/100)*bike_price
elif bike_price>50000 and bike_price<=100000:
tax = (10/100)*bike_price
else:
tax = (5/100) * bike_price

print(tax)

Input 57000
1

Outp 5700.0
ut 1
Input 43000
2

Outp 2150.0
ut 2

Expla
natio
n

Diffic Easy
ulty

Quest 2
ion
Numb
er

Langu python
age

Topic Conditional Statement

Subto If-elif-else
pic

Type coding

Questi Student loan


on
Title

Questi A government wants to provide student loans to students in their


on country. But in-order for a student to be eligible to get a student
Descri
loan, he/she must be in age range 17 to 21, and must have a
ption
minimum of 80% score in academics.
Write a program to accept the name, age and marks of a student
and display if he/she is eligible for the loan or not.

Constr Not applicable


aints

Soluti name = input()


on age = int(input())
marks = float(input())
if age>=17 and age<=21 and marks>=80:
print(name+" is eligible")
else:
print(name+" is not eligible")

Input Atul
1 21
89

Outpu Atul is eligible


t1

Input kiran
2 19
76

Outpu kiran is not eligible


t2

Expla
nation

Difficu Easy
lty

Que 3
stio
n
Num
ber

Lan Python
gua
ge

Topi Conditional Statement


c
Subt If-elif-else
opic

Type Coding

Que Find the criteria for exam


stion
Title

Que A student will not be allowed to sit in exam if his/her attendence is


stion less than 75%.
Desc
Take following input from user:
ripti
1. Number of classes held
on
2. Number of classes attended.
And calculate the percentage of class attended.
Print if student is allowed to sit in exam or not.

Cons 0<Classes<250
train
ts

Solu no_ch = int(input())


tion no_ca = int(input())
atten = (no_ca/no_ch)*100

if atten >= 75:


print ("allowed")
else:
print ("not allowed")

Inpu 245
t1 198

Out allowed
put 1

Inpu 245
t2 138

Out not allowed


put
2

Expl
anat
ion

Diffi Easy
culty

Que 4
stio
n
Nu
mb
er

Lan Python
gua
ge

Topi Conditional Statements


c

Sub If-elif-else
topi
c

Typ Coding
e

Que ATM
stio
n
Title

Que Pooja would like to withdraw X rs from an ATM. The cash machine will only
stio accept the transaction if X is a multiple of 5, and Pooja’s account balance has
n enough cash to perform the withdrawal transaction (including bank charges).
Des For each successful withdrawal the bank charges 1.5 Rs. Calculate Pooja’s
crip account balance after an attempted transaction.
tion
First value in input would be initial balance and it is float, second value is
transaction amount.

Con 0<amount of cash for withdrawal <= 2000


strai 0<= Pooja’s initial balance <=2000
nts

Solu amt,tran = input().split()


tion
amt = float(amt)
tran = int(tran)
if tran<=amt and tran%5==0:
t=amt-(tran+1.5)
print(f'%.2f'%t)
else:
print(f'%.2f'%amt)

Inp 120.0 30
ut 1

Out 88.50
put
1

Inp 500.0 505


ut 2

Out 500.00
put
2

Expl
ana
tion

Diffi Easy
cult
y

Quest 5
ion
Num
ber

Lang Python
uage

Topic Conditional statements


Subto If-elif-else ladder
pic

Type coding

Quest Calculate the Net amount


ion
Title

Quest A toy vendor supplies three types of toys: Battery Based Toys,
ion Key-based Toys, and Electrical Charging Based Toys. The vendor
Descri
gives a discount of 10% on orders for battery-based toys if the order
ption
is for more than Rs. 1000. On orders of more than Rs. 100 for
key-based toys, a discount of 5% is given, and a discount of 10% is
given on orders for electrical charging based toys of value more than
Rs. 500.

Assume that the numeric codes 1,2 and 3 are used for battery
based toys, key-based toys, and electrical charging based toys
respectively.
Write a program that reads the product code and the order amount
and prints out the net amount that the customer is required to pay
after the discount.

Const 0<Order_value<2000
raints

Soluti def compute_discount():


on
opt = int(input( ))
amt = int(input())
if opt==1:
if amt>1000:
dis = amt * 0.1
else:
dis = 0
elif opt==2:
if amt>100:
dis = amt * 0.05
else:
dis=0
elif opt==3:
if amt>500:
dis = amt*0.1
else:
dis = 0
else:
print("Product is not available")
bill_amt= amt - dis
print(bill_amt)
compute_discount()

Input 2
1 500

Outp 475.0
ut 1

Input 3
2 1500

Outp 1350.0
ut 2

Expla
natio
n

Diffic Hard
ulty

Quest 6
ion
Num
ber

Lang Python
uage

Topic Conditional Statements

Subto If-elif-else
pic

Type coding

Quest Calculate Net_amount


ion
Title

Quest A cloth showroom has announced the following discounts on the purchase of
ion specific items :
Descri
ption
Amount Shorts Pants Shits/T-Shirts

0-100 – 3% 5%

101-200 5% 8% 10%

201-300 10% 12% 15%

Above 300 18% 20% 22%

1. Ask user to enter the amount and assign following code for the items
such as (s) for shorts,(p) for pans and (t) for shirts/t-shirts.
2. Compute the discount and print the net amount paid by customer.

Const 0<Amount<1000
raints

Soluti def Calc():


on
amt = int(input())
opt = input()
if opt=='s' or opt=='S':
if amt>0 and amt<100:
dis = 0
elif amt>100 and amt<200:
dis = amt * 0.05
elif amt>201 and amt<300:
dis = amt * 0.1
else:
dis = amt * 0.18
elif opt=='p'or opt=='P':
if amt>0 and amt<100:
dis = amt * 0.03
elif amt>100 and amt<200:
dis = amt * 0.08
elif amt>201 and amt<300:
dis = amt * 0.12
else:
dis = amt * 0.20
if opt=='t' or opt=='T':
if amt>0 and amt<100:
dis = amt * 0.05
elif amt>100 and amt<200:
dis = amt * 0.10
elif amt>201 and amt<300:
dis = amt * 0.15
else:
dis = amt * 0.22
bill_amt = amt - dis
print(bill_amt)
Calc()

Input 600
1 t

Outp 468.0
ut 1

Input 790
2 S

Outp 647.8
ut 2

Expla
natio
n

Diffic Hard
ulty

Ques 7
tion
Num
ber

Lang Python
uage

Topic Conditional Statement

Subto If-elif-else
pic

Type coding

Quest Calculate and Print the bill in proper format.


ion
Title

Quest BSNL has three categories of customers: Industrial, Bulk Institutional and Domestic.
ion The rates for these are tabulated below :
Descr
iption
Category Units Rate

Industrial Minimum up to 5000 units Rs. 1500

Next 5000 units Rs. 0.25 per unit

Next 10000 units Rs. 0.23 per unit

Above this Rs. 0.20 per unit


Institutional Minimum up to 5000 units Rs. 1800

Next 5000 units Rs. 0.30 per unit

Next 10000 units Rs. 0.28 per unit

Above this Rs. 0.25 per unit

Domestic Minimum up to 100 Units Rs. 75

Next 100 Units Rs. 1.25 per unit

Next 200 Units Rs. 2.00 per unit

Above this Rs. 2.50 per unit

1. Ask user to enter customer category, Units.


2. Compute the bill as per given criteria.
3. Print bill in proper format.

Const Not applicable


raints

Soluti def calc_bill():


on cat = input()
units =int( input())
if cat == "commercial":
if units>0 and units<=5000:
bill = 1500
elif units>5000 and units<=10000:
bill = (units-5000) * 0.25 +1500
elif units>10000 and units<=15000:
bill = (units-10000) * 0.23+1500+5000*.25
elif units>20000:
bill = (units-20000) * 0.20+1500+5000*.25+10000*.23

elif cat == "institutional":


if units>0 and units<=5000:
bill = 1800
elif units>5000 and units<=10000:
bill = (units-5000) * 0.30+1800
elif units>10000 and units<=20000:
bill = (units-10000) * 0.28+5000*.30+1800
elif units>20000:
bill =( units-20000 )* 0.25+10000*.28+5000*.30+1800
if cat == "domestic":
if units>0 and units<=100:
bill = 75
elif units>100 and units<=200:
bill = (units-100) * 1.25+75
elif units>200and units<=400:
bill = (units-200 )* 2+100*1.25+75
elif units>400:
bill = (units-400) * 2.50+200*2+100*1.25+75

print(bill)
calc_bill()

Input institutional
1 50000

Outp 13600.0
ut 1

Input domestic
2 342

Outp 484.0
ut 2

Expla
natio
n

Diffic Hard
ulty

Ques 8
tion
Num
ber

Lang Python
uage

Topic Conditional statements

Subt If-elif-else
opic

Type coding

Ques Compute the fare


tion
Title

Ques A Ridesharing company called Ola charges the fare according to


tion following table:
Descr
iptio
n Distance Charges

1-50 8 Rs./Km

51-100 6 Rs./Km

> 100 5 Rs/Km

Cons 0<distance<150
traint
s

Soluti def fare():


on distance = int(input())
if distance>=1 and distance<=50:
fare = distance * 8
elif distance>=51 and distance<=100:
fare = distance * 6
elif distance>100:
fare = distance * 5
else:
print("Invalid fare")
print(fare)
fare()

Input 70
1

Outp 420
ut 1

Input 24
2

Outp 192
ut 2

Expla
natio
n

Diffic Medium
ulty

Ques 9
tion
Num
ber

Lang Python
uage

Topic Conditional Statements


Subt If-elif-else
opic

Type coding

Ques The Minion Game


tion
Title

Ques Game Rules


tion
Desc Both players are given the same string, S.
riptio Both players have to make substrings using the letters of the string S.
n Stuart has to make words starting with consonants.
Kevin has to make words starting with vowels.
The game ends when both players have made all possible substrings.

Scoring
A player gets +1 point for each occurrence of the substring in the string S.

For Example:
String S = BANANA
Kevin's vowel beginning word = ANA
Here, ANA occurs twice in BANANA. Hence, Kevin will get 2 Points.

For better understanding, see the image below:


Your task is to determine the winner of the game and their score.

Cons 0<len(s)<20
traint
s

Solut def minion_game(s):


ion
count_vowel=count_const=0
d= {'Vowel':['a','e','i','o','u','A','E','I','O','U']}

for i in range(len(s)):
for key,value in d.items():
if s[i] in value:
for i in range(i,len(s)):
count_vowel+=1
else:
for i in range(i,len(s)):
count_const+=1

if count_vowel>count_const:
print('Kevin',count_vowel)
elif count_vowel==count_const:
print('Draw')
else:
print('Stuart',count_const)

s = input()
minion_game(s)

Input PINEAPPLE
1

Outp Stuart 25
ut 1

Input ABACUS
2

Outp Kevin 12
ut 2

Expla
natio
n
Diffic Medium
ulty

Que 10
stion
Num
ber

Lang Python
uage

Topi Conditional Statements


c

Subt If-elif-else
opic

Type coding

Que Chess Time


stion
Title

Que Six friends go on a trip and are looking for accommodation. After looking for
stion hours, they find a hotel which offers two types of rooms — double rooms and
Desc triple rooms. A double room costs Rs. X, while a triple room costs Rs. Y.
ripti
on The friends can either get three double rooms or get two triple rooms. Find the
minimum amount they will have to pay to accommodate all six of them.

Input Format
The first line contains a single integer

T - the number of test cases. Then the test cases follow.


The first and only line of each test case contains two integers X and Y - the cost
of a double room and the cost of a triple room.

Output Format
For each testcase, output the minimum amount required to accommodate all
the six friends.
Cons 1<=T<=100
train
ts
1<=X<Y<=100

Solut for i in range(int(input())):


ion x,y=list(map(int,input().split()))

if (x*3)<(y*2):
print(x*3)
else:
print(y*2)

Inpu 3
t1 10 15
68
48

Outp 30
ut 1 16
12

Inpu 4
t2 10 4
10 26
40 13
51 20

Outp 8
ut 2 30
26
40

Expl
anati
on

Diffi Medium
culty

You might also like