-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathP5.py
More file actions
36 lines (33 loc) · 1.38 KB
/
P5.py
File metadata and controls
36 lines (33 loc) · 1.38 KB
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
st = input("What do you want to swap : number or character ? \n")
st = list(st)
if(st[0]=='n' or st[0]=='N'):
num1 = int(input("Enter the first number : "))
num2 = int(input("Enter the second number : "))
num1 = num1+num2
num2 = num1-num2
num1 = num1-num2
print("The first number is now "+str(num1))
print("The second number is now "+str(num2))
elif(st[0]=='c' or st[0]=='C'):
ch1 = input("Enter the first character : ")
ch2 = input("Enter the second character : ")
ch3 = ch2
ch2 = ch1
ch1 = ch3
print("The first character is now "+ch1)
print("The second character is now "+ch2)
''' Output
What do you want to swap : number or character ?
number
Enter the first number : 49
Enter the second number : 91
The first number is now 91
The second number is now 49
OR
What do you want to swap : number or character ?
character
Enter the first character : A
Enter the second character : Z
The first character is now Z
The second character is now A
'''