[go: up one dir, main page]

0% found this document useful (0 votes)
9 views13 pages

Class VII Study Material (Ch-4,5,6)

Uploaded by

sumanarti100
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)
9 views13 pages

Class VII Study Material (Ch-4,5,6)

Uploaded by

sumanarti100
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/ 13

PYTHON PROGRAMS (Ch - 5 & 6)

1.​ Write a program to input three numbers and print its average.
(Average= Sum of all the numbers(observations)/No. Of observations).

A=int(input(‘Enter first number’))


B=int(input(‘Enter second number’))
C=int(input(‘Enter third number’))
s=A+B+C
average=s/3
print(‘The average of the given numbers is’, average)

2.​ Write a program to input length and breadth of a rectangle and calculate the area and
perimeter.
L=int(input(‘Enter length of rectangle :’))
B=int(input(‘Enter breadth of rectangle:’))
Area=L*B
Perimeter=2*(L+B)
print(‘The Area of rectangle :’,Area)
print(‘The perimeter of the given rectangle :’,Perimeter)

3.​ Write a program to input the side of a square and calculate the area and perimeter.

Side=int(input("Enter the side of square"))


Area=Side*Side
Perimeter=4*Side
print("The Area of the Square is:",Area)
print("The Perimeter of the Square is:",Perimeter)
4.​ Write a program to input two angles of a triangle and find the third angle using formula
A + B + C = 180
A=int(input(‘Enter the first angle’))
B=int(input(‘Enter the second angle’))
C=180-(A+B)
print(‘The third angle is=’,C)

5.​ Write a program to input the price of a commodity and calculate the discount as 25% of
price.
price=int(input('Enter the price of the product'))
discount=price-(0.25*price)
print('Final discounted price is',discount)

6.​ Write a program to input two numbers and print the largest.

a=int(input('Enter the first number'))


b=int(input('Enter the second number'))
if a>b:
print('Largest number is', a)
else:
print('Largest number is', b)

7.​ Write a program to input a number and find whether the number is even or odd.

a=int(input('Enter the first number'))


if a%2==0:
print('Number is even’)
else:
print('Number is odd’)
8.​ Write a program to check whether a number entered is divisible by 11 or not.

a=int(input('Enter the first number'))


if a%11==0:
print('Number is divisible by 11’)
else:
print('Number is not divisible by 11’)

9.​ Write a program to input three numbers and print the smallest.

a=int(input('Enter the first number'))


b=int(input('Enter the second number'))
c=int(input('Enter the third number'))
if a<b and a<c:
print('Smallest number is', a)
elif b<c:
print('Smallest number is', b)
else:
print('Smallest number is', c)

10.​Write a program to input your age and check the eligibility for voting.
age=int(input('Enter your age'))
if age >= 18:
print('You are eligible to vote')
else:
print('You are not eligible to vote')
11.​Write a program to input cost price and selling price and check whether there is a profit
or loss.
sp=int(input('Enter the selling price'))
cp=int(input('Enter the cost price'))
if sp>cp:
print('There is a profit of rupees', sp-cp)
else:
print('There is a loss of rupees', cp-sp)

12.​Write a program to input your percentage and display the grade obtained as per the below
given table -
Percentage Grade

80 and above A

70 to 79 B

50 to 69 C

33 to 49 D

Below 33 E

per=int(input('Enter your percentage:'))


if per>=80:
print('Grade A')
elif per>=70 and per<=79:
print('Grade B')
elif per>=50 and per<=69:
print('Grade C')
elif per>=33 and per<=49:
print('Grade D')
else:
print('Grade E')
13.​Write a program to input a calendar month number and print its corresponding month
name.
num=int(input('Enter a month number:'))
if num==1:
print('January')
elif num==2:
print('February')
elif num==3:
print('March')
elif num==4:
print('April')
elif num==5:
print('May')
elif num==6:
print('June')
elif num==7:
print('July')
elif num==8:
print('August')
elif num==9:
print('September')
elif num==10:
print('October')
elif num==11:
print('November')
elif num==12:
print('December')
else:
print(‘Invalid Input’)
OUTPUT BASED PROGRAMS ON PYTHON OPERATORS

Q. Predict the output for the below given codes -


S.No. Program Output

a) 100
2.5
-11
11

b) True
True
False
True
False

c)
d) True
False
False
True
True
True

e) True
False
False
True

f)
130
43.3
<class ‘float’>

g) <class ‘int’>
<class ‘float’>
<class ‘str’>
SOLUTIONS TO THE BACK EXERCISES OF THE BOOK

Chapter 4 - Cascading Style Sheets

Chapter 5 - Operators in Python


Chapter 6 - Conditional Statements

You might also like