ITW Practical File Brar
ITW Practical File Brar
1903107
A REPORT ON
( IT WORKSHOP )
(BTCS 305-18)
LAB FILE
BACHELOR OF TECHNOLOGY
(Computer Science & Engineering)
SUBMITTED BY
ASSISTANT PROFESSOR
PRACTICAL 1
Introduction of python computer programming
PRACTICAL 2
Write a python program to compute greatest common divisor of two numbers
OUTPUT:
5
1903107
PRACTICAL 3
Write a python program to find square root of a number
def squareRoot(n, l) :
x=n
count = 0
while (1) :
count += 1
if (abs(root - x) < l) :
break
x = root
return root
if __name__ == "__main__" :
n = int(input(“Enter a number: ” ))
l = 0.00001
print(squareRoot(n, l))
OUTPUT:
6
1903107
PRACTICAL 4
Write a python program for power a number
num=int(input("enter a number"))
pow=int(input("enter power"))
print(num**pow)
OUTPUT:
7
1903107
PRACTICAL 5
Write a python program to find maximum of a list of numbers
list=[12,54,76,99,45,87,23]
save=0
for i in list:
if i>save:
save=i
print(save)
OUTPUT:
8
1903107
PROGRAM 6
Write a python program to design a simple calculator
def add(var1,var2):
return var1+var2
def sub(var1,var2):
return var1-var2
def mul(var1,var2):
return var1*var2
def div(var1,var2):
return var1/var2
def mod(var1,var2):
return var1%var2
OUTPUT:
9
1903107
PROGRAM 7
Write a python program to determine whether a given year is lead year or not.
def checkYear(year):
if (year % 4) == 0:
if (year % 100) == 0:
if (year % 400) == 0:
return True
else:
return False
else:
return True
else:
return False
year = 2000
if(checkYear(year)):
else:
OUTPUT:
10
1903107
PROGRAM 8
Write a python program to find factorial of number
def factorial(n):
if n == 0:
return 1
return n * factorial(n-1)
num = 5;
print("Factorial of", num, "is",
factorial(num))
OUTPUT:
11
1903107
PROGRAM 9
Write a python program to print Fibonacci series
def Fibonacci(n):
if n<0:
print("Incorrect input")
elif n==0:
return 0
elif n==1:
return 1
else:
return Fibonacci(n-1)+Fibonacci(n-2)
print(Fibonacci(9))
OUTPUT:
12
1903107
PROGRAM 10
Write a python program for linear search.
list=[]
for i in range(0,5):
num=int(input("enter a number"))
list.append(num)
for i in range(0,5):
if item==list[i]:
print("your item",item,"is found at location",i+1)
exit("thank you")
OUTPUT: