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

Python Programming Lab 1

Uploaded by

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

Python Programming Lab 1

Uploaded by

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

1(a):Exchange the values of two Variables

a=int(input("Enter a:"))
b=int(input("Enter b:"))
print("Before Swapping:")
print(a)
print(b)
temp=a
a=b
b=temp
print("After Swapping:")
print(a)
print(b)

Output
Enter a:5
Enter b:8
Before Swapping:
5
8
After Swapping:
8
5
1(b):Circulate the values of n Variables
def circulate(a,n):
for i in range(1,n+1):
b=a[i:]+a[:i]
print("circulation",i,"=",b)
return
a=[9,8,7,6,5,4,3,2,1]
n=int(input("enter n:"))
circulate(a,n)

Output
enter n:4
circulation 1 = [8, 7, 6, 5, 4, 3, 2, 1, 9]
circulation 2 = [7, 6, 5, 4, 3, 2, 1, 9, 8]
circulation 3 = [6, 5, 4, 3, 2, 1, 9, 8, 7]
circulation 4 = [5, 4, 3, 2, 1, 9, 8, 7, 6]
1(c): Distance between two points

import math
x1=int(input("enter x1:"))
y1=int(input("enter y1:"))
x2=int(input("enter x2:"))
y2=int(input("enter y2:"))
distance =math.sqrt(((x2-x1)**2)+((y2-y1)**2))
print(distance)

Output
enter x1:6
enter y1:6
enter x2:3
enter y2:3
4.242640687119285

You might also like