Practical No.6
Practical No.6
Practical No.6
# Move n-1 disks from source to auxiliary, so they are out of the way
tower_of_hanoi(n - 1, source, auxiliary, target) # Move the nth disk
from source to target print(f"Move disk {n} from {source} to {target}")
# Example usage n = 3 #
Number of disks
Output
Practical No.7
if students:
a
if students:
print("\nStudent Information:") for
roll_number, marks in students.items():
if choice == '1':
add_record(students)
output
Menu:
1. Add a Student Record
2. Delete a Student Record
3. Update Marks
4. Search a Roll Number and Display Marks
5. Sort Records in Ascending Order of Marks
6. Sort Records in Descending Order of Marks
7. Display Student with Highest Marks
8. Display All Student Information
9. Exit
Enter your choice (1-9): 4 Enter
the roll number to search: 6
Practical No.8
#Calculating cube
# Displaying output
OUTPUT:
Enter an integer: 10
Cube of 10 is 1000
Practical No 9
Output
1
4
9
16
25
36
49
64
81
100
Practical No 10
10. write a program to validate email id, password, url and mobile using
regular expression.
a
import re
def validate_email(email):
email_pattern = r'^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$'
def validate_password(password):
# At least 8 characters, at least one uppercase letter, one lowercase letter, one
digit and one special character
password_pattern = r'^(?=.[a-z])(?=.[A-Z])(?=.\d)(?=.[@$!%?&])[A-Za-z\
d@$!%?&]{8,}$'
def validate_url(url):
Z]{2,)(/[a-zA-Z0-9-?&=]*)?$'
def validate_mobile(mobile):
mobile_pattern = r'^[789]\d{9}$'
a
OUTPUT:
email = "[email protected]"
password = "Password123!"
url = "https://www.example.com"
mobile = "9421866392"
Practical No .14
# 3 * 3 matrix
X=[ [12, 7, 3] ,
[4,5,6],
[7, 8, 9] ]
3 * 4 matrix
Y=[ [5, 8, 1, 2] ,
[6,7,3,0], [4, 5, 9, 1] ]
# result is 3 * 4
result =[ [0, 0, 0, 0] ,
[0,0,0,0],
[0,0,0,0]]
print(r)
a
OUTPUT:
Practical No .15
import threading
import time
# Entry point
if __name__ == "__main__":
main()
Output:
0
A
1
a
B
2
C
3
D
4
E
Both tasks are complete.
a