0% found this document useful (0 votes)
15 views12 pages

PPFD Set-1

This document is a laboratory manual for a Bachelor of Technology course in Programming in Python with Full Stack Development. It includes a certificate of completion for a student and a series of programming exercises with code examples and outputs. The exercises cover various topics such as temperature conversion, area calculation, password generation, average calculation, leap year checking, factorial computation, palindrome checking, sorting, multiplication tables, and base conversion.

Uploaded by

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

PPFD Set-1

This document is a laboratory manual for a Bachelor of Technology course in Programming in Python with Full Stack Development. It includes a certificate of completion for a student and a series of programming exercises with code examples and outputs. The exercises cover various topics such as temperature conversion, area calculation, password generation, average calculation, leap year checking, factorial computation, palindrome checking, sorting, multiplication tables, and base conversion.

Uploaded by

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

FACULTY OF ENGINEERING AND TECHNOLOGY

BACHELOR OF TECHNOLOGY

Programming in Python with Full Stack Development

IV – SEM
COMPUTER SCIENCE & ENGINEERING
DEPARTMENT

Laboratory Manual
INDEX

1
2203031050602 PPFD Laboratory

CERTIFICATE

This is to certify that

Mr. /Miss. SHAH KAJOL GUNVANTKUMAR with Enrolment No.


2203031050602 has successfully completed his/her laboratory experiments
in Programming in Python with Full Stack Development
(303105258) from the Department of COMPUTER SCIENCE & ENGINEERING
during the academic year 2023 – 2024.

Date of Submission: ......................... Staff In charge:.........................................

Head of Department: ...........................................

CSE-PIET 2
2203031050602 PPFD Laboratory

SET-1

1. A program that converts temperatures from Fahrenheit to Celsius


and vice versa.

Code:
# Fahrenheit to Celsius
def FtoC(Fahrenheit):
return(Fahrenheit- 32.0) * 5.0 / 9.0

Fahrenheit = 100
Celsius = FtoC(Fahrenheit)
print (Celsius)

# Celsius to Fahrenheit
def CtoF(Celsius):
return(celsius * 1.8) + 32

Celsius = 38
Fahrenheit = CtoF(Celsius)
print (Fahrenheit)

Output:

CSE-PIET 3
2203031050602 PPFD Laboratory

2. A program that calculates the area and perimeter of a rectangle.

Code:
length = int(input())
width = int(input())

area = length * width


perimeter= 2 * (length + width)

print(f'Area of the Rectangle : {area}')


print(f'Perimeter of the Rectangle : {perimeter}')

Output:

CSE-PIET 4
2203031050602 PPFD Laboratory

3. A program that generates a random password of a specified length.

Code:
import string
import secrets

symbols = ['*', '%', '£'] # Can add more

password = ""
for _ in range(9):
password += secrets.choice(string.ascii_lowercase)
password += secrets.choice(string.ascii_uppercase)
password += secrets.choice(string.digits)
password += secrets.choice(symbols)
print(password)

Output:

CSE-PIET 5
2203031050602 PPFD Laboratory

4. A program that calculates the average of a list of numbers.

Code:
# Python program to get the average of a list
def Average(lst):
return sum(lst) / len(lst)

# Driver Code
lst = [15, 9, 55, 41, 35, 20, 62, 49]
average = Average(lst)

# Printing average of the list


print("Average of the list =", round(average, 2))

Output:

CSE-PIET 6
2203031050602 PPFD Laboratory

5. A program that checks if a given year is a leap year.

Code:
def ISLP(y):
if((y % 400 == 0)or(y % 100 != 0)and(y % 4 == 0)):
return 1;
else:
return 0;

if __name__=='__main__':
year = 2020;
print(ISLP(year));

Output:

CSE-PIET 7
2203031050602 PPFD Laboratory

6. A program that calculates the factorial of a number.

Code:
def factorial(n):

return 1 if (n==1 or n==0) else n * factorial(n - 1)

num = 7
print("Factorial of",num,"is",factorial(num))

Output:

CSE-PIET 8
2203031050602 PPFD Laboratory

7. A program that checks if a given string is a palindrome.

Code:
def isPalindrome(s):
return s == s[::-1]

s = "malayalam"
ans = isPalindrome(s)

if ans:
print("Yes")
else:
print("No")

Output:

8. A program that sorts a list of numbers in ascending or descending


order.

CSE-PIET 9
2203031050602 PPFD Laboratory

Code:
alphabets = ['a','e','d','c','b']
alphabets.sort()
print(alphabets)

random_numbers = [2,5,6,1,8,3]
random_numbers.sort()
print(random_numbers)

Output:

9. A program that generates a multiplication table for a given number.


CSE-PIET
10
2203031050602 PPFD Laboratory

Code:
num = 52

for i in range(1, 11):


print(num, 'x', i, '=', num*i)

Output:

10. A program that converts a given number from one base to another.

CSE-PIET
11
2203031050602 PPFD Laboratory

Code:
def decimal_to_binary(dec):
decimal = int(dec)

print(decimal, " in Binary : ", bin(decimal))

def decimal_to_octal(dec):
decimal = int(dec)

print(decimal, "in Octal : ", oct(decimal))

def decimal_to_hexadecimal(dec):
decimal = int(dec)

print(decimal, " in Hexadecimal : ", hex(decimal))

dec = 16
decimal_to_binary(dec)
decimal_to_octal(dec)
decimal_to_hexadecimal(dec)

Output:

CSE-PIET
12

You might also like