0% found this document useful (0 votes)
16 views

ITW Practical File Brar

Uploaded by

Arshpreet Brar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views

ITW Practical File Brar

Uploaded by

Arshpreet Brar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 12

1

1903107

A REPORT ON

( IT WORKSHOP )
(BTCS 305-18)
LAB FILE

SUBMITTED IN PARTIAL FULFILLMENT OF THE


REQUIREMENT FOR THE

AWARD OF THE DEGREE OF

BACHELOR OF TECHNOLOGY
(Computer Science & Engineering)

SUBMITTED BY

(Arshpreet Singh, Roll no1903107, 3RD SEMESTER & GROUP Z1)

UNDER THE GUIDANCE OF

MR. SIMARPREET SINGH

ASSISTANT PROFESSOR

Department of Computer Science & Engineering


Chandigarh Engineering College
Kharar-Banur Highway, Sector-112 Greater Mohali,

Punjab – 140307 (INDIA)


2
1903107

S.NO Aim of Practical


1 Introduction of python computer programming

2 Write a python program to compute greatest common divisor


of two numbers

3 Write a python program to find square root of a number

4 Write a python program for power a number

5 Write a python program to find maximum of a list of numbers

6 Write a python program to design a simple calculator

7 Write a python program to determine whether a given year is


lead year or not.

8 Write a python program to find factorial of number

9 Write a python program to print Fibonacci series

10 Write a python program for linear search.


3
1903107

PRACTICAL 1
Introduction of python computer programming

Python is an interpreted, high-level and general-purpose programming language.


Python's design philosophy emphasizes code readability with its notable use
of significant whitespace. Its language constructs and object-oriented approach aim to
help programmers write clear, logical code for small and large-scale projects.
Python is dynamically typed and garbage-collected. It supports multiple programming
paradigms, including structured (particularly, procedural), object-oriented,
and functional programming.
Python was created in the late 1980s, and first released in 1991, by Guido van
Rossum as a successor to the ABC programming language. Python 2.0, released in
2000, introduced new features, such as list comprehensions, and a garbage collection
system with reference counting, and was discontinued with version 2.7 in
2020.Python 3.0, released in 2008, was a major revision of the language that is not
completely backward-compatible and much Python 2 code does not run unmodified
on Python 3.

The language's core philosophy is summarized such as:

 Beautiful is better than ugly.


 Explicit is better than implicit.
 Simple is better than complex.
 Complex is better than complicated.
 Readability counts.

Python is meant to be an easily readable language. Its formatting is visually


uncluttered, and it often uses English keywords where other languages use
punctuation.Python uses whitespace indentation, rather than curly brackets or
keywords, to delimit blocks. An increase in indentation comes after certain
statements; a decrease in indentation signifies the end of the current block. Thus, the
program's visual structure accurately represents the program's semantic structure.
4
1903107

PRACTICAL 2
Write a python program to compute greatest common divisor of two numbers

def compute_hcf(x, y):


if x > y:
smaller = y
else:
smaller = x
for i in range(1, smaller+1):
if((x % i == 0) and (y % i == 0)):
hcf = i
return hcf

num1 = int(input(“Enter first number: ” ))


num2 = int(input(“Enter second number: ”))

print("The H.C.F. is", compute_hcf(num1, num2))

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

root = 0.5 * (x + (n / x))

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

num1=float(input("enter first number: "))


num2=float(input("enter second number: "))
print("Sum: ",add(num1,num2))
print("Difference: ",sub(num1,num2))
print("Product: ",mul(num1,num2))
print("Division: ",div(num1,num2))
print("Modulus: ",mod(num1,num2))

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)):

print(year,"is a Leap Year")

else:

print(year,"is Not a Leap Year")

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)

item=int(input("enter the number to be search"))

for i in range(0,5):
if item==list[i]:
print("your item",item,"is found at location",i+1)
exit("thank you")

OUTPUT:

You might also like