CHAPTER 6 Making Decision Book Work Class 8-1
CHAPTER 6 Making Decision Book Work Class 8-1
Page no - 105
Challenge zone
A. Fill in the blanks
1. >
2. And, or and not
3. Tab
4. Input
5. Not
Q1. A program that receives name and age from the user .The program should display whether the person can vote or not . The
voting age is 18. The name of the user should also be displayed with a greeting.
Q2. A program that receives a single digit number from the user. Display the following output , based on the number entered by
the user:
Sample input – output :
Input Output
2 This is my 2nd hello to you
3 This is my 3rd hello to you
1 This is my 1st hello to you
6 This is my 6th hello to you
Ans 2. number = int(input("Enter single digit number : "))
if (number == 1):
print("This is my 1st hello to you")
elif(number == 2):
print("This is my 2nd hello to you")
elif(number == 3):
print("This is my 3rd hello to you")
elif(number == 4 or 5 or 6 or 7 or 8 or 9 ):
print("This is my",number,"th hello to you")
else:
print( "invalid number")
Q3. A program that receives two numbers num1 and num2 from the user . Display the larger number .If the numbers are the
same , display that the numbers are the same.
Ans 3. number1 = int(input("Enter 1 digit number : "))
number2 = int(input("Enter 2 digit number : "))
if (number1 > number2):
print(number1,"is greater than ",number2)
elif(number_1 < number_2):
print(number2,"is greater than ",number1)
else:
print(number2,"is equal to",number1)
Q4. A program that receives the number of a weekday(between 1 and 7 :1 being Sunday ). Display
the day of the week according to the number entered by the user.
Sample input- output
Input Output
2 Monday
4 Wednesday
7 Saturday
Q5. A program that receives a year (in yyyy format ) from the user . find whether the year is a leap year or normal year . if year
is divisible by 4 and not divisible by 100 , then it is a leap year . or if year is divisible by 400 then it is leap year .
Ans 5. year = int(input("Enter year : "))
if (year %4 == 0 and year %100 != 0) or year%400!=0:
print("leap year ")
else:
print("normal year")
Q6. A Program that receives the length of the three sides of a triangle -a , band c . Find whether the triangle is equilateral ,
isosceles or scalene.
Ans 6. a = int(input("Enter first side : "))
b = int(input("Enter second side : "))
c = int(input("Enter third side : "))
if a == b and b == c :
print("Equilateral Triangle")
elif a == b or b == c or c == a:
print("Isosceles Triangle")
else :
print("Scalene Triangle")
Q7 . A program that receives the number of a month (1for January , 2for February and so on) and displays the number of days in
that month. Assume that the year is a leap year .
Input Output
1 31
2 29
3 31
4 30
Ans 7. month=int(input(“Enter a month from 1-12:”))
if (month== 2 ):
print(“Number of days:29”)
elif month==4:
print(“Number of days:30”)
elif month== 6:
print(“Number of days: 30”)
elif month== 9:
print(“Number of days:30”)
elif month==11:
print(“Number of days:30”)
else:
print(“Number of days:31”)
Q8. Write a program that receives the marks in five subjects Physics, Chemistry , Biology , Mathematics and Computer . The
Program displays the percentage and grade according to following tables:
Percentage >= 90 % : Grade A
Percentage >= 80 % : Grade B
Percentage >= 70 % : Grade C
Percentage >= 60 % : Grade D
Percentage >= 50 % : Grade E
Percentage < 40 % : Grade F
Ans 8. print ("Enter marks obtained all 5 subjects")
Mark_1 = int(input("Enter Physics marks"))
Mark_2 = int(input("Enter Chemistry marks"))
Mark_3 = int(input("Enter Biology marks"))
Mark_4 = int(input("Enter Mathematics marks"))
Mark_5 = int(input("Enter Computer marks"))
Totalmarks= int(input(“ total marks in all subjects”))
Sum= Mark_1+ Mark_2+ Mark_3+ Mark_4+ Mark_5
percentage= (Sum /Totalmarks)*100
if ( percentage >= 90):
print("Grade A",percentage )
elif ( percentage >= 80 and < 90):
print("Grade B", percentage )
elif ( percentage >= 70 and < 80):
print("Grade C", percentage )
elif ( percentage >= 60 and < 70):
print("Grade D", percentage )
elif (percentage >= 40) and < 60:
print("Grade E", percentage )
else:
print("Grade F", percentage )
Q 9. Write a Program to input basic salary of an employee and calculate his/her Gross salary according to the following :
If Basic Salary <= 10000 , then HRA = 20% of Basic Salary , DA = 80 % of Basic Salary
If Basic Salary <= 20000 , then HRA = 25% of Basic Salary , DA = 90 % of Basic Salary
If Basic Salary > 20000 , then HRA = 30% of Basic Salary , DA = 95 % of Basic Salary
Gross Salary = Basic Salary + HRA +DA
Ans 9. basic_salary=int(input("Enter the basic salary"))
if(basic_salary <= 10000):
hra =basic_salary *0.2
da=basic_salary *0.8
gross_salary=basic_salary+hra+da
print("your gross salary is",gross_salary)
elif(basic_salary <= 20000 and > 10000):
hra =basic_salary *0.25
da=basic_salary *0.9
gross_salary=basic_salary+hra+da
print("your gross salary is",gross_salary)
else :
hra =basic_salary *0.30
da=basic_salary *0.95
gross_salary=basic_salary+hra+da
print("your gross salary is",gross_salary)
10. Write a program to input units of electricity consumed and then display the total electricity bill according to the following
condition :
• Cost of first 50 units rs.0.50/unit
• Cost of next 100 units rs.0.75/ unit
• Cost of next 100 units rs.1.20/unit
• Cost of a unit above 250 rs.1.50/unit
• An additional surcharge of 20% is added to all the bills .