0% found this document useful (0 votes)
34 views5 pages

CHAPTER 6 Making Decision Book Work Class 8-1

The document discusses Python programming concepts and provides examples of Python code to solve various problems. It includes 10 programming questions with sample inputs and outputs and the Python code to solve each problem. The problems cover concepts like conditional statements, loops, functions and string manipulation.

Uploaded by

Aviral
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)
34 views5 pages

CHAPTER 6 Making Decision Book Work Class 8-1

The document discusses Python programming concepts and provides examples of Python code to solve various problems. It includes 10 programming questions with sample inputs and outputs and the Python code to solve each problem. The problems cover concepts like conditional statements, loops, functions and string manipulation.

Uploaded by

Aviral
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/ 5

CHAPTER 6

MAKING DECISION IN PYTHON


BOOK WORK
PAGE NO – 100
Check point
1. = =
2. And
3. Tab
4. !

Page no - 105
Challenge zone
A. Fill in the blanks
1. >
2. And, or and not
3. Tab
4. Input
5. Not

B. Match the following


1. D
2. E
3. A
4. B
5. C

C. Name the following


1. And
2. Or
3. Elif
4. Int()
5. Float()

D. Write the following programs in Python. (copy work )

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.

Ans 1. name=input("Please enter your name")


age = int(input("Please enter a persons age."))
if age >= 18:
print (name ," can give vote .")
else:
print (name ," cannot give vote .")

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

Ans 4.week = int(input("Enter week number (1-7): "))


if (week == 1):
print("sunday ")
elif(week == 2):
print("Monday")
elif(week == 3):
print("Tuesday")
elif(week == 4):
print("Wednesday")
elif(week == 5):
print("Thursday")
elif(week == 6):
print("friday ")
elif(week == 7):
print("Saturday ")
else:
print ("not valid ")

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 .

Ans 10:- unit=int(input("Enter the unit of electricity"))


if(unit <50):
amt = unit*0.5
print("Amount To Be Paid Is:",amt*0.2)
elif(unit <= 150 and unit > 50):
amt = (50*0.5) + ((unit-50)*0.75)
print("Amount To Be Paid Is:",amt*0.2)
elif unit <= 250 and unit > 150:
amt = (50*0.5) + (100*0.75) + ((unit-150)*1.2)
print("Amount To Be Paid Is:",amt*0.2)
else:
amt = (50*0.5) + (100*0.75) + (100*1.2) + ((unit-250)*1.5)
print("Amount To Be Paid Is:",amt*0.2)
print("Process Completed")

You might also like