1.
print('hello world')
2. a=int(input("enter the value of a"))
b=int(input("enter the value of b"))
sum=a+b
print('the sum is',sum)
3. a=int(input("enter the value of a"))
b=int(input("enter the value of b"))
c=int(input("enter the value of c"))
d=int(input("enter the value of d"))
e=int(input("enter the value of e"))
sum=a+b+c+d+e
avg=sum/5
print("the sum is",sum)
print("the avg is",avg)
4. a=int(input("enter the value of a"))
b=int(input("enter the value of b"))
print('befor swapping',a,b)
a=a+b
b=a-b
a=a-b
print("after swapping",a,b)
5. a=int(input("enter the value of a"))
b=int(input("enter the value of b"))
print('before swapping',a,b)
temp=a
a=b
b=temp
print("after swapping",a,b)
6. p=int(input("enter the value of p"))
t=int(input("enter the value of t"))
r=int(input("enter the value of r"))
si=p*t*r/100
print("the si is",si)
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))
9. r=int(input("enter the radius"))
area=3.4*r*r
print("the area of circle is",area)
10. b=int(input("enter the value of b"))
h=int(input("enter the value of h"))
area=0.5*b*h
print("the area of triangle is",area)
11. l=int(input("enter the value of l"))
b=int(input("enter the value of b"))
area=l*b
perimeter=2*(l+b)
print("the area is",area)
print("the perimeter is ",perimeter)
12. a=int(input("enter the value of a"))
square=a*a
print("the square of number is",square)
(NOT IN SCRIPTIND MODE)
13. >>> string='123nithya'
>>> string.isalnum()
True
1) >>> string='nithya'
>>> string.isalpha()
True
>>> string='123456789'
>>> string.isdigit()
True
>>> string="laptop"
>>> string.islower()
True
>>> string='CSEAIML'
>>> string.isupper()
True
>>> string=' '
>>> string.isspace()
True
>>> string='Welcome To Python'
>>> string.istitle()
True
>>> string='I am learning'
>>> string.replace('I','Nithya')
'Nithya am learning'
>>> string='Nithya is 18'
>>> string.split()
['Nithya', 'is', '18']
>>> string='I am good'
>>> string.count('o')
2
>>> string'I am good'
>>> string.find('a')
2
>>> string='HELLO'
>>> string.swapcase()
'hello'
>>> string='I am good'
>>> string.startswith('I')
True
>>> string='i am good'
>>> string.endswith('d')
True
14. >>> list1=[1,2,3,4,5,6,7,8,9,10]
>>> print(list1)
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
>>> x=[1,3,2,5]
>>> x=[1,2,3,4,5,6,7,8,9,10]
>>> x.append(12)
>>> x
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12]
>>> y=[2,3,4]
>>> x.extend(y)
>>> y
[2, 3, 4]
>>> x
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 2, 3, 4]
>>> 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
15. >>> tuple=(1,2,3,4,5,6,7,8,9,10)
>>> print('tuple')
tuple
>>> print(tuple)
(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
>>> tuple
(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
>>> tuple.count(3)
1
>>> tuple=(1,2,3,4,4,4,1)
>>> tuple.count(4)
3
>>> tuple.index(4)
3
>>> len(tuple)
>>>
16. >>> x={1,2,3,4,5,6,7,8,9,10}
>>> x
{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
>>> 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()
17. >>> x={"branch":"aiml","name":"nithya","rno":"603"}
>>> x
{'branch': 'aiml', 'name': 'nithya', 'rno': '603'}
>>> x.update({"sub":"pp"})
>>> x
{'branch': 'aiml', 'name': 'nithya', 'rno': '603', 'sub': 'pp'}
>>> x.pop("name")
'nithya'
>>> x.items()
dict_items([('branch', 'aiml'), ('rno', '603'), ('sub', 'pp')])
>>> x.keys()
dict_keys(['branch', 'rno', 'sub'])
>>> x.values()
dict_values(['aiml', '603', 'pp'])
>>> len(x)
3
>>> x.get("branch")
'aiml'
>>> x.clear()
>>> x
{}
18. x=int(input("enter the value of x"))
y=int(input("enter the value of y"))
sum=x+y
sub=x-y
mul=x*y
div=x/y
mod=x%y
exp=x**y
floor=x//y
print('sum,sub,mul,div,mod,exp,floor',sum,sub,mul,div,mod,exp,floor)
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)