Program 1: Simple Calculator
Aim: Simple Calculator
Algorithm:
1. Start the program.
2. Take required inputs.
3. Apply logic as per requirement.
4. Display the result.
5. Stop.
Program Code:
a = int(input("Enter first number: "))
b = int(input("Enter second number: "))
print("Addition:", a + b)
print("Subtraction:", a - b)
print("Multiplication:", a * b)
print("Division:", a / b)
Sample Output:
Output will depend on user input. Example shown when program is executed.
Viva Questions:
1. What is the purpose of this program?
2. Which Python concepts are used?
3. Can this program be modified for another use case?
Program 2: Swap Variables
Aim: Swap Variables
Algorithm:
1. Start the program.
2. Take required inputs.
3. Apply logic as per requirement.
4. Display the result.
5. Stop.
Program Code:
x = input("Enter value of x: ")
y = input("Enter value of y: ")
print("Before Swapping: x =", x, ", y =", y)
x, y = y, x
print("After Swapping: x =", x, ", y =", y)
Sample Output:
Output will depend on user input. Example shown when program is executed.
Viva Questions:
1. What is the purpose of this program?
2. Which Python concepts are used?
3. Can this program be modified for another use case?
Program 3: Student Marks Average
Aim: Student Marks Average
Algorithm:
1. Start the program.
2. Take required inputs.
3. Apply logic as per requirement.
4. Display the result.
5. Stop.
Program Code:
m1 = float(input("Enter marks of subject 1: "))
m2 = float(input("Enter marks of subject 2: "))
m3 = float(input("Enter marks of subject 3: "))
avg = (m1 + m2 + m3) / 3
print("Average Marks:", avg)
Sample Output:
Output will depend on user input. Example shown when program is executed.
Viva Questions:
1. What is the purpose of this program?
2. Which Python concepts are used?
3. Can this program be modified for another use case?
Program 4: Check Prime Number
Aim: Check Prime Number
Algorithm:
1. Start the program.
2. Take required inputs.
3. Apply logic as per requirement.
4. Display the result.
5. Stop.
Program Code:
num = int(input("Enter a number: "))
if num > 1:
for i in range(2, num):
if num % i == 0:
print(num, "is not a prime number")
break
else:
print(num, "is a prime number")
else:
print(num, "is not a prime number")
Sample Output:
Output will depend on user input. Example shown when program is executed.
Viva Questions:
1. What is the purpose of this program?
2. Which Python concepts are used?
3. Can this program be modified for another use case?
Program 5: Factorial using Loop
Aim: Factorial using Loop
Algorithm:
1. Start the program.
2. Take required inputs.
3. Apply logic as per requirement.
4. Display the result.
5. Stop.
Program Code:
num = int(input("Enter a number: "))
fact = 1
for i in range(1, num + 1):
fact *= i
print("Factorial of", num, "is", fact)
Sample Output:
Output will depend on user input. Example shown when program is executed.
Viva Questions:
1. What is the purpose of this program?
2. Which Python concepts are used?
3. Can this program be modified for another use case?
Program 6: Factorial using Function
Aim: Factorial using Function
Algorithm:
1. Start the program.
2. Take required inputs.
3. Apply logic as per requirement.
4. Display the result.
5. Stop.
Program Code:
def factorial(n):
fact = 1
for i in range(1, n + 1):
fact *= i
return fact
num = int(input("Enter a number: "))
print("Factorial of", num, "is", factorial(num))
Sample Output:
Output will depend on user input. Example shown when program is executed.
Viva Questions:
1. What is the purpose of this program?
2. Which Python concepts are used?
3. Can this program be modified for another use case?
Program 7: File Handling (Create, Write, Read Student Records)
Aim: File Handling (Create, Write, Read Student Records)
Algorithm:
1. Start the program.
2. Take required inputs.
3. Apply logic as per requirement.
4. Display the result.
5. Stop.
Program Code:
# Writing data
with open("[Link]", "w") as f:
[Link]("Name: Rohan, Marks: 85\n")
[Link]("Name: Priya, Marks: 92\n")
[Link]("Name: Aman, Marks: 78\n")
# Reading data
print("Student Records from File:")
with open("[Link]", "r") as f:
for line in f:
print([Link]())
Sample Output:
Output will depend on user input. Example shown when program is executed.
Viva Questions:
1. What is the purpose of this program?
2. Which Python concepts are used?
3. Can this program be modified for another use case?
Program 8: Reverse a String
Aim: Reverse a String
Algorithm:
1. Start the program.
2. Take required inputs.
3. Apply logic as per requirement.
4. Display the result.
5. Stop.
Program Code:
s = input("Enter a string: ")
print("Reversed string:", s[::-1])
Sample Output:
Output will depend on user input. Example shown when program is executed.
Viva Questions:
1. What is the purpose of this program?
2. Which Python concepts are used?
3. Can this program be modified for another use case?
Program 9: Find Largest Element in a List
Aim: Find Largest Element in a List
Algorithm:
1. Start the program.
2. Take required inputs.
3. Apply logic as per requirement.
4. Display the result.
5. Stop.
Program Code:
numbers = [12, 45, 7, 89, 23, 56]
print("List:", numbers)
print("Largest element:", max(numbers))
Sample Output:
Output will depend on user input. Example shown when program is executed.
Viva Questions:
1. What is the purpose of this program?
2. Which Python concepts are used?
3. Can this program be modified for another use case?
Program 10: Student Database using Dictionary
Aim: Student Database using Dictionary
Algorithm:
1. Start the program.
2. Take required inputs.
3. Apply logic as per requirement.
4. Display the result.
5. Stop.
Program Code:
students = {
101: {"Name": "Rohan", "Marks": 85},
102: {"Name": "Priya", "Marks": 92},
103: {"Name": "Aman", "Marks": 78}
}
for roll, details in [Link]():
print("Roll No:", roll, ", Name:", details["Name"], ", Marks:", details["Marks"])
Sample Output:
Output will depend on user input. Example shown when program is executed.
Viva Questions:
1. What is the purpose of this program?
2. Which Python concepts are used?
3. Can this program be modified for another use case?
Program 11: Multiplication Table Generator
Aim: Multiplication Table Generator
Algorithm:
1. Start the program.
2. Take required inputs.
3. Apply logic as per requirement.
4. Display the result.
5. Stop.
Program Code:
num = int(input("Enter a number: "))
print("Multiplication Table of", num)
for i in range(1, 11):
print(num, "x", i, "=", num * i)
Sample Output:
Output will depend on user input. Example shown when program is executed.
Viva Questions:
1. What is the purpose of this program?
2. Which Python concepts are used?
3. Can this program be modified for another use case?