Kush Python
Kush Python
Fundamentals of Python
Programming Lab
(PBD 202)
BCA II Sem
Session 2024-27
Bhimtal Campus
THIS IS TO CERTIFY THAT KUSHAGRA SHARMA HAS
SATISFACTORILY COMPLETED ALL THE EXPERIMENTS IN THE
LABORATORY OF THIS COLLEGE. THE COURSE OF THE TERM
WORK IN PARTIAL FULLMENT OF THE
REQUIREMENT IN SECOND SEMESTER OF BCA DEGREE COURSE
PRESCRIBED BY THE GRAPHIC ERA HILL UNIVERSITY BHIMTAL
DURING THE YEAR.
NAME OF EXAMINER:
SIGNATURE
Exp. No. Date Experiment Page No. Remarks
Program Objective:
Write a program to get the marks of five subjects from the user, calculate the average marks, and find
the grade.
Program:
marks = [] for i
in range(5):
marks.append(float(input(f"Enter marks for subject {i+1}: ")))
{average:.2f}") print(f"Grade:
{grade}")
Output:
Program Objective:
Write a program to make a calculator and perform basic arithmetic based on user input. The menu
should be continuously available.
Program:
while True:
print("\nSimple Calculator")
Subtraction") print("3.
if choice == '5':
print("Exiting calculator.")
break
if choice == '1':
else:
else:
Output:
Write a program to take a number from the user and check if it is smaller than 100. If so, determine
whether the number is even or odd.
Program:
num = int(input("Enter a number: "))
is odd.") else:
Output:
Program Objective:
Write a program to take a character from the user and check whether it is uppercase, lowercase,
digit, or a special character.
Program:
char = input("Enter a character: ") if
char.isupper():
char.islower():
char.isdigit():
Output:
Program:
num1 = int(input("Enter first number: "))
Output:
Program:
Program Objective:
5 == 0:
Output:
Program Objective:
Write a program to create a list and print the original list as well as twice of each number.
Program:
numbers = [2, 4, 6, 8, 10] print("Original list:",
Output:
Write a program to print the table of 5 and terminate the loop when the value exceeds 10 using the
break statement.
Program Objective:
Program:
num = 5
result = num * i if
break
print(result)
Output:
Program:
def is_prime(n):
if n < 2:
Program Objective:
return False
return True start = int(input("Enter start of range: ")) end = int(input("Enter end of
range: ")) print("Prime numbers in range:", [num for num in range(start, end + 1) if
is_prime(num)])
Output:
Program:
n = int(input("Enter the number of Fibonacci terms: "))
range(2, n):
series:", fib[:n])
Program Objective:
Output:
Program:
numbers = [10, 5, 8, 20, 3] smallest
= min(numbers) largest =
max(numbers) print("Smallest
number:", largest)
Output:
Program Objective:
Program:
text = input("Enter a string: ") if
text == text[::-1]:
palindrome.")
Output:
Program Objective:
Program:
numbers = [10, 20, 5, 8, 30]
numbers.sort(reverse=True)
second_highest = numbers[1]
Output:
Program Objective:
Program:
numbers = [1, 2, 3, 4, 5]
reversed_list = numbers[::-1]
Output
Program Objective:
Program:
my_tuple = (1, 2, 3, 4, 5)
my_list = list(my_tuple)
new_tuple = tuple(my_list)
Output:
Program:
list1 = [1, 2, 3] list2 = [4, 5, 6]
Output:
Program:
Program Objective:
Output:
Program:
year = int(input("Enter a year: ")) if (year % 4 == 0 and
year.")
Output:
Program:
num = int(input("Enter a number: "))
factorial = 1 for i in
factorial *= i print(f"Factorial of
{num} is {factorial}.")
Output:
Program:
n = int(input("Enter a number: ")) print("Even numbers:",