-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrevise.py
More file actions
107 lines (80 loc) · 1.73 KB
/
revise.py
File metadata and controls
107 lines (80 loc) · 1.73 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#Airthmetic operations
a=int(input('enter a value:'))
b=int(input('enter b value:'))
print(a+b)
print(a-b)
print(a*b)
print(a/b)
print(a//b)
print(a%b)
print(a**b)
#swap a two numbers
a=int(input('enter a value:'))
b=int(input('enter b value:'))
c=a,b=b,a
print(c)
#method of swapping
a=int(input('enter a value:'))
b=int(input('enter b value:'))
temp=a
a=b
b=temp
print('after swapping:')
print("a=",a)
print("b=",b)
#simple greeting program
name=input('enter a name :')
age=int(input('enter your age:'))
print(f'Hello, {name} your {age} years old.')
#string manipulation
text=input('enter a sentence:')
print(text.upper())
print(text.lower())
print(text.replace(' ','_'))
print(text.strip())
#character counter
text=input('enter a sentence :')
no_space=text.replace(' ','')
char=len(no_space)
print(f'Number of characters : {char}')
#escape sequences
print('Hello \n\tWorld \n This is the bacslash:')
#logical operator
a=int(input('enter a number:'))
b=int(input('enter b number:'))
print(a>10 and b>10)
print(a<5 or b<5)
print(not(a>b))
#comparison operator
age=int(input('enter a age:'))
if age>=18:
print('your an adult')
elif age<18:
print('your a minor ')
#membership operator
sentence=input('enter a sentence:')
print('a' in sentence )
print('python' not in sentence)
#Bitwise operator
a=int(input('enter a number:'))
b=int(input('enter b number:'))
print(a&b)
print(a|b)
print(a^b)
print(a<<2)
print(b>>1)
# List
l=['abhi',90,'bhagya',95,'roopa']
l1=l.insert(1,'rekha')
print(l)
l2=l.append(98)
print(l)
l3=l.pop(2)
print(l)
print('final list ',l)
#reverse and sort
l=[18,6,4,8,9,6]
l.sort()
print(l)
l.reverse()
print(l)