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

Pract3

Uploaded by

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

Pract3

Uploaded by

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

Subject: PWP[22616]

Practical No. 3: Write simple Python program using operators: Arithmetic Operators, Logical Operators, Bitwise
Operators
Name: Ritesh Doibale Roll no:41

Practical code:
Arithmetic Operator:

print("Arithmetic Operators use")


a=12
b=7
c=a+b
print(f"Addition {a}+{b}={c}")

d=a-b
print(f"Substraction {a}-{b}={d}")

e=a*b
print(f"Multiplication {a}*{b}={e}")

f=a/b
print(f"Division {a}/{b}={f}")

g=a%b
print(f"Modulus {a}%{b}={f}")

g=a//b
print(f"floor division {a}//{b}={f}")

Output:
Subject: PWP[22616]
Practical No. 3: Write simple Python program using operators: Arithmetic Operators, Logical Operators, Bitwise
Operators
Name: Ritesh Doibale Roll no:41
Logical Operator:

Code:

print("Use of Logical Operator")


print("AND operator 8>9 and 8<12:")
print(8>9 and 8<12)
print("OR operator 8>9 or 8<12:")
print(8>9 or 8<12)
print("NOT operator 8>9 not 8<12:")
print(not( 8>9 and 8<12))
Output:

Bitwise Operator:

Code:

a=int(input("Enter first number"))


b=int(input("Enter Seccond number"))
print("a={0} \t b={1}".format(a,b))
print("Bitwise AND a&b", a&b)
print("Bitwise OR a|b", a|b)
print("Bitwise NOT ~a", ~a)
print("Bitwise XOR a^b", a^b)
print("Bitwise AND a>>2", a>>b)
print("Bitwise AND a<<2", a<<b)
Output:
Subject: PWP[22616]
Practical No. 3: Write simple Python program using operators: Arithmetic Operators, Logical Operators, Bitwise
Operators
Name: Ritesh Doibale Roll no:41
Exercise:

1Code:

print("Us dollar to Indian Rupees")


i= float(input("enter the us dollar: "))
# i=3
rs=i*83
print(f"{i}$ usd is {rs}rs in indian rupees")
Output:

2Code:

print("Converion of bits to megabytes and GigaBytes ")


b=int(input("Enter the no of bits: "))
by=b/8
mb=by/1024
gb=mb/1024
print("Megabytes=", mb,"\nGigabytes =",gb)

Output:

3Code:

i= int(input("Enter the number:"))


print("square root of ", i," is :", i*i)
output:
Subject: PWP[22616]
Practical No. 3: Write simple Python program using operators: Arithmetic Operators, Logical Operators, Bitwise
Operators
Name: Ritesh Doibale Roll no:41
4Code:

print("Finding are of rectangle\n")


l=float(input("Enter the length: "))
w=float(input("\nEnter the width: " ))
Area = l*w
print("Area : ",Area)
Output:

5Code:

print("Finding square's area and perimeter \n")


side=float(input("Enter the lenght of side:"))
area=side*side
perimeter= 4*side
print(" Area :",area)
print(" Perimter :",perimeter)
Output:

6Code:

import math
print("program to calculate surface volume and area of a cylinder. \n")
radius = float(input("Enter the radius of the cylinder: "))
height = float(input("Enter the height of the cylinder: "))
print("\nCylinder Surface Area:", 2 * math.pi * radius * (radius + height) )
print("Cylinder Volume:", math.pi * radius**2 * height)
Output:
Subject: PWP[22616]
Practical No. 3: Write simple Python program using operators: Arithmetic Operators, Logical Operators, Bitwise
Operators
Name: Ritesh Doibale Roll no:41

7Code:

i=int(input("Enter the number :"))


j=int(input("Enter the number :"))
print("integer i=",i,"\n Integer j=",j)

temp =i
i=j
j=temp

print("integer i=",i,"\n Integer j=",j)

Output:

You might also like