Skip to content

Instantly share code, notes, and snippets.

View kasauhasree-ctrl's full-sized avatar

kasauhasree-ctrl

View GitHub Profile
def find_winning_strategy(cards):
n = len(cards)
dp = [[0] * n for _ in range(n)]
for gap in range(n):
for i in range(n - gap):
j = i + gap
# Base cases
if i == j:
#Task12a
# importing libraries
import pygame
import time
import random
snake_speed = 15
# Window size
#task 11.a
import tkinter as tk
# Function to change font style
def change_font():
label.config(font=("Arial", 18, "bold"))
# Create main window
#Task10a
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')
plt.xlabel('Programming Languages')
#task 9.a
# 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:
Task8a
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: "))
#Task7a
def analyze_student_grades():
# Sample data
student_names = ["Alice", "Bob", "Charlie", "Diana"]
student_grades = [85, 92, 78, 90]
# 1. Print a welcome message
print("Welcome to the Student Grades Analyzer!\n")
#Task6a
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 5.a
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 = [
#Task4a
#Add Elements: Add elements to the list.
list=[10,20]
a=30
list.append(a)
print(list)
#Remove Elements: Remove specific elements from the list.
list.pop(1)#by index value