0% found this document useful (0 votes)
19 views3 pages

pwp_prac_3

The document contains a series of practical programming exercises that demonstrate basic calculations and conversions using Python. It includes programs for converting U.S. dollars to Indian rupees, bits to various data sizes, finding square roots, calculating areas of rectangles and squares, and swapping variable values. Each exercise is accompanied by example inputs and outputs.

Uploaded by

saeedarwatkar
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)
19 views3 pages

pwp_prac_3

The document contains a series of practical programming exercises that demonstrate basic calculations and conversions using Python. It includes programs for converting U.S. dollars to Indian rupees, bits to various data sizes, finding square roots, calculating areas of rectangles and squares, and swapping variable values. Each exercise is accompanied by example inputs and outputs.

Uploaded by

saeedarwatkar
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/ 3

Practical No.

3
1. Write a program to convert U.S. dollars to Indian rupees.

us=int(input("Enter US Dollars:"))
indian=us*86
print("Indian Rupees:",indian)

output:
C:\Users\admin\PycharmProjects\lolita\.venv\Scripts\python.exe
C:\Users\admin\PycharmProjects\lolita\prac_1.py

Enter US Dollars:2

Indian Rupees: 172

2. Write a program to convert bits to Megabytes, Gigabytes and Terabytes


bits=int(input("Enter the number of bits:"))
byte=bits/8
kb=byte/1024
mb=kb/1024
gb=mb/1024
tb=gb/1024
print("Megabytes:",mb)
print("Gigabytes:",gb)
print("Terabyte",tb)

output:
C:\Users\admin\PycharmProjects\lolita\.venv\Scripts\python.exe C:\Users\admin\PycharmProjects\lolita\prac_1.py

Enter the number of bits:5

Megabytes: 5.960464477539062e-07

Gigabytes: 5.820766091346741e-10

Terabyte 5.684341886080801e-13

3. Write a program to find the square root of a number


s=int(input("Enter a number:"))
sq=s**0.5
print("Square root of ",s,"is",sq)
output:
C:\Users\admin\PycharmProjects\lolita\.venv\Scripts\python.exe
C:\Users\admin\PycharmProjects\lolita\prac_1.py

Enter a number:25

Square root of 25 is 5.0

4. Write a program to find the area of Rectangle


len=int(input("Enter Length:"))
bre=int(input("Enter breadth:"))
area=len*bre
print("Area of Rectangle is ",area)

output:
C:\Users\admin\PycharmProjects\lolita\.venv\Scripts\python.exe C:\Users\admin\PycharmProjects\lolita\prac_1.py

Enter Length:10

Enter breadth:10

Area of Rectangle is 100

5. Write a program to calculate area and perimeter of the square.


a=int(input("Enter Side:"))
print("Area of Square:",a*a)
print("Perimeter of Square:",a*4)

output:
C:\Users\admin\PycharmProjects\lolita\.venv\Scripts\python.exe C:\Users\admin\PycharmProjects\lolita\prac_1.py

Enter Side:5

Area of Square: 25

Perimeter of Square: 20

6. Write a program to calculate surface volume and area of a cylinder.


r=int(input("Enter Radius:"))
h=int(input("Enter Height:"))
s=3.14*r*r*h
a=2*3.14*r*(r+h)
print("surface area:",s)
print("Area of cylinder:",a)
output:
C:\Users\admin\PycharmProjects\lolita\.venv\Scripts\python.exe C:\Users\admin\PycharmProjects\lolita\prac_1.py

Enter Radius:2

Enter Height:4

surface area: 50.24

Area of cylinder: 75.36

7. Write a program to swap the value of two variables.


no1=int(input("Enter 1st no:"))
no2=int(input("Enter 2nd no:"))
print("Before swapping")
print("number 1:",no1)
print("number 2:",no2)
temp=no1
no1=no2
no2=temp
print("After swapping")
print("number 1:",no1)
print("number 2:",no2)

output:
C:\Users\admin\PycharmProjects\lolita\.venv\Scripts\python.exe C:\Users\admin\PycharmProjects\lolita\prac_1.py

Enter 1st no:5

Enter 2nd no:6

Before swapping

number 1: 5

number 2: 6

After swapping

number 1: 6

number 2: 5

You might also like