-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathswaping.py
More file actions
59 lines (51 loc) · 957 Bytes
/
swaping.py
File metadata and controls
59 lines (51 loc) · 957 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#different methods to swap two numbers in python
print('first method')
a=int(input('enter 1st no.: '))
b=int(input('enter 2nd no.: '))
a,b=b,a
print('a=',a)
print('b=',b)
print('second method')
a=int(input('enter 1st no.: '))
b=int(input('enter 2nd no.: '))
b=a*b
a=b/a
b=b/a
print(a)
print(b)
print('third method')
a=int(input('enter 1st no.: '))
b=int(input('enter 2nd no.: '))
a=a+b
b=a-b
a=a-b
print(a)
print(b)
print('fourth method')
a=int(input('enter 1st no.: '))
b=int(input('enter 2nd no.: '))
temp=a
a=b
b=temp
print(a)
print(b)
print('fifth method')
a=int(input('enter 1st no.: '))
b=int(input('enter 2nd no.: '))
a=a^b
b=a^b
a=a^b
print(a)
print(b)
print('sixth method')
n=(input('enter two numbers: ')).split()
print(n)
n.reverse()
a=int(n[0])
b=int(n[1])
print(a)
print(b)
print('seventh method')
List=[int(input("enter a")),int(input("enter b"))]
List.reverse()
print(List)