9.
PROGRAM USING STRING
str1="sathya saai"
str2="arts and science college for women"
print(str1)
print(str1[0])
print(str1[0],str1[1])
print(str1[2:5])
print(str1[1:])
print(str2*2)
print(str1+str2)
OUTPUT
sathya saai
s
sa
thy
athya saai
arts and science college for womenarts and science college for women
sathya saaiarts and science college fo
2. PROGRAM USING OPERATORS IN PYTHON
a=int(input("enter the a value\n"))
b=int(input("enter the b value\n"))
#addition
print('sum',a+b)
#subtraction
print("subtraction:",a-b)
#multiplication
print("multipilcation:",a*b)
#division
print("division:",a/b)
#floor division
print("floor division:",a//b)
#module
print("module:",a%b)
#a to the power b
print("power:",a**b)
OUTPUT
enter the a value
10
enter the b value
2
sum 12
subtraction: 8
multipilcation: 20
division: 5.0
floor division: 5
module: 0
power: 100
[Link] USING LOOPS
r=int(input("enter the counter value r:\n"))
n=int(input("enter the range value n:\n"))
count=0
while(count<r):
count=count+1
print("hello geek")
else:
print("in else block")
print("this is example for statement\n")
for i in range(0,n):
print(i)
OUPUTenter the counter value r:
5
enter the range value n:
5
hello geek
hello geek
hello geek
hello geek
hello geek
in else block
this is example for statement
0
1
2
3
4
[Link] USING MODULESimport math
print([Link](5))
import math,random
print([Link](5))
print([Link](10,20))
from math import factorial
print(factorial(5))
OUTPUT
2.23606797749979
120
14
120
[Link] USING OPERATORS IN PYTHON
INPUT:
a=int(input("enter the a value\n"))
b=int(input("enter the b value\n"))
#additon
print('sum:',a+b)
#subraction
print('subraction:',a-b)
#multiplication
print('multiplication:',a*b)
#division
print('division:',a/b)
#floor division
print('floor division:',a//b)
#module
print('module:',a%b)
#a to the power b
print('power:',a**b)
OUTPUT: