Skip to content

Instantly share code, notes, and snippets.

View vtu29046-bot's full-sized avatar

vtu29046-bot

  • Joined Oct 24, 2025
View GitHub Profile
import hashlib
def create_file_hash(filename, algorithm='sha256'):
"""Creates a hash (message digest) of a given file."""
try:
hash_func = getattr(hashlib, algorithm)() # Choose hash algorithm
with open(filename, 'rb') as file:
while chunk := file.read(4096): # Read in chunks
hash_func.update(chunk)
TASK 12 A
# importing libraries
import pygame
import time
import random
snake_speed = 15
# Window size
TASK 11A
import tkinter as tk
# Function to change font style
def change_font():
label.config(font=("Arial", 18, "bold"))
# Create main window
TASK 10A
#pip install matplotlib
import matplotlib.pyplot as plt
languages = ['Java', 'Python', 'PHP', 'JavaScript', 'C#', 'C++']
popularity = [22.2, 17.6, 8.8, 8, 7.7, 6.7]
plt.bar(languages, popularity, color='b')
plt.title('Popularity of Programming Languages')
TASK 9A
# Initialize the list of grades
grades = [85, 90, 78, 92, 88]
# Display the grades list
print("Grades List:", grades)
# Prompt the user to enter the index of the grade they want to view
try:
TASK 8A
def number_sequence(start, end, step=1):
current = start
while current <= end:
yield current
current += step
start = int(input("Enter the starting number: "))
end = int(input("Enter the ending number: "))
step = int(input("Enter the step value: "))
TASK 6A
def copy_files(file_paths):
for file_path in file_paths:
if os.path.exists(file_path):
with open(file_path, 'r') as original_file:
original_content = original_file.read()
copy_file_path = file_path.split('.')[0] + '_copy.' + file_path.split('.')[1]
with open(copy_file_path, 'w') as copy_file:
copy_file.write(original_content)
TASK 5A
def find_employee_by_id(employees, target_id):
for employee in employees:
if employee['id'] == target_id:
return employee
return None
# Test the function
employees = [
TASK 3A
# Function to find k'th non repeating character
# in string
from collections import OrderedDict
def kthRepeating(input,k):
# OrderedDict returns a dictionary data structure having characters of input
# string as keys in the same order they were inserted and 0 as their default value
dict=OrderedDict.fromkeys(input,0)