Python Programs
Python Programs
print('hello world')
sum=a+b
7. import math
a=int(input("enter the value of a"))
print(math.sqrt(a))
8. import math
a=int(input("enter the value of a"))
exp=int(input("enter the value of exp"))
print("the power of a is",math.pow(a,exp))
>>> x.insert(6,34)
>>> x
[1, 2, 3, 4, 5, 6, 34, 7, 8, 9, 10, 12, 2, 3, 4]
>>> x.remove(7)
>>> x
[1, 2, 3, 4, 5, 6, 34, 8, 9, 10, 12, 2, 3, 4]
>>> x.reverse()
>>> x
[4, 3, 2, 12, 10, 9, 8, 34, 6, 5, 4, 3, 2, 1]
>>> x.sort()
>>> x
[1, 2, 2, 3, 3, 4, 4, 5, 6, 8, 9, 10, 12, 34]
>>> x.clear()
>>> x
[]
>>> len(x)
0
>>> x.add(19)
>>> x
{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 19}
>>> x.remove(19)
>>> x
{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
>>> len(x)
10
>>> x.pop()
1
>>> x={1,3,5,7}
>>> y={5,6,8,2}
>>> x|y
{1, 2, 3, 5, 6, 7, 8}
>>> x&y
{5}
>>> x^y
{1, 2, 3, 6, 7, 8}
>>> x.clear()
>>> x
set()
19. a=5
b=10
c=15
d=20
e=25
f=30
g=20
a+=5
b-=10
c*=3
d/=25
e%=30
f**=5
g//=8
print(a,b,c,d,e,f,g)
20. a=10
b=20
print(a>b)
print(a<b)
print(a<=b)
print(a>=b)
print(a==b)
print(a!=b)
21. a=10
b=20
c=30
d=40
print(a>b and b==d)
print(a<c or b>a)
print(not(a>d))
22. a=10
b=20
print(a|b)
print(a&b)
print(a^b)
print(a>>1)
print(a<<2)
23. a=1
b=2
print(a is b)
print(a is not b)
print(id(a))
print(id(b))
24. x=[1,2,3,4,5]
print(5 in x)
print(11 not in x)