0% found this document useful (0 votes)
11 views

Class 7 Computer Practical Work-Term-2-2021-22 Write The Python Programs (Input) and Output According To The Given Topic

Uploaded by

RAGHAV GARG
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

Class 7 Computer Practical Work-Term-2-2021-22 Write The Python Programs (Input) and Output According To The Given Topic

Uploaded by

RAGHAV GARG
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

CLASS 7 COMPUTER PRACTICAL WORK-TERM-2-2021-22

Write the Python Programs (Input) and output according to the


given topic.

1.python for arithmetic operators


Input
a=100
b=50
c=5
d=4
e=10
f=2
print(“the sum of two numbers is”,a+b)
print(“subtraction of two numbers is”,a-b)
print(“multiplication of two numbers is”,c*d)
print(“division of two numbers is”,a/b)
print(“remainder of two numbers after division is”,e%f)
print(c,”raised to the power of”,d,”is”,c**d
print(“floor division of two numbers is”,c//f)
Output
Sum of two numbers is 150
Subtraction of two numbers is 50
Multiplication of two numbers is 20
Division of two numbers is 2.0
Remainder after the division of two numbers is 0
5 raised to the power of 4 is 625
Floor division of numbers is 2

2.python for relational operators


Input
a=200
b=100
#greater than operator
Print(a>b)
#less than operator
Print(a<b)
#greater than or equal to operator
Print(a>=b)
#less than or equal to operator
Print(a<=b)
#equal to
Print(a==b)
#not equal to
Print(a!=b)
Output
True
False
True
False
False
True

3.program for logical operators


Input
a = True
b = False
#output: a and b is False
print("a and b is",a and b)
#output: a or b is True
print("a or b is",a or b)
#output: not b is False
print("not b is",not b)
Output
a and b is False
a or b is True
not b is True

4.Python for area and perimeter of a square


Input
a=int(input("enter the value of side:"))
side=a
peri=4*a
area=a*a
print("the perimeter of a square is:",peri)
print("the area of a square is:",area)

Output
enter the value of side:2
the perimeter of a square is: 8
the area of a square is: 4

5.Python after swapping


Input
a=int(input("enter the value of first variable a:"))
b=int(input("enter the number for b:"))
temp=a
a=b
b=temp
print("the value of a after swapping is",a)
print("the value of b after swapping is",b)

Output
enter the value of first variable a:10
enter the number for b:5
the value of a after swapping is 5
the value of b after swapping is 10

You might also like