├── Aarthika Nettyam ├── README.md ├── Task1 ├── Task2 ├── Task3 └── Task4 ├── Ankit_Dhanawat ├── calculator │ ├── README.md │ └── main.py ├── chatbot │ ├── README.md │ └── chatbot.py ├── game │ ├── README.md │ └── guessing_game.py └── image_converter │ ├── README.md │ └── img_convert.py ├── Kalthireddy Lukesh Chandra ├── README.md ├── Task 1 ├── Task 2 ├── Task 3 └── Task 4 ├── Karri Mokshith ├── README.md ├── Task1 ├── Task2 ├── Task3 └── Task4 ├── Kitchaiahgari Reddy Prasanna ├── README.md ├── Task1 ├── Task2 ├── Task3 └── Task4 ├── Konda Lakshmi Prasanna ├── README.md └── Task4 ├── Kundeti Lakshmikar ├── README.md ├── Task1 ├── Task2 ├── Task3 └── Task4 ├── LICENSE ├── Lakshmiprasanna8008 ├── README.md └── Task3 ├── LayavardhanReddy MaddiReddy ├── README.md ├── Task1 ├── Task2 ├── Task3 └── Task4 ├── Mogilipalli Bhargavi ├── README.md ├── Task1 ├── Task2 ├── Task3 └── Task4 ├── NELABALLI BHANUPRAKASH REDDY ├── README.md ├── Task1 ├── Task2 ├── Task3 └── Task4 ├── Naga Sathvik Rapelli ├── Hard Tasks │ ├── Task 10 │ │ └── task10.py │ ├── Task 11 │ │ └── task11.py │ ├── Task 12 │ │ ├── compressed_images │ │ │ └── compressed_image.jpg │ │ └── task12.py │ └── Task 9 │ │ ├── output_images │ │ ├── Motive.png │ │ └── WhatsApp Image 2024-02-15 at 06.43.27_0a95261b.png │ │ └── task9.py ├── Task 5 │ ├── task5.py │ └── templates │ │ └── index.html ├── Task 6 │ ├── data.csv │ └── task6.py ├── Task 7 │ └── task7.py ├── Task 8 │ └── task8.py ├── Task1 │ └── simple_calculator.py ├── Task2 │ ├── ToDoList.py │ └── ToDoListGUI.py ├── Task3 │ └── Number_guessing_game.py └── Task4 │ └── PDF_converter.py ├── Naga Tejaswini Nandyala ├── Task1 ├── Task2 ├── Task3 └── Task4 ├── R.LOKESH ├── task5 │ └── weatherapp.py ├── task6 │ └── webscrapper.py ├── task7 │ └── chatbot.py └── task8 │ └── pdfmerger.py ├── README.md ├── Sai Bharadwaj ├── Task 2 ├── Task 3 ├── Task 4 └── task 1 ├── TABBIBBU HITESH ├── README.md ├── Task1 ├── Task2 ├── Task3 └── Task4 └── Yogi Neelam ├── Task 3 ├── Task 4 ├── Task1 └── Task2 /Aarthika Nettyam/README.md: -------------------------------------------------------------------------------- 1 | Advance Level 2 | 3 | Task 1 :Image Converter: 4 | 5 | Where the program that accepts images in multiple formats that may be in JPEG, PNG, BMP, GIF and converts them into a desired format using Python Imaging Library (PIL) that may be any of the formats mentioned. 6 | 7 | 8 | Task 2:Data Analysis with Pandas: 9 | 10 | In the program on loading the "Iris" dataset from Seaborn and analyzing it using Pandas and performed exploratory data analysis, cleaning, aggregation, visualizations, and correlation calculations. 11 | The output of the program will consits of calculations , graph which will be more understanding to users. 12 | 13 | 14 | Task 3:Linear Regression with Scikit-learn: 15 | 16 | Completed a program by applying linear regression to predict house prices from the Boston housing dataset using scikit-learn and compared train and test scores and plot residuals. 17 | 18 | Task 4:Image Compression: 19 | 20 | Developed a Python program for compressing images while maintaining quality by exploring compression techniques like RLE and DCT and allowing users to adjust compression quality, support various image formats, and provide output options. Optionally, include a user interface. 21 | -------------------------------------------------------------------------------- /Aarthika Nettyam/Task1: -------------------------------------------------------------------------------- 1 | from PIL import Image 2 | import os 3 | 4 | def convert_image(input_path, output_path, output_format): 5 | try: 6 | # Open the image 7 | with Image.open(input_path) as img: 8 | # Convert and save the image to the desired format 9 | img.save(output_path, format=output_format) 10 | print(f"Image converted successfully to {output_format} format.") 11 | except Exception as e: 12 | print(f"An error occurred: {e}") 13 | 14 | def main(): 15 | input_path = input("Enter the path to the input image: ") 16 | output_format = input("Enter the desired output format (e.g., JPEG, PNG, BMP, GIF): ").upper() 17 | 18 | # Validate output format 19 | if output_format not in ['JPEG', 'PNG', 'BMP', 'GIF']: 20 | print("Invalid output format. Please choose from JPEG, PNG, BMP, or GIF.") 21 | return 22 | 23 | # Extract the file name and extension 24 | file_name, file_extension = os.path.splitext(input_path) 25 | 26 | # If the input file already has an extension, remove it 27 | file_name_without_ext = file_name.split('.')[0] 28 | 29 | # Set the output path 30 | output_path = f"{file_name_without_ext}_converted.{output_format.lower()}" 31 | 32 | # Convert the image 33 | convert_image(input_path, output_path, output_format) 34 | 35 | if __name__ == "__main__": 36 |     main() 37 | -------------------------------------------------------------------------------- /Aarthika Nettyam/Task2: -------------------------------------------------------------------------------- 1 | import seaborn as sns 2 | import pandas as pd 3 | import matplotlib.pyplot as plt 4 | 5 | # Load the Iris dataset from Seaborn 6 | iris = sns.load_dataset("iris") 7 | numeric_iris = iris.drop(columns='species') 8 | 9 | # Display the first few rows of the dataset 10 | print("First few rows of the dataset:") 11 | print(iris.head()) 12 | 13 | # Summary statistics 14 | print("\nSummary statistics:") 15 | print(iris.describe()) 16 | 17 | # Checking for missing values 18 | print("\nMissing values:") 19 | print(iris.isnull().sum()) 20 | 21 | # Visualizations 22 | # Pairplot 23 | sns.pairplot(iris, hue="species") 24 | plt.title("Pairplot of Iris Dataset") 25 | plt.show() 26 | 27 | # Boxplot 28 | plt.figure(figsize=(10, 6)) 29 | sns.boxplot(data=iris, orient="h") 30 | plt.title("Boxplot of Iris Dataset") 31 | plt.show() 32 | 33 | # Histograms 34 | plt.figure(figsize=(10, 6)) 35 | iris.hist() 36 | plt.suptitle("Histograms of Iris Dataset") 37 | plt.show() 38 | 39 | # Correlation heatmap 40 | plt.figure(figsize=(8, 6)) 41 | sns.heatmap(numeric_iris.corr(), annot=True, cmap="coolwarm") 42 | plt.title("Correlation Heatmap of Iris Dataset") 43 | plt.show() 44 | -------------------------------------------------------------------------------- /Aarthika Nettyam/Task3: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import matplotlib.pyplot as plt 3 | from sklearn.model_selection import train_test_split 4 | from sklearn.linear_model import LinearRegression 5 | from sklearn.metrics import mean_squared_error 6 | import pandas as pd 7 | data_url = "http://lib.stat.cmu.edu/datasets/boston" 8 | raw_df = pd.read_csv(data_url, sep="\s+", skiprows=22, header=None) 9 | data = np.hstack([raw_df.values[::2, :], raw_df.values[1::2, :2]]) 10 | target = raw_df.values[1::2, 2] 11 | 12 | # Load the Boston housing dataset 13 | 14 | X = data 15 | y = target 16 | 17 | # Split the data into training and testing sets 18 | X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42) 19 | 20 | # Initialize the linear regression model 21 | model = LinearRegression() 22 | 23 | # Fit the model on the training data 24 | model.fit(X_train, y_train) 25 | 26 | # Predict on the training and testing data 27 | y_train_pred = model.predict(X_train) 28 | y_test_pred = model.predict(X_test) 29 | 30 | # Calculate the scores 31 | train_score = model.score(X_train, y_train) 32 | test_score = model.score(X_test, y_test) 33 | 34 | print("Training score:", train_score) 35 | print("Testing score:", test_score) 36 | 37 | # Plot residuals 38 | plt.scatter(y_train_pred, y_train_pred - y_train, c='blue', marker='o', label='Training data') 39 | plt.scatter(y_test_pred, y_test_pred - y_test, c='lightgreen', marker='s', label='Testing data') 40 | plt.xlabel('Predicted values') 41 | plt.ylabel('Residuals') 42 | plt.legend(loc='upper left') 43 | plt.hlines(y=0, xmin=0, xmax=50, lw=2, color='red') 44 | plt.title('Residual plot') 45 | plt.show() 46 | -------------------------------------------------------------------------------- /Aarthika Nettyam/Task4: -------------------------------------------------------------------------------- 1 | from PIL import Image 2 | import os 3 | 4 | def get_size_format(b, factor=1024, suffix="B"): 5 | """ 6 | Scale bytes to its proper byte format. 7 | e.g: 1253656 => '1.20MB', 1253656678 => '1.17GB' 8 | """ 9 | for unit in ["", "K", "M", "G", "T", "P", "E", "Z"]: 10 | if b < factor: 11 | return f"{b:.2f}{unit}{suffix}" 12 | b /= factor 13 | return f"{b:.2f}Y{suffix}" 14 | 15 | def compress_img(image_name, new_size_ratio=0.9, quality=90, width=None, height=None, to_jpg=True): 16 | # Load the image into memory 17 | img = Image.open(image_name) 18 | 19 | # Print the original image shape 20 | print("[*] Image shape:", img.size) 21 | 22 | # Get the original image size in bytes 23 | image_size = os.path.getsize(image_name) 24 | print("[*] Size before compression:", get_size_format(image_size)) 25 | 26 | if new_size_ratio < 1.0: 27 | # If resizing ratio is below 1.0, multiply width & height with this ratio to reduce image size 28 | img = img.resize((int(img.size[0] * new_size_ratio), int(img.size[1] * new_size_ratio)), Image.ANTIALIAS) 29 | elif width and height: 30 | # If width and height are set, resize with them instead 31 | img = img.resize((width, height), Image.ANTIALIAS) 32 | 33 | # Split the filename and extension 34 | filename, ext = os.path.splitext(image_name) 35 | 36 | # Make a new filename appending "_compressed" to the original file name 37 | if to_jpg: 38 | # Change the extension to JPEG 39 | new_filename = f"{filename}_compressed.jpg" 40 | else: 41 | # Retain the same extension of the original image 42 | new_filename = f"{filename}_compressed{ext}" 43 | 44 | # Save the compressed image 45 | img.save(new_filename, optimize=True, quality=quality) 46 | 47 | # Print the new image shape 48 | print("[+] New Image shape:", img.size) 49 | print(f"[*] Compressed image saved as: {new_filename}") 50 | 51 | # Example usage: 52 | Input=input() 53 | compress_img(Input, new_size_ratio=0.8, quality=80, width=800, height=600) 54 | -------------------------------------------------------------------------------- /Ankit_Dhanawat/calculator/README.md: -------------------------------------------------------------------------------- 1 | # Calculator Documentation 2 | 3 | This is a simple calculator program written in Python. It performs basic arithmetic operations such as addition, subtraction, multiplication, and division. 4 | 5 | ## Functions 6 | 7 | ### addition(x, y) 8 | 9 | This function takes two numbers as input and returns their sum. 10 | 11 | ### subtraction(x, y) 12 | 13 | This function takes two numbers as input and returns the result of subtracting the second number from the first. 14 | 15 | ### multiplication(x, y) 16 | 17 | This function takes two numbers as input and returns their product. 18 | 19 | ### division(x, y) 20 | 21 | This function takes two numbers as input and returns their division. It checks for division by zero and returns an error message if the second number is zero. 22 | 23 | ## Usage 24 | 25 | 1. Run the script. 26 | 2. Choose the desired operation by entering the corresponding number. 27 | 3. Enter the first number. 28 | 4. Enter the second number. 29 | 5. The result of the chosen operation will be displayed. 30 | 31 | ## Example 32 | 33 | ``` 34 | Operation. 35 | 1. Addition. 36 | 2. Subtraction. 37 | 3. Multiplication. 38 | 4. Division. 39 | Enter your Choice: 1 40 | Enter number first : 5 41 | Enter number second : 3 42 | Result : 8.0 43 | ``` 44 | 45 | ## Error Handling 46 | 47 | If the user enters an invalid choice, the program will display "Invalid input." If the user attempts to divide by zero, the program will display "Error! Division by zero." 48 | -------------------------------------------------------------------------------- /Ankit_Dhanawat/calculator/main.py: -------------------------------------------------------------------------------- 1 | def addition(x,y): 2 | return x+y 3 | 4 | def subtraction(x,y): 5 | return x-y 6 | 7 | def multiplication(x,y): 8 | return x*y 9 | 10 | def division(x,y): 11 | if(y==0): 12 | return "Error! Devision by zero" 13 | else: 14 | return "x/y" 15 | 16 | 17 | 18 | print("Operation.") 19 | 20 | print("1. Addition.") 21 | print("2. Subtraction.") 22 | print("3. Multiplication.") 23 | print("4. Division.") 24 | 25 | choice =input("Enter your Choice: ") 26 | 27 | num1 = float(input("Enter number first : ")) 28 | num2 = float(input("Enter number second : ")) 29 | 30 | if choice == "1": 31 | print("Result : ", addition(num1 , num2)) 32 | elif choice == "2": 33 | print("Result : ", subtraction(num1 , num2)) 34 | elif choice == "3": 35 | print("Result : ", multiplication(num1 , num2)) 36 | elif choice == "4": 37 | print("Result : ", division(num1 , num2)) 38 | else: 39 | print("Invalid input.") 40 | 41 | -------------------------------------------------------------------------------- /Ankit_Dhanawat/chatbot/README.md: -------------------------------------------------------------------------------- 1 | # Chatbot Documentation 2 | 3 | ### Overview 4 | This Python script implements a simple chatbot using the `nltk` library for natural language processing. The chatbot responds to user queries and provides predefined responses for certain topics. 5 | 6 | ### Code Structure 7 | The code consists of the following components: 8 | 9 | 1. Importing necessary libraries: 10 | ```python 11 | import nltk 12 | from nltk.chat.util import Chat, reflections 13 | ``` 14 | 15 | 2. Defining patterns and responses: 16 | ```python 17 | pairs = [ 18 | ['hi|hello|hey', ['Hello!', 'Hi there!', 'Hey!']], 19 | ['how are you?', ['I am doing well, thank you!', 'I am good, thanks for asking!']], 20 | ['what is your name?', ['I am just a chatbot.', 'I am a chatbot designed to assist you.']], 21 | ['what can you do?', ['I can provide information on various topics. Feel free to ask me anything!']], 22 | ['bye|goodbye', ['Goodbye!', 'Bye! Have a great day!']], 23 | ['(.*) weather (.*)', ['Sorry, I cannot provide weather information at the moment.']], 24 | ['(.*) news (.*)', ['I am not able to provide news updates right now.']], 25 | ['(.*) time (.*)', ['Sorry, I cannot provide time information currently.']] 26 | ] 27 | ``` 28 | 29 | 3. Creating a `Chat` object: 30 | ```python 31 | chat = Chat(pairs, reflections) 32 | ``` 33 | 34 | 4. Defining a function to handle user input and generate chatbot response: 35 | ```python 36 | def chat_respond(user_input): 37 | return chat.respond(user_input) 38 | ``` 39 | 40 | 5. Defining the main function to interact with the chatbot: 41 | ```python 42 | def main(): 43 | print("Hello! I'm a simple chatbot.") 44 | 45 | while True: 46 | user_input = input("You : ") 47 | response = chat_respond(user_input) 48 | print("Bot:",response) 49 | if user_input.lower() == 'bye': 50 | break 51 | ``` 52 | 53 | 6. Executing the main function: 54 | ```python 55 | if __name__ == "__main__": 56 | main() 57 | ``` 58 | 59 | ### Usage 60 | To run the chatbot: 61 | 1. Ensure you have the `nltk` library installed. If not, you can install it using `pip install nltk`. 62 | 2. Copy the provided code into a Python script (e.g., `simple_chatbot.py`). 63 | 3. Run the script in a Python environment. 64 | 4. Interact with the chatbot by entering text input when prompted. 65 | 66 | ### Extending Functionality 67 | To extend the functionality of the chatbot: 68 | - Add more patterns and responses in the `pairs` list to handle a wider range of user queries. 69 | - Integrate external APIs to provide real-time information on specific topics like weather, news, or time. 70 | - Implement more sophisticated natural language processing techniques for better understanding of user queries. -------------------------------------------------------------------------------- /Ankit_Dhanawat/chatbot/chatbot.py: -------------------------------------------------------------------------------- 1 | import nltk 2 | from nltk.chat.util import Chat, reflections 3 | 4 | pairs = [ 5 | ['hi|hello|hey', ['Hello!', 'Hi there!', 'Hey!']], 6 | ['how are you?', ['I am doing well, thank you!', 'I am good, thanks for asking!']], 7 | ['what is your name?', ['I am just a chatbot.', 'I am a chatbot designed to assist you.']], 8 | ['what can you do?', ['I can provide information on various topics. Feel free to ask me anything!']], 9 | ['bye|goodbye', ['Goodbye!', 'Bye! Have a great day!']], 10 | ['(.*) weather (.*)', ['Sorry, I cannot provide weather information at the moment.']], 11 | ['(.*) news (.*)', ['I am not able to provide news updates right now.']], 12 | ['(.*) time (.*)', ['Sorry, I cannot provide time information currently.']] 13 | ] 14 | 15 | chat = Chat(pairs, reflections) 16 | 17 | def chat_respond(user_input): 18 | return chat.respond(user_input) 19 | 20 | def main(): 21 | print("Hello! I'm a simple chatbot.") 22 | 23 | while True: 24 | user_input = input("You : ") 25 | response = chat_respond(user_input) 26 | print("Bot:",response) 27 | if user_input.lower() == 'bye': 28 | break 29 | 30 | if __name__ == "__main__": 31 | main() -------------------------------------------------------------------------------- /Ankit_Dhanawat/game/README.md: -------------------------------------------------------------------------------- 1 | # Guessing Game Documentation 2 | 3 | This is a simple guessing game implemented in Python. The program generates a random number between 1 and 100, and the user has to guess the number within a limited number of attempts. 4 | 5 | ## Function 6 | 7 | ### `genareted_number()` 8 | 9 | This function generates a random number between 1 and 100 and initiates the guessing game. It prompts the user to guess the number and provides feedback on whether the guess is too low, too high, or correct. It also limits the user to a maximum of 10 attempts. 10 | 11 | ## Usage 12 | 13 | 1. Run the script. 14 | 2. The program will generate a random number between 1 and 100. 15 | 3. You will be prompted to guess the number. 16 | 4. Enter your guess within the range of 1 to 100. 17 | 5. You will receive feedback on whether your guess is too low, too high, or correct. 18 | 6. Continue guessing until you guess the number correctly or exhaust all 10 attempts. 19 | 20 | ## Example 21 | 22 | ``` 23 | Welcome to the Guessing Game! 24 | You have maximum 10 chances. 25 | Enter your number in 1 to 100 : 50 26 | Too low! Try again. 27 | Enter your number in 1 to 100 : 75 28 | Too high! Try again. 29 | Enter your number in 1 to 100 : 63 30 | Too high! Try again. 31 | Enter your number in 1 to 100 : 58 32 | Too high! Try again. 33 | Enter your number in 1 to 100 : 54 34 | Too low! Try again. 35 | Enter your number in 1 to 100 : 56 36 | Congratulations! You've guessed the number in 6 attempts. 37 | ``` 38 | 39 | ## Error Handling 40 | 41 | If the user exhausts all 10 attempts without guessing the correct number, the program will display "Sorry, you've run out of attempts. The number was [generated_number]." -------------------------------------------------------------------------------- /Ankit_Dhanawat/game/guessing_game.py: -------------------------------------------------------------------------------- 1 | import random 2 | 3 | def genareted_number(): 4 | 5 | genareted_number=random.randint(1, 100) 6 | 7 | 8 | print("Welcome to the Guessing Game!") 9 | print("You heve maximum 10 chance.") 10 | 11 | for attempts in range (0, 10): 12 | user_choice = int(input("Enter your number in 1 to 100 : ")) 13 | attempts += 1 14 | 15 | if user_choice < genareted_number: 16 | print("Too low! Try again.") 17 | elif user_choice>genareted_number: 18 | print("Too high! Try again.") 19 | else: 20 | print("Congratulations! You've guessed the number in", attempts, "attempts.") 21 | break 22 | else: 23 | print("Sorry, you've run out of attempts. The number was", genareted_number) 24 | 25 | genareted_number() -------------------------------------------------------------------------------- /Ankit_Dhanawat/image_converter/README.md: -------------------------------------------------------------------------------- 1 | # Image Converter Documentation 2 | 3 | ## Overview 4 | 5 | This Python script is designed to convert images from one format to another using the PIL (Python Imaging Library) module. 6 | 7 | ## Usage 8 | 9 | To use this script, follow these steps: 10 | 11 | 1. Ensure you have Python installed on your system. 12 | 2. Install the required Python modules using pip: 13 | ``` 14 | pip install pillow 15 | ``` 16 | 3. Run the script using Python: 17 | ``` 18 | python image_converter.py 19 | ``` 20 | 21 | ## Functions 22 | 23 | ### `convert_image(input_path, output_path, output_format)` 24 | 25 | This function converts an input image to the specified output format and saves it to the output path. 26 | 27 | - `input_path` (string): The file path of the input image. 28 | - `output_path` (string): The file path where the converted image will be saved. 29 | - `output_format` (string): The desired output format for the image (e.g., JPEG, PNG, BMP, GIF). 30 | 31 | ## Error Handling 32 | 33 | - If the input image file cannot be opened, an IOError is raised, and an error message is displayed. 34 | - If the conversion process fails, an exception is caught, and an error message is displayed. 35 | 36 | ## Example 37 | 38 | ```python 39 | from PIL import Image 40 | import os 41 | 42 | def convert_image(input_path, output_path, output_format): 43 | try: 44 | img = Image.open(input_path) 45 | except IOError: 46 | print("Unable to open image file:", input_path) 47 | return 48 | 49 | os.makedirs(os.path.dirname(output_path), exist_ok=True) 50 | 51 | try: 52 | img.save(output_path, format=output_format) 53 | print("Image converted successfully!") 54 | except Exception as e: 55 | print("Failed to convert image:", e) 56 | 57 | if __name__ == "__main__": 58 | input_path = input("Enter the path to the input image: ") 59 | output_path = input("Enter the path for the output image: ") 60 | output_format = input("Enter the desired output format (JPEG, PNG, BMP, GIF): ").upper() 61 | 62 | if output_format not in ["JPEG", "PNG", "BMP", "GIF"]: 63 | print("Invalid output format!") 64 | else: 65 | convert_image(input_path, output_path, output_format) 66 | ``` 67 | 68 | ## Dependencies 69 | 70 | - **PIL (Python Imaging Library)**: This script requires the PIL module to manipulate images. You can install it using pip: 71 | 72 | ``` 73 | pip install pillow 74 | ``` -------------------------------------------------------------------------------- /Ankit_Dhanawat/image_converter/img_convert.py: -------------------------------------------------------------------------------- 1 | from PIL import Image 2 | import os 3 | 4 | def convert_image(input_path, output_path, output_format): 5 | 6 | try: 7 | img = Image.open(input_path) 8 | except IOError: 9 | print("Unable to open image file:", input_path) 10 | return 11 | 12 | os.makedirs(os.path.dirname(output_path), exist_ok=True) 13 | 14 | try: 15 | img.save(output_path, format=output_format) 16 | print("Image converted successfully!") 17 | except Exception as e: 18 | print("Failed to convert image:", e) 19 | 20 | if __name__ == "__main__": 21 | input_path = input("Enter the path to the input image: ") 22 | output_path = input("Enter the path for the output image: ") 23 | output_format = input("Enter the desired output format (JPEG, PNG, BMP, GIF): ").upper() 24 | 25 | if output_format not in ["JPEG", "PNG", "BMP", "GIF"]: 26 | print("Invalid output format!") 27 | else: 28 | convert_image(input_path, output_path, output_format) 29 | -------------------------------------------------------------------------------- /Kalthireddy Lukesh Chandra/README.md: -------------------------------------------------------------------------------- 1 | Advance Level 2 | 3 | Task 1 :Image Converter: 4 | 5 | Where the program that accepts images in multiple formats that may be in JPEG, PNG, BMP, GIF and converts them into a desired format using Python Imaging Library (PIL) that may be any of the formats mentioned. 6 | 7 | 8 | Task 2:Data Analysis with Pandas: 9 | 10 | In the program on loading the "Iris" dataset from Seaborn and analyzing it using Pandas and performed exploratory data analysis, cleaning, aggregation, visualizations, and correlation calculations. 11 | The output of the program will consits of calculations , graph which will be more understanding to users. 12 | 13 | 14 | Task 3:Linear Regression with Scikit-learn: 15 | 16 | Completed a program by applying linear regression to predict house prices from the Boston housing dataset using scikit-learn and compared train and test scores and plot residuals. 17 | 18 | Task 4:Image Compression: 19 | 20 | Developed a Python program for compressing images while maintaining quality by exploring compression techniques like RLE and DCT and allowing users to adjust compression quality, support various image formats, and provide output options. Optionally, include a user interface. 21 | -------------------------------------------------------------------------------- /Kalthireddy Lukesh Chandra/Task 1: -------------------------------------------------------------------------------- 1 | from PIL import Image 2 | import os 3 | 4 | def convert_image(input_path, output_path, output_format): 5 | try: 6 | # Open the image 7 | with Image.open(input_path) as img: 8 | # Convert and save the image to the desired format 9 | img.save(output_path, format=output_format) 10 | print(f"Image converted successfully to {output_format} format.") 11 | except Exception as e: 12 | print(f"An error occurred: {e}") 13 | 14 | def main(): 15 | input_path = input("Enter the path to the input image: ") 16 | output_format = input("Enter the desired output format (e.g., JPEG, PNG, BMP, GIF): ").upper() 17 | 18 | # Validate output format 19 | if output_format not in ['JPEG', 'PNG', 'BMP', 'GIF']: 20 | print("Invalid output format. Please choose from JPEG, PNG, BMP, or GIF.") 21 | return 22 | 23 | # Extract the file name and extension 24 | file_name, file_extension = os.path.splitext(input_path) 25 | 26 | # If the input file already has an extension, remove it 27 | file_name_without_ext = file_name.split('.')[0] 28 | 29 | # Set the output path 30 | output_path = f"{file_name_without_ext}_converted.{output_format.lower()}" 31 | 32 | # Convert the image 33 | convert_image(input_path, output_path, output_format) 34 | 35 | if __name__ == "__main__": 36 | main() 37 | -------------------------------------------------------------------------------- /Kalthireddy Lukesh Chandra/Task 2: -------------------------------------------------------------------------------- 1 | import seaborn as sns 2 | import pandas as pd 3 | import matplotlib.pyplot as plt 4 | 5 | # Load the Iris dataset from Seaborn 6 | iris = sns.load_dataset("iris") 7 | numeric_iris = iris.drop(columns='species') 8 | 9 | # Display the first few rows of the dataset 10 | print("First few rows of the dataset:") 11 | print(iris.head()) 12 | 13 | # Summary statistics 14 | print("\nSummary statistics:") 15 | print(iris.describe()) 16 | 17 | # Checking for missing values 18 | print("\nMissing values:") 19 | print(iris.isnull().sum()) 20 | 21 | # Visualizations 22 | # Pairplot 23 | sns.pairplot(iris, hue="species") 24 | plt.title("Pairplot of Iris Dataset") 25 | plt.show() 26 | 27 | # Boxplot 28 | plt.figure(figsize=(10, 6)) 29 | sns.boxplot(data=iris, orient="h") 30 | plt.title("Boxplot of Iris Dataset") 31 | plt.show() 32 | 33 | # Histograms 34 | plt.figure(figsize=(10, 6)) 35 | iris.hist() 36 | plt.suptitle("Histograms of Iris Dataset") 37 | plt.show() 38 | 39 | # Correlation heatmap 40 | plt.figure(figsize=(8, 6)) 41 | sns.heatmap(numeric_iris.corr(), annot=True, cmap="coolwarm") 42 | plt.title("Correlation Heatmap of Iris Dataset") 43 | plt.show() 44 | -------------------------------------------------------------------------------- /Kalthireddy Lukesh Chandra/Task 3: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import matplotlib.pyplot as plt 3 | from sklearn.model_selection import train_test_split 4 | from sklearn.linear_model import LinearRegression 5 | from sklearn.metrics import mean_squared_error 6 | import pandas as pd 7 | data_url = "http://lib.stat.cmu.edu/datasets/boston" 8 | raw_df = pd.read_csv(data_url, sep="\s+", skiprows=22, header=None) 9 | data = np.hstack([raw_df.values[::2, :], raw_df.values[1::2, :2]]) 10 | target = raw_df.values[1::2, 2] 11 | 12 | # Load the Boston housing dataset 13 | 14 | X = data 15 | y = target 16 | 17 | # Split the data into training and testing sets 18 | X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42) 19 | 20 | # Initialize the linear regression model 21 | model = LinearRegression() 22 | 23 | # Fit the model on the training data 24 | model.fit(X_train, y_train) 25 | 26 | # Predict on the training and testing data 27 | y_train_pred = model.predict(X_train) 28 | y_test_pred = model.predict(X_test) 29 | 30 | # Calculate the scores 31 | train_score = model.score(X_train, y_train) 32 | test_score = model.score(X_test, y_test) 33 | 34 | print("Training score:", train_score) 35 | print("Testing score:", test_score) 36 | 37 | # Plot residuals 38 | plt.scatter(y_train_pred, y_train_pred - y_train, c='blue', marker='o', label='Training data') 39 | plt.scatter(y_test_pred, y_test_pred - y_test, c='lightgreen', marker='s', label='Testing data') 40 | plt.xlabel('Predicted values') 41 | plt.ylabel('Residuals') 42 | plt.legend(loc='upper left') 43 | plt.hlines(y=0, xmin=0, xmax=50, lw=2, color='red') 44 | plt.title('Residual plot') 45 | plt.show() 46 | -------------------------------------------------------------------------------- /Kalthireddy Lukesh Chandra/Task 4: -------------------------------------------------------------------------------- 1 | from PIL import Image 2 | import os 3 | 4 | def get_size_format(b, factor=1024, suffix="B"): 5 | """ 6 | Scale bytes to its proper byte format. 7 | e.g: 1253656 => '1.20MB', 1253656678 => '1.17GB' 8 | """ 9 | for unit in ["", "K", "M", "G", "T", "P", "E", "Z"]: 10 | if b < factor: 11 | return f"{b:.2f}{unit}{suffix}" 12 | b /= factor 13 | return f"{b:.2f}Y{suffix}" 14 | 15 | def compress_img(image_name, new_size_ratio=0.9, quality=90, width=None, height=None, to_jpg=True): 16 | # Load the image into memory 17 | img = Image.open(image_name) 18 | 19 | # Print the original image shape 20 | print("[*] Image shape:", img.size) 21 | 22 | # Get the original image size in bytes 23 | image_size = os.path.getsize(image_name) 24 | print("[*] Size before compression:", get_size_format(image_size)) 25 | 26 | if new_size_ratio < 1.0: 27 | # If resizing ratio is below 1.0, multiply width & height with this ratio to reduce image size 28 | img = img.resize((int(img.size[0] * new_size_ratio), int(img.size[1] * new_size_ratio)), Image.ANTIALIAS) 29 | elif width and height: 30 | # If width and height are set, resize with them instead 31 | img = img.resize((width, height), Image.ANTIALIAS) 32 | 33 | # Split the filename and extension 34 | filename, ext = os.path.splitext(image_name) 35 | 36 | # Make a new filename appending "_compressed" to the original file name 37 | if to_jpg: 38 | # Change the extension to JPEG 39 | new_filename = f"{filename}_compressed.jpg" 40 | else: 41 | # Retain the same extension of the original image 42 | new_filename = f"{filename}_compressed{ext}" 43 | 44 | # Save the compressed image 45 | img.save(new_filename, optimize=True, quality=quality) 46 | 47 | # Print the new image shape 48 | print("[+] New Image shape:", img.size) 49 | print(f"[*] Compressed image saved as: {new_filename}") 50 | 51 | # Example usage: 52 | compress_img("wp1966881.jpg", new_size_ratio=0.8, quality=80, width=800, height=600) 53 | -------------------------------------------------------------------------------- /Karri Mokshith/README.md: -------------------------------------------------------------------------------- 1 | Advance Level 2 | 3 | Task 1 :Image Converter: 4 | 5 | Where the program that accepts images in multiple formats that may be in JPEG, PNG, BMP, GIF and converts them into a desired format using Python Imaging Library (PIL) that may be any of the formats mentioned. 6 | 7 | 8 | Task 2:Data Analysis with Pandas: 9 | 10 | In the program on loading the "Iris" dataset from Seaborn and analyzing it using Pandas and performed exploratory data analysis, cleaning, aggregation, visualizations, and correlation calculations. 11 | The output of the program will consits of calculations , graph which will be more understanding to users. 12 | 13 | 14 | Task 3:Linear Regression with Scikit-learn: 15 | 16 | Completed a program by applying linear regression to predict house prices from the Boston housing dataset using scikit-learn and compared train and test scores and plot residuals. 17 | 18 | Task 4:Image Compression: 19 | 20 | Developed a Python program for compressing images while maintaining quality by exploring compression techniques like RLE and DCT and allowing users to adjust compression quality, support various image formats, and provide output options. Optionally, include a user interface. 21 | -------------------------------------------------------------------------------- /Karri Mokshith/Task1: -------------------------------------------------------------------------------- 1 | from PIL import Image 2 | import os 3 | 4 | def convert_image(input_path, output_path, output_format): 5 | try: 6 | # Open the image 7 | with Image.open(input_path) as img: 8 | # Convert and save the image to the desired format 9 | img.save(output_path, format=output_format) 10 | print(f"Image converted successfully to {output_format} format.") 11 | except Exception as e: 12 | print(f"An error occurred: {e}") 13 | 14 | def main(): 15 | input_path = input("Enter the path to the input image: ") 16 | output_format = input("Enter the desired output format (e.g., JPEG, PNG, BMP, GIF): ").upper() 17 | 18 | # Validate output format 19 | if output_format not in ['JPEG', 'PNG', 'BMP', 'GIF']: 20 | print("Invalid output format. Please choose from JPEG, PNG, BMP, or GIF.") 21 | return 22 | 23 | # Extract the file name and extension 24 | file_name, file_extension = os.path.splitext(input_path) 25 | 26 | # If the input file already has an extension, remove it 27 | file_name_without_ext = file_name.split('.')[0] 28 | 29 | # Set the output path 30 | output_path = f"{file_name_without_ext}_converted.{output_format.lower()}" 31 | 32 | # Convert the image 33 | convert_image(input_path, output_path, output_format) 34 | 35 | if __name__ == "__main__": 36 | main() 37 | -------------------------------------------------------------------------------- /Karri Mokshith/Task2: -------------------------------------------------------------------------------- 1 | import seaborn as sns 2 | import pandas as pd 3 | import matplotlib.pyplot as plt 4 | 5 | # Load the Iris dataset from Seaborn 6 | iris = sns.load_dataset("iris") 7 | numeric_iris = iris.drop(columns='species') 8 | 9 | # Display the first few rows of the dataset 10 | print("First few rows of the dataset:") 11 | print(iris.head()) 12 | 13 | # Summary statistics 14 | print("\nSummary statistics:") 15 | print(iris.describe()) 16 | 17 | # Checking for missing values 18 | print("\nMissing values:") 19 | print(iris.isnull().sum()) 20 | 21 | # Visualizations 22 | # Pairplot 23 | sns.pairplot(iris, hue="species") 24 | plt.title("Pairplot of Iris Dataset") 25 | plt.show() 26 | 27 | # Boxplot 28 | plt.figure(figsize=(10, 6)) 29 | sns.boxplot(data=iris, orient="h") 30 | plt.title("Boxplot of Iris Dataset") 31 | plt.show() 32 | 33 | # Histograms 34 | plt.figure(figsize=(10, 6)) 35 | iris.hist() 36 | plt.suptitle("Histograms of Iris Dataset") 37 | plt.show() 38 | 39 | # Correlation heatmap 40 | plt.figure(figsize=(8, 6)) 41 | sns.heatmap(numeric_iris.corr(), annot=True, cmap="coolwarm") 42 | plt.title("Correlation Heatmap of Iris Dataset") 43 | plt.show() 44 | -------------------------------------------------------------------------------- /Karri Mokshith/Task3: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import matplotlib.pyplot as plt 3 | from sklearn.model_selection import train_test_split 4 | from sklearn.linear_model import LinearRegression 5 | from sklearn.metrics import mean_squared_error 6 | import pandas as pd 7 | data_url = "http://lib.stat.cmu.edu/datasets/boston" 8 | raw_df = pd.read_csv(data_url, sep="\s+", skiprows=22, header=None) 9 | data = np.hstack([raw_df.values[::2, :], raw_df.values[1::2, :2]]) 10 | target = raw_df.values[1::2, 2] 11 | 12 | # Load the Boston housing dataset 13 | 14 | X = data 15 | y = target 16 | 17 | # Split the data into training and testing sets 18 | X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42) 19 | 20 | # Initialize the linear regression model 21 | model = LinearRegression() 22 | 23 | # Fit the model on the training data 24 | model.fit(X_train, y_train) 25 | 26 | # Predict on the training and testing data 27 | y_train_pred = model.predict(X_train) 28 | y_test_pred = model.predict(X_test) 29 | 30 | # Calculate the scores 31 | train_score = model.score(X_train, y_train) 32 | test_score = model.score(X_test, y_test) 33 | 34 | print("Training score:", train_score) 35 | print("Testing score:", test_score) 36 | 37 | # Plot residuals 38 | plt.scatter(y_train_pred, y_train_pred - y_train, c='blue', marker='o', label='Training data') 39 | plt.scatter(y_test_pred, y_test_pred - y_test, c='lightgreen', marker='s', label='Testing data') 40 | plt.xlabel('Predicted values') 41 | plt.ylabel('Residuals') 42 | plt.legend(loc='upper left') 43 | plt.hlines(y=0, xmin=0, xmax=50, lw=2, color='red') 44 | plt.title('Residual plot') 45 | plt.show() 46 | -------------------------------------------------------------------------------- /Karri Mokshith/Task4: -------------------------------------------------------------------------------- 1 | from PIL import Image 2 | import os 3 | 4 | def get_size_format(b, factor=1024, suffix="B"): 5 | """ 6 | Scale bytes to its proper byte format. 7 | e.g: 1253656 => '1.20MB', 1253656678 => '1.17GB' 8 | """ 9 | for unit in ["", "K", "M", "G", "T", "P", "E", "Z"]: 10 | if b < factor: 11 | return f"{b:.2f}{unit}{suffix}" 12 | b /= factor 13 | return f"{b:.2f}Y{suffix}" 14 | 15 | def compress_img(image_name, new_size_ratio=0.9, quality=90, width=None, height=None, to_jpg=True): 16 | # Load the image into memory 17 | img = Image.open(image_name) 18 | 19 | # Print the original image shape 20 | print("[*] Image shape:", img.size) 21 | 22 | # Get the original image size in bytes 23 | image_size = os.path.getsize(image_name) 24 | print("[*] Size before compression:", get_size_format(image_size)) 25 | 26 | if new_size_ratio < 1.0: 27 | # If resizing ratio is below 1.0, multiply width & height with this ratio to reduce image size 28 | img = img.resize((int(img.size[0] * new_size_ratio), int(img.size[1] * new_size_ratio)), Image.ANTIALIAS) 29 | elif width and height: 30 | # If width and height are set, resize with them instead 31 | img = img.resize((width, height), Image.ANTIALIAS) 32 | 33 | # Split the filename and extension 34 | filename, ext = os.path.splitext(image_name) 35 | 36 | # Make a new filename appending "_compressed" to the original file name 37 | if to_jpg: 38 | # Change the extension to JPEG 39 | new_filename = f"{filename}_compressed.jpg" 40 | else: 41 | # Retain the same extension of the original image 42 | new_filename = f"{filename}_compressed{ext}" 43 | 44 | # Save the compressed image 45 | img.save(new_filename, optimize=True, quality=quality) 46 | 47 | # Print the new image shape 48 | print("[+] New Image shape:", img.size) 49 | print(f"[*] Compressed image saved as: {new_filename}") 50 | 51 | # Example usage: 52 | compress_img("wp1966881.jpg", new_size_ratio=0.8, quality=80, width=800, height=600) 53 | -------------------------------------------------------------------------------- /Kitchaiahgari Reddy Prasanna/README.md: -------------------------------------------------------------------------------- 1 | Advance Level 2 | 3 | Task 1 :Image Converter: 4 | 5 | Where the program that accepts images in multiple formats that may be in JPEG, PNG, BMP, GIF and converts them into a desired format using Python Imaging Library (PIL) that may be any of the formats mentioned. 6 | 7 | 8 | Task 2:Data Analysis with Pandas: 9 | 10 | In the program on loading the "Iris" dataset from Seaborn and analyzing it using Pandas and performed exploratory data analysis, cleaning, aggregation, visualizations, and correlation calculations. 11 | The output of the program will consits of calculations , graph which will be more understanding to users. 12 | 13 | 14 | Task 3:Linear Regression with Scikit-learn: 15 | 16 | Completed a program by applying linear regression to predict house prices from the Boston housing dataset using scikit-learn and compared train and test scores and plot residuals. 17 | 18 | Task 4:Image Compression: 19 | 20 | Developed a Python program for compressing images while maintaining quality by exploring compression techniques like RLE and DCT and allowing users to adjust compression quality, support various image formats, and provide output options. Optionally, include a user interface. 21 | 22 | -------------------------------------------------------------------------------- /Kitchaiahgari Reddy Prasanna/Task1: -------------------------------------------------------------------------------- 1 | from PIL import Image 2 | import os 3 | 4 | def convert_image(input_path, output_path, output_format): 5 | try: 6 | # Open the image 7 | with Image.open(input_path) as img: 8 | # Convert and save the image to the desired format 9 | img.save(output_path, format=output_format) 10 | print(f"Image converted successfully to {output_format} format.") 11 | except Exception as e: 12 | print(f"An error occurred: {e}") 13 | 14 | def main(): 15 | input_path = input("Enter the path to the input image: ") 16 | output_format = input("Enter the desired output format (e.g., JPEG, PNG, BMP, GIF): ").upper() 17 | 18 | # Validate output format 19 | if output_format not in ['JPEG', 'PNG', 'BMP', 'GIF']: 20 | print("Invalid output format. Please choose from JPEG, PNG, BMP, or GIF.") 21 | return 22 | 23 | # Extract the file name and extension 24 | file_name, file_extension = os.path.splitext(input_path) 25 | 26 | # If the input file already has an extension, remove it 27 | file_name_without_ext = file_name.split('.')[0] 28 | 29 | # Set the output path 30 | output_path = f"{file_name_without_ext}_converted.{output_format.lower()}" 31 | 32 | # Convert the image 33 | convert_image(input_path, output_path, output_format) 34 | 35 | if __name__ == "__main__": 36 |     main() 37 | -------------------------------------------------------------------------------- /Kitchaiahgari Reddy Prasanna/Task2: -------------------------------------------------------------------------------- 1 | import seaborn as sns 2 | import pandas as pd 3 | import matplotlib.pyplot as plt 4 | 5 | # Load the Iris dataset from Seaborn 6 | iris = sns.load_dataset("iris") 7 | numeric_iris = iris.drop(columns='species') 8 | 9 | # Display the first few rows of the dataset 10 | print("First few rows of the dataset:") 11 | print(iris.head()) 12 | 13 | # Summary statistics 14 | print("\nSummary statistics:") 15 | print(iris.describe()) 16 | 17 | # Checking for missing values 18 | print("\nMissing values:") 19 | print(iris.isnull().sum()) 20 | 21 | # Visualizations 22 | # Pairplot 23 | sns.pairplot(iris, hue="species") 24 | plt.title("Pairplot of Iris Dataset") 25 | plt.show() 26 | 27 | # Boxplot 28 | plt.figure(figsize=(10, 6)) 29 | sns.boxplot(data=iris, orient="h") 30 | plt.title("Boxplot of Iris Dataset") 31 | plt.show() 32 | 33 | # Histograms 34 | plt.figure(figsize=(10, 6)) 35 | iris.hist() 36 | plt.suptitle("Histograms of Iris Dataset") 37 | plt.show() 38 | 39 | # Correlation heatmap 40 | plt.figure(figsize=(8, 6)) 41 | sns.heatmap(numeric_iris.corr(), annot=True, cmap="coolwarm") 42 | plt.title("Correlation Heatmap of Iris Dataset") 43 | plt.show() 44 | -------------------------------------------------------------------------------- /Kitchaiahgari Reddy Prasanna/Task3: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import matplotlib.pyplot as plt 3 | from sklearn.model_selection import train_test_split 4 | from sklearn.linear_model import LinearRegression 5 | from sklearn.metrics import mean_squared_error 6 | import pandas as pd 7 | data_url = "http://lib.stat.cmu.edu/datasets/boston" 8 | raw_df = pd.read_csv(data_url, sep="\s+", skiprows=22, header=None) 9 | data = np.hstack([raw_df.values[::2, :], raw_df.values[1::2, :2]]) 10 | target = raw_df.values[1::2, 2] 11 | 12 | # Load the Boston housing dataset 13 | 14 | X = data 15 | y = target 16 | 17 | # Split the data into training and testing sets 18 | X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42) 19 | 20 | # Initialize the linear regression model 21 | model = LinearRegression() 22 | 23 | # Fit the model on the training data 24 | model.fit(X_train, y_train) 25 | 26 | # Predict on the training and testing data 27 | y_train_pred = model.predict(X_train) 28 | y_test_pred = model.predict(X_test) 29 | 30 | # Calculate the scores 31 | train_score = model.score(X_train, y_train) 32 | test_score = model.score(X_test, y_test) 33 | 34 | print("Training score:", train_score) 35 | print("Testing score:", test_score) 36 | 37 | # Plot residuals 38 | plt.scatter(y_train_pred, y_train_pred - y_train, c='blue', marker='o', label='Training data') 39 | plt.scatter(y_test_pred, y_test_pred - y_test, c='lightgreen', marker='s', label='Testing data') 40 | plt.xlabel('Predicted values') 41 | plt.ylabel('Residuals') 42 | plt.legend(loc='upper left') 43 | plt.hlines(y=0, xmin=0, xmax=50, lw=2, color='red') 44 | plt.title('Residual plot') 45 | plt.show() 46 | -------------------------------------------------------------------------------- /Kitchaiahgari Reddy Prasanna/Task4: -------------------------------------------------------------------------------- 1 | from PIL import Image 2 | import os 3 | 4 | def get_size_format(b, factor=1024, suffix="B"): 5 | """ 6 | Scale bytes to its proper byte format. 7 | e.g: 1253656 => '1.20MB', 1253656678 => '1.17GB' 8 | """ 9 | for unit in ["", "K", "M", "G", "T", "P", "E", "Z"]: 10 | if b < factor: 11 | return f"{b:.2f}{unit}{suffix}" 12 | b /= factor 13 | return f"{b:.2f}Y{suffix}" 14 | 15 | def compress_img(image_name, new_size_ratio=0.9, quality=90, width=None, height=None, to_jpg=True): 16 | # Load the image into memory 17 | img = Image.open(image_name) 18 | 19 | # Print the original image shape 20 | print("[*] Image shape:", img.size) 21 | 22 | # Get the original image size in bytes 23 | image_size = os.path.getsize(image_name) 24 | print("[*] Size before compression:", get_size_format(image_size)) 25 | 26 | if new_size_ratio < 1.0: 27 | # If resizing ratio is below 1.0, multiply width & height with this ratio to reduce image size 28 | img = img.resize((int(img.size[0] * new_size_ratio), int(img.size[1] * new_size_ratio)), Image.ANTIALIAS) 29 | elif width and height: 30 | # If width and height are set, resize with them instead 31 | img = img.resize((width, height), Image.ANTIALIAS) 32 | 33 | # Split the filename and extension 34 | filename, ext = os.path.splitext(image_name) 35 | 36 | # Make a new filename appending "_compressed" to the original file name 37 | if to_jpg: 38 | # Change the extension to JPEG 39 | new_filename = f"{filename}_compressed.jpg" 40 | else: 41 | # Retain the same extension of the original image 42 | new_filename = f"{filename}_compressed{ext}" 43 | 44 | # Save the compressed image 45 | img.save(new_filename, optimize=True, quality=quality) 46 | 47 | # Print the new image shape 48 | print("[+] New Image shape:", img.size) 49 | print(f"[*] Compressed image saved as: {new_filename}") 50 | 51 | # Example usage: 52 | Input=input() 53 | compress_img(Input, new_size_ratio=0.8, quality=80, width=800, height=600) 54 | -------------------------------------------------------------------------------- /Konda Lakshmi Prasanna/README.md: -------------------------------------------------------------------------------- 1 | mage Compression: 2 | 3 | Developed a Python program for compressing images while maintaining quality by exploring compression techniques like RLE and DCT and allowing users to adjust compression quality, support various image formats, and provide output options. Optionally, include a user interface. 4 | This Python script utilizes the Boston housing dataset to perform linear regression. After splitting the data into training and testing sets, it trains a linear regression model on the training data and evaluates its performance on both sets. It calculates the model's scores for training and testing data. Additionally, it visualizes the residuals, highlighting discrepancies between predicted and actual values. This analysis aids in assessing the model's fit and identifying potential areas for improvement, crucial for understanding predictive accuracy and model effectiveness in real-world applications. 5 | -------------------------------------------------------------------------------- /Konda Lakshmi Prasanna/Task4: -------------------------------------------------------------------------------- 1 | from PIL import Image 2 | import os 3 | 4 | def get_size_format(b, factor=1024, suffix="B"): 5 | """ 6 | Scale bytes to its proper byte format. 7 | e.g: 1253656 => '1.20MB', 1253656678 => '1.17GB' 8 | """ 9 | for unit in ["", "K", "M", "G", "T", "P", "E", "Z"]: 10 | if b < factor: 11 | return f"{b:.2f}{unit}{suffix}" 12 | b /= factor 13 | return f"{b:.2f}Y{suffix}" 14 | 15 | def compress_img(image_name, new_size_ratio=0.9, quality=90, width=None, height=None, to_jpg=True): 16 | # Load the image into memory 17 | img = Image.open(image_name) 18 | 19 | # Print the original image shape 20 | print("[*] Image shape:", img.size) 21 | 22 | # Get the original image size in bytes 23 | image_size = os.path.getsize(image_name) 24 | print("[*] Size before compression:", get_size_format(image_size)) 25 | 26 | if new_size_ratio < 1.0: 27 | # If resizing ratio is below 1.0, multiply width & height with this ratio to reduce image size 28 | img = img.resize((int(img.size[0] * new_size_ratio), int(img.size[1] * new_size_ratio)), Image.ANTIALIAS) 29 | elif width and height: 30 | # If width and height are set, resize with them instead 31 | img = img.resize((width, height), Image.ANTIALIAS) 32 | 33 | # Split the filename and extension 34 | filename, ext = os.path.splitext(image_name) 35 | 36 | # Make a new filename appending "_compressed" to the original file name 37 | if to_jpg: 38 | # Change the extension to JPEG 39 | new_filename = f"{filename}_compressed.jpg" 40 | else: 41 | # Retain the same extension of the original image 42 | new_filename = f"{filename}_compressed{ext}" 43 | 44 | # Save the compressed image 45 | img.save(new_filename, optimize=True, quality=quality) 46 | 47 | # Print the new image shape 48 | print("[+] New Image shape:", img.size) 49 | print(f"[*] Compressed image saved as: {new_filename}") 50 | 51 | # Example usage: 52 | compress_img("wp1966881.jpg", new_size_ratio=0.8, quality=80, width=800, height=600) 53 | -------------------------------------------------------------------------------- /Kundeti Lakshmikar/README.md: -------------------------------------------------------------------------------- 1 | Advance Level 2 | 3 | Task 1 :Image Converter: 4 | 5 | Where the program that accepts images in multiple formats that may be in JPEG, PNG, BMP, GIF and converts them into a desired format using Python Imaging Library (PIL) that may be any of the formats mentioned. 6 | 7 | 8 | Task 2:Data Analysis with Pandas: 9 | 10 | In the program on loading the "Iris" dataset from Seaborn and analyzing it using Pandas and performed exploratory data analysis, cleaning, aggregation, visualizations, and correlation calculations. 11 | The output of the program will consits of calculations , graph which will be more understanding to users. 12 | 13 | 14 | Task 3:Linear Regression with Scikit-learn: 15 | 16 | Completed a program by applying linear regression to predict house prices from the Boston housing dataset using scikit-learn and compared train and test scores and plot residuals. 17 | 18 | Task 4:Image Compression: 19 | 20 | Developed a Python program for compressing images while maintaining quality by exploring compression techniques like RLE and DCT and allowing users to adjust compression quality, support various image formats, and provide output options. Optionally, include a user interface. 21 | -------------------------------------------------------------------------------- /Kundeti Lakshmikar/Task1: -------------------------------------------------------------------------------- 1 | from PIL import Image 2 | import os 3 | 4 | def convert_image(input_path, output_path, output_format): 5 | try: 6 | # Open the image 7 | with Image.open(input_path) as img: 8 | # Convert and save the image to the desired format 9 | img.save(output_path, format=output_format) 10 | print(f"Image converted successfully to {output_format} format.") 11 | except Exception as e: 12 | print(f"An error occurred: {e}") 13 | 14 | def main(): 15 | input_path = input("Enter the path to the input image: ") 16 | output_format = input("Enter the desired output format (e.g., JPEG, PNG, BMP, GIF): ").upper() 17 | 18 | # Validate output format 19 | if output_format not in ['JPEG', 'PNG', 'BMP', 'GIF']: 20 | print("Invalid output format. Please choose from JPEG, PNG, BMP, or GIF.") 21 | return 22 | 23 | # Extract the file name and extension 24 | file_name, file_extension = os.path.splitext(input_path) 25 | 26 | # If the input file already has an extension, remove it 27 | file_name_without_ext = file_name.split('.')[0] 28 | 29 | # Set the output path 30 | output_path = f"{file_name_without_ext}_converted.{output_format.lower()}" 31 | 32 | # Convert the image 33 | convert_image(input_path, output_path, output_format) 34 | 35 | if __name__ == "__main__": 36 |     main() 37 | -------------------------------------------------------------------------------- /Kundeti Lakshmikar/Task2: -------------------------------------------------------------------------------- 1 | import seaborn as sns 2 | import pandas as pd 3 | import matplotlib.pyplot as plt 4 | 5 | # Load the Iris dataset from Seaborn 6 | iris = sns.load_dataset("iris") 7 | numeric_iris = iris.drop(columns='species') 8 | 9 | # Display the first few rows of the dataset 10 | print("First few rows of the dataset:") 11 | print(iris.head()) 12 | 13 | # Summary statistics 14 | print("\nSummary statistics:") 15 | print(iris.describe()) 16 | 17 | # Checking for missing values 18 | print("\nMissing values:") 19 | print(iris.isnull().sum()) 20 | 21 | # Visualizations 22 | # Pairplot 23 | sns.pairplot(iris, hue="species") 24 | plt.title("Pairplot of Iris Dataset") 25 | plt.show() 26 | 27 | # Boxplot 28 | plt.figure(figsize=(10, 6)) 29 | sns.boxplot(data=iris, orient="h") 30 | plt.title("Boxplot of Iris Dataset") 31 | plt.show() 32 | 33 | # Histograms 34 | plt.figure(figsize=(10, 6)) 35 | iris.hist() 36 | plt.suptitle("Histograms of Iris Dataset") 37 | plt.show() 38 | 39 | # Correlation heatmap 40 | plt.figure(figsize=(8, 6)) 41 | sns.heatmap(numeric_iris.corr(), annot=True, cmap="coolwarm") 42 | plt.title("Correlation Heatmap of Iris Dataset") 43 | plt.show() 44 | -------------------------------------------------------------------------------- /Kundeti Lakshmikar/Task3: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import matplotlib.pyplot as plt 3 | from sklearn.model_selection import train_test_split 4 | from sklearn.linear_model import LinearRegression 5 | from sklearn.metrics import mean_squared_error 6 | import pandas as pd 7 | data_url = "http://lib.stat.cmu.edu/datasets/boston" 8 | raw_df = pd.read_csv(data_url, sep="\s+", skiprows=22, header=None) 9 | data = np.hstack([raw_df.values[::2, :], raw_df.values[1::2, :2]]) 10 | target = raw_df.values[1::2, 2] 11 | 12 | # Load the Boston housing dataset 13 | 14 | X = data 15 | y = target 16 | 17 | # Split the data into training and testing sets 18 | X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42) 19 | 20 | # Initialize the linear regression model 21 | model = LinearRegression() 22 | 23 | # Fit the model on the training data 24 | model.fit(X_train, y_train) 25 | 26 | # Predict on the training and testing data 27 | y_train_pred = model.predict(X_train) 28 | y_test_pred = model.predict(X_test) 29 | 30 | # Calculate the scores 31 | train_score = model.score(X_train, y_train) 32 | test_score = model.score(X_test, y_test) 33 | 34 | print("Training score:", train_score) 35 | print("Testing score:", test_score) 36 | 37 | # Plot residuals 38 | plt.scatter(y_train_pred, y_train_pred - y_train, c='blue', marker='o', label='Training data') 39 | plt.scatter(y_test_pred, y_test_pred - y_test, c='lightgreen', marker='s', label='Testing data') 40 | plt.xlabel('Predicted values') 41 | plt.ylabel('Residuals') 42 | plt.legend(loc='upper left') 43 | plt.hlines(y=0, xmin=0, xmax=50, lw=2, color='red') 44 | plt.title('Residual plot') 45 | plt.show() 46 | -------------------------------------------------------------------------------- /Kundeti Lakshmikar/Task4: -------------------------------------------------------------------------------- 1 | from PIL import Image 2 | import os 3 | 4 | def get_size_format(b, factor=1024, suffix="B"): 5 | """ 6 | Scale bytes to its proper byte format. 7 | e.g: 1253656 => '1.20MB', 1253656678 => '1.17GB' 8 | """ 9 | for unit in ["", "K", "M", "G", "T", "P", "E", "Z"]: 10 | if b < factor: 11 | return f"{b:.2f}{unit}{suffix}" 12 | b /= factor 13 | return f"{b:.2f}Y{suffix}" 14 | 15 | def compress_img(image_name, new_size_ratio=0.9, quality=90, width=None, height=None, to_jpg=True): 16 | # Load the image into memory 17 | img = Image.open(image_name) 18 | 19 | # Print the original image shape 20 | print("[*] Image shape:", img.size) 21 | 22 | # Get the original image size in bytes 23 | image_size = os.path.getsize(image_name) 24 | print("[*] Size before compression:", get_size_format(image_size)) 25 | 26 | if new_size_ratio < 1.0: 27 | # If resizing ratio is below 1.0, multiply width & height with this ratio to reduce image size 28 | img = img.resize((int(img.size[0] * new_size_ratio), int(img.size[1] * new_size_ratio)), Image.ANTIALIAS) 29 | elif width and height: 30 | # If width and height are set, resize with them instead 31 | img = img.resize((width, height), Image.ANTIALIAS) 32 | 33 | # Split the filename and extension 34 | filename, ext = os.path.splitext(image_name) 35 | 36 | # Make a new filename appending "_compressed" to the original file name 37 | if to_jpg: 38 | # Change the extension to JPEG 39 | new_filename = f"{filename}_compressed.jpg" 40 | else: 41 | # Retain the same extension of the original image 42 | new_filename = f"{filename}_compressed{ext}" 43 | 44 | # Save the compressed image 45 | img.save(new_filename, optimize=True, quality=quality) 46 | 47 | # Print the new image shape 48 | print("[+] New Image shape:", img.size) 49 | print(f"[*] Compressed image saved as: {new_filename}") 50 | 51 | # Example usage: 52 | Input=input() 53 | compress_img(Input, new_size_ratio=0.8, quality=80, width=800, height=600) 54 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 CSEdge 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Lakshmiprasanna8008/README.md: -------------------------------------------------------------------------------- 1 | Linear Regression with Scikit-learn: 2 | 3 | Completed a program by applying linear regression to predict house prices from the Boston housing dataset using scikit-learn and compared train and test scores and plot residuals. 4 | 5 | This Python script utilizes the Boston housing dataset to perform linear regression. After splitting the data into training and testing sets, it trains a linear regression model on the training data and evaluates its performance on both sets. It calculates the model's scores for training and testing data. Additionally, it visualizes the residuals, highlighting discrepancies between predicted and actual values. This analysis aids in assessing the model's fit and identifying potential areas for improvement, crucial for understanding predictive accuracy and model effectiveness in real-world applications. 6 | -------------------------------------------------------------------------------- /Lakshmiprasanna8008/Task3: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import matplotlib.pyplot as plt 3 | from sklearn.model_selection import train_test_split 4 | from sklearn.linear_model import LinearRegression 5 | from sklearn.metrics import mean_squared_error 6 | import pandas as pd 7 | data_url = "http://lib.stat.cmu.edu/datasets/boston" 8 | raw_df = pd.read_csv(data_url, sep="\s+", skiprows=22, header=None) 9 | data = np.hstack([raw_df.values[::2, :], raw_df.values[1::2, :2]]) 10 | target = raw_df.values[1::2, 2] 11 | 12 | # Load the Boston housing dataset 13 | 14 | X = data 15 | y = target 16 | 17 | # Split the data into training and testing sets 18 | X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42) 19 | 20 | # Initialize the linear regression model 21 | model = LinearRegression() 22 | 23 | # Fit the model on the training data 24 | model.fit(X_train, y_train) 25 | 26 | # Predict on the training and testing data 27 | y_train_pred = model.predict(X_train) 28 | y_test_pred = model.predict(X_test) 29 | 30 | # Calculate the scores 31 | train_score = model.score(X_train, y_train) 32 | test_score = model.score(X_test, y_test) 33 | 34 | print("Training score:", train_score) 35 | print("Testing score:", test_score) 36 | 37 | # Plot residuals 38 | plt.scatter(y_train_pred, y_train_pred - y_train, c='blue', marker='o', label='Training data') 39 | plt.scatter(y_test_pred, y_test_pred - y_test, c='lightgreen', marker='s', label='Testing data') 40 | plt.xlabel('Predicted values') 41 | plt.ylabel('Residuals') 42 | plt.legend(loc='upper left') 43 | plt.hlines(y=0, xmin=0, xmax=50, lw=2, color='red') 44 | plt.title('Residual plot') 45 | plt.show() 46 | -------------------------------------------------------------------------------- /LayavardhanReddy MaddiReddy/README.md: -------------------------------------------------------------------------------- 1 | Advance Level 2 | 3 | Task 1 :Image Converter: 4 | 5 | Where the program that accepts images in multiple formats that may be in JPEG, PNG, BMP, GIF and converts them into a desired format using Python Imaging Library (PIL) that may be any of the formats mentioned. 6 | 7 | 8 | Task 2:Data Analysis with Pandas: 9 | 10 | In the program on loading the "Iris" dataset from Seaborn and analyzing it using Pandas and performed exploratory data analysis, cleaning, aggregation, visualizations, and correlation calculations. 11 | The output of the program will consits of calculations , graph which will be more understanding to users. 12 | 13 | 14 | Task 3:Linear Regression with Scikit-learn: 15 | 16 | Completed a program by applying linear regression to predict house prices from the Boston housing dataset using scikit-learn and compared train and test scores and plot residuals. 17 | 18 | Task 4:Image Compression: 19 | 20 | Developed a Python program for compressing images while maintaining quality by exploring compression techniques like RLE and DCT and allowing users to adjust compression quality, support various image formats, and provide output options. Optionally, include a user interface. 21 | -------------------------------------------------------------------------------- /LayavardhanReddy MaddiReddy/Task1: -------------------------------------------------------------------------------- 1 | from PIL import Image 2 | import os 3 | 4 | def convert_image(input_path, output_path, output_format): 5 | try: 6 | # Open the image 7 | with Image.open(input_path) as img: 8 | # Convert and save the image to the desired format 9 | img.save(output_path, format=output_format) 10 | print(f"Image converted successfully to {output_format} format.") 11 | except Exception as e: 12 | print(f"An error occurred: {e}") 13 | 14 | def main(): 15 | input_path = input("Enter the path to the input image: ") 16 | output_format = input("Enter the desired output format (e.g., JPEG, PNG, BMP, GIF): ").upper() 17 | 18 | # Validate output format 19 | if output_format not in ['JPEG', 'PNG', 'BMP', 'GIF']: 20 | print("Invalid output format. Please choose from JPEG, PNG, BMP, or GIF.") 21 | return 22 | 23 | # Extract the file name and extension 24 | file_name, file_extension = os.path.splitext(input_path) 25 | 26 | # If the input file already has an extension, remove it 27 | file_name_without_ext = file_name.split('.')[0] 28 | 29 | # Set the output path 30 | output_path = f"{file_name_without_ext}_converted.{output_format.lower()}" 31 | 32 | # Convert the image 33 | convert_image(input_path, output_path, output_format) 34 | 35 | if __name__ == "__main__": 36 | main() 37 | -------------------------------------------------------------------------------- /LayavardhanReddy MaddiReddy/Task2: -------------------------------------------------------------------------------- 1 | import seaborn as sns 2 | import pandas as pd 3 | import matplotlib.pyplot as plt 4 | 5 | # Load the Iris dataset from Seaborn 6 | iris = sns.load_dataset("iris") 7 | numeric_iris = iris.drop(columns='species') 8 | 9 | # Display the first few rows of the dataset 10 | print("First few rows of the dataset:") 11 | print(iris.head()) 12 | 13 | # Summary statistics 14 | print("\nSummary statistics:") 15 | print(iris.describe()) 16 | 17 | # Checking for missing values 18 | print("\nMissing values:") 19 | print(iris.isnull().sum()) 20 | 21 | # Visualizations 22 | # Pairplot 23 | sns.pairplot(iris, hue="species") 24 | plt.title("Pairplot of Iris Dataset") 25 | plt.show() 26 | 27 | # Boxplot 28 | plt.figure(figsize=(10, 6)) 29 | sns.boxplot(data=iris, orient="h") 30 | plt.title("Boxplot of Iris Dataset") 31 | plt.show() 32 | 33 | # Histograms 34 | plt.figure(figsize=(10, 6)) 35 | iris.hist() 36 | plt.suptitle("Histograms of Iris Dataset") 37 | plt.show() 38 | 39 | # Correlation heatmap 40 | plt.figure(figsize=(8, 6)) 41 | sns.heatmap(numeric_iris.corr(), annot=True, cmap="coolwarm") 42 | plt.title("Correlation Heatmap of Iris Dataset") 43 | plt.show() 44 | -------------------------------------------------------------------------------- /LayavardhanReddy MaddiReddy/Task3: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import matplotlib.pyplot as plt 3 | from sklearn.model_selection import train_test_split 4 | from sklearn.linear_model import LinearRegression 5 | from sklearn.metrics import mean_squared_error 6 | import pandas as pd 7 | data_url = "http://lib.stat.cmu.edu/datasets/boston" 8 | raw_df = pd.read_csv(data_url, sep="\s+", skiprows=22, header=None) 9 | data = np.hstack([raw_df.values[::2, :], raw_df.values[1::2, :2]]) 10 | target = raw_df.values[1::2, 2] 11 | 12 | # Load the Boston housing dataset 13 | 14 | X = data 15 | y = target 16 | 17 | # Split the data into training and testing sets 18 | X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42) 19 | 20 | # Initialize the linear regression model 21 | model = LinearRegression() 22 | 23 | # Fit the model on the training data 24 | model.fit(X_train, y_train) 25 | 26 | # Predict on the training and testing data 27 | y_train_pred = model.predict(X_train) 28 | y_test_pred = model.predict(X_test) 29 | 30 | # Calculate the scores 31 | train_score = model.score(X_train, y_train) 32 | test_score = model.score(X_test, y_test) 33 | 34 | print("Training score:", train_score) 35 | print("Testing score:", test_score) 36 | 37 | # Plot residuals 38 | plt.scatter(y_train_pred, y_train_pred - y_train, c='blue', marker='o', label='Training data') 39 | plt.scatter(y_test_pred, y_test_pred - y_test, c='lightgreen', marker='s', label='Testing data') 40 | plt.xlabel('Predicted values') 41 | plt.ylabel('Residuals') 42 | plt.legend(loc='upper left') 43 | plt.hlines(y=0, xmin=0, xmax=50, lw=2, color='red') 44 | plt.title('Residual plot') 45 | plt.show() 46 | -------------------------------------------------------------------------------- /LayavardhanReddy MaddiReddy/Task4: -------------------------------------------------------------------------------- 1 | from PIL import Image 2 | import os 3 | 4 | def get_size_format(b, factor=1024, suffix="B"): 5 | """ 6 | Scale bytes to its proper byte format. 7 | e.g: 1253656 => '1.20MB', 1253656678 => '1.17GB' 8 | """ 9 | for unit in ["", "K", "M", "G", "T", "P", "E", "Z"]: 10 | if b < factor: 11 | return f"{b:.2f}{unit}{suffix}" 12 | b /= factor 13 | return f"{b:.2f}Y{suffix}" 14 | 15 | def compress_img(image_name, new_size_ratio=0.9, quality=90, width=None, height=None, to_jpg=True): 16 | # Load the image into memory 17 | img = Image.open(image_name) 18 | 19 | # Print the original image shape 20 | print("[*] Image shape:", img.size) 21 | 22 | # Get the original image size in bytes 23 | image_size = os.path.getsize(image_name) 24 | print("[*] Size before compression:", get_size_format(image_size)) 25 | 26 | if new_size_ratio < 1.0: 27 | # If resizing ratio is below 1.0, multiply width & height with this ratio to reduce image size 28 | img = img.resize((int(img.size[0] * new_size_ratio), int(img.size[1] * new_size_ratio)), Image.ANTIALIAS) 29 | elif width and height: 30 | # If width and height are set, resize with them instead 31 | img = img.resize((width, height), Image.ANTIALIAS) 32 | 33 | # Split the filename and extension 34 | filename, ext = os.path.splitext(image_name) 35 | 36 | # Make a new filename appending "_compressed" to the original file name 37 | if to_jpg: 38 | # Change the extension to JPEG 39 | new_filename = f"{filename}_compressed.jpg" 40 | else: 41 | # Retain the same extension of the original image 42 | new_filename = f"{filename}_compressed{ext}" 43 | 44 | # Save the compressed image 45 | img.save(new_filename, optimize=True, quality=quality) 46 | 47 | # Print the new image shape 48 | print("[+] New Image shape:", img.size) 49 | print(f"[*] Compressed image saved as: {new_filename}") 50 | 51 | # Example usage: 52 | compress_img("wp1966881.jpg", new_size_ratio=0.8, quality=80, width=800, height=600) 53 | -------------------------------------------------------------------------------- /Mogilipalli Bhargavi/README.md: -------------------------------------------------------------------------------- 1 | Advance Level 2 | 3 | Task 1 :Image Converter: 4 | 5 | Where the program that accepts images in multiple formats that may be in JPEG, PNG, BMP, GIF and converts them into a desired format using Python Imaging Library (PIL) that may be any of the formats mentioned. 6 | 7 | 8 | Task 2:Data Analysis with Pandas: 9 | 10 | In the program on loading the "Iris" dataset from Seaborn and analyzing it using Pandas and performed exploratory data analysis, cleaning, aggregation, visualizations, and correlation calculations. 11 | The output of the program will consits of calculations , graph which will be more understanding to users. 12 | 13 | 14 | Task 3:Linear Regression with Scikit-learn: 15 | 16 | Completed a program by applying linear regression to predict house prices from the Boston housing dataset using scikit-learn and compared train and test scores and plot residuals. 17 | 18 | Task 4:Image Compression: 19 | 20 | Developed a Python program for compressing images while maintaining quality by exploring compression techniques like RLE and DCT and allowing users to adjust compression quality, support various image formats, and provide output options. Optionally, include a user interface. 21 | -------------------------------------------------------------------------------- /Mogilipalli Bhargavi/Task1: -------------------------------------------------------------------------------- 1 | from PIL import Image 2 | import os 3 | 4 | def convert_image(input_path, output_path, output_format): 5 | try: 6 | # Open the image 7 | with Image.open(input_path) as img: 8 | # Convert and save the image to the desired format 9 | img.save(output_path, format=output_format) 10 | print(f"Image converted successfully to {output_format} format.") 11 | except Exception as e: 12 | print(f"An error occurred: {e}") 13 | 14 | def main(): 15 | input_path = input("Enter the path to the input image: ") 16 | output_format = input("Enter the desired output format (e.g., JPEG, PNG, BMP, GIF): ").upper() 17 | 18 | # Validate output format 19 | if output_format not in ['JPEG', 'PNG', 'BMP', 'GIF']: 20 | print("Invalid output format. Please choose from JPEG, PNG, BMP, or GIF.") 21 | return 22 | 23 | # Extract the file name and extension 24 | file_name, file_extension = os.path.splitext(input_path) 25 | 26 | # If the input file already has an extension, remove it 27 | file_name_without_ext = file_name.split('.')[0] 28 | 29 | # Set the output path 30 | output_path = f"{file_name_without_ext}_converted.{output_format.lower()}" 31 | 32 | # Convert the image 33 | convert_image(input_path, output_path, output_format) 34 | 35 | if __name__ == "__main__": 36 | main() 37 | -------------------------------------------------------------------------------- /Mogilipalli Bhargavi/Task2: -------------------------------------------------------------------------------- 1 | import seaborn as sns 2 | import pandas as pd 3 | import matplotlib.pyplot as plt 4 | 5 | # Load the Iris dataset from Seaborn 6 | iris = sns.load_dataset("iris") 7 | numeric_iris = iris.drop(columns='species') 8 | 9 | # Display the first few rows of the dataset 10 | print("First few rows of the dataset:") 11 | print(iris.head()) 12 | 13 | # Summary statistics 14 | print("\nSummary statistics:") 15 | print(iris.describe()) 16 | 17 | # Checking for missing values 18 | print("\nMissing values:") 19 | print(iris.isnull().sum()) 20 | 21 | # Visualizations 22 | # Pairplot 23 | sns.pairplot(iris, hue="species") 24 | plt.title("Pairplot of Iris Dataset") 25 | plt.show() 26 | 27 | # Boxplot 28 | plt.figure(figsize=(10, 6)) 29 | sns.boxplot(data=iris, orient="h") 30 | plt.title("Boxplot of Iris Dataset") 31 | plt.show() 32 | 33 | # Histograms 34 | plt.figure(figsize=(10, 6)) 35 | iris.hist() 36 | plt.suptitle("Histograms of Iris Dataset") 37 | plt.show() 38 | 39 | # Correlation heatmap 40 | plt.figure(figsize=(8, 6)) 41 | sns.heatmap(numeric_iris.corr(), annot=True, cmap="coolwarm") 42 | plt.title("Correlation Heatmap of Iris Dataset") 43 | plt.show() 44 | -------------------------------------------------------------------------------- /Mogilipalli Bhargavi/Task3: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import matplotlib.pyplot as plt 3 | from sklearn.model_selection import train_test_split 4 | from sklearn.linear_model import LinearRegression 5 | from sklearn.metrics import mean_squared_error 6 | import pandas as pd 7 | data_url = "http://lib.stat.cmu.edu/datasets/boston" 8 | raw_df = pd.read_csv(data_url, sep="\s+", skiprows=22, header=None) 9 | data = np.hstack([raw_df.values[::2, :], raw_df.values[1::2, :2]]) 10 | target = raw_df.values[1::2, 2] 11 | 12 | # Load the Boston housing dataset 13 | 14 | X = data 15 | y = target 16 | 17 | # Split the data into training and testing sets 18 | X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42) 19 | 20 | # Initialize the linear regression model 21 | model = LinearRegression() 22 | 23 | # Fit the model on the training data 24 | model.fit(X_train, y_train) 25 | 26 | # Predict on the training and testing data 27 | y_train_pred = model.predict(X_train) 28 | y_test_pred = model.predict(X_test) 29 | 30 | # Calculate the scores 31 | train_score = model.score(X_train, y_train) 32 | test_score = model.score(X_test, y_test) 33 | 34 | print("Training score:", train_score) 35 | print("Testing score:", test_score) 36 | 37 | # Plot residuals 38 | plt.scatter(y_train_pred, y_train_pred - y_train, c='blue', marker='o', label='Training data') 39 | plt.scatter(y_test_pred, y_test_pred - y_test, c='lightgreen', marker='s', label='Testing data') 40 | plt.xlabel('Predicted values') 41 | plt.ylabel('Residuals') 42 | plt.legend(loc='upper left') 43 | plt.hlines(y=0, xmin=0, xmax=50, lw=2, color='red') 44 | plt.title('Residual plot') 45 | plt.show() 46 | -------------------------------------------------------------------------------- /Mogilipalli Bhargavi/Task4: -------------------------------------------------------------------------------- 1 | from PIL import Image 2 | import os 3 | 4 | def get_size_format(b, factor=1024, suffix="B"): 5 | """ 6 | Scale bytes to its proper byte format. 7 | e.g: 1253656 => '1.20MB', 1253656678 => '1.17GB' 8 | """ 9 | for unit in ["", "K", "M", "G", "T", "P", "E", "Z"]: 10 | if b < factor: 11 | return f"{b:.2f}{unit}{suffix}" 12 | b /= factor 13 | return f"{b:.2f}Y{suffix}" 14 | 15 | def compress_img(image_name, new_size_ratio=0.9, quality=90, width=None, height=None, to_jpg=True): 16 | # Load the image into memory 17 | img = Image.open(image_name) 18 | 19 | # Print the original image shape 20 | print("[*] Image shape:", img.size) 21 | 22 | # Get the original image size in bytes 23 | image_size = os.path.getsize(image_name) 24 | print("[*] Size before compression:", get_size_format(image_size)) 25 | 26 | if new_size_ratio < 1.0: 27 | # If resizing ratio is below 1.0, multiply width & height with this ratio to reduce image size 28 | img = img.resize((int(img.size[0] * new_size_ratio), int(img.size[1] * new_size_ratio)), Image.ANTIALIAS) 29 | elif width and height: 30 | # If width and height are set, resize with them instead 31 | img = img.resize((width, height), Image.ANTIALIAS) 32 | 33 | # Split the filename and extension 34 | filename, ext = os.path.splitext(image_name) 35 | 36 | # Make a new filename appending "_compressed" to the original file name 37 | if to_jpg: 38 | # Change the extension to JPEG 39 | new_filename = f"{filename}_compressed.jpg" 40 | else: 41 | # Retain the same extension of the original image 42 | new_filename = f"{filename}_compressed{ext}" 43 | 44 | # Save the compressed image 45 | img.save(new_filename, optimize=True, quality=quality) 46 | 47 | # Print the new image shape 48 | print("[+] New Image shape:", img.size) 49 | print(f"[*] Compressed image saved as: {new_filename}") 50 | 51 | # Example usage: 52 | compress_img("wp1966881.jpg", new_size_ratio=0.8, quality=80, width=800, height=600) 53 | -------------------------------------------------------------------------------- /NELABALLI BHANUPRAKASH REDDY/README.md: -------------------------------------------------------------------------------- 1 | Advance Level 2 | 3 | Task 1 :Image Converter: 4 | 5 | Where the program that accepts images in multiple formats that may be in JPEG, PNG, BMP, GIF and converts them into a desired format using Python Imaging Library (PIL) that may be any of the formats mentioned. 6 | 7 | 8 | Task 2:Data Analysis with Pandas: 9 | 10 | In the program on loading the "Iris" dataset from Seaborn and analyzing it using Pandas and performed exploratory data analysis, cleaning, aggregation, visualizations, and correlation calculations. 11 | The output of the program will consits of calculations , graph which will be more understanding to users. 12 | 13 | 14 | Task 3:Linear Regression with Scikit-learn: 15 | 16 | Completed a program by applying linear regression to predict house prices from the Boston housing dataset using scikit-learn and compared train and test scores and plot residuals. 17 | 18 | Task 4:Image Compression: 19 | 20 | Developed a Python program for compressing images while maintaining quality by exploring compression techniques like RLE and DCT and allowing users to adjust compression quality, support various image formats, and provide output options. Optionally, include a user interface. 21 | -------------------------------------------------------------------------------- /NELABALLI BHANUPRAKASH REDDY/Task1: -------------------------------------------------------------------------------- 1 | from PIL import Image 2 | import os 3 | 4 | def convert_image(input_path, output_path, output_format): 5 | try: 6 | # Open the image 7 | with Image.open(input_path) as img: 8 | # Convert and save the image to the desired format 9 | img.save(output_path, format=output_format) 10 | print(f"Image converted successfully to {output_format} format.") 11 | except Exception as e: 12 | print(f"An error occurred: {e}") 13 | 14 | def main(): 15 | input_path = input("Enter the path to the input image: ") 16 | output_format = input("Enter the desired output format (e.g., JPEG, PNG, BMP, GIF): ").upper() 17 | 18 | # Validate output format 19 | if output_format not in ['JPEG', 'PNG', 'BMP', 'GIF']: 20 | print("Invalid output format. Please choose from JPEG, PNG, BMP, or GIF.") 21 | return 22 | 23 | # Extract the file name and extension 24 | file_name, file_extension = os.path.splitext(input_path) 25 | 26 | # If the input file already has an extension, remove it 27 | file_name_without_ext = file_name.split('.')[0] 28 | 29 | # Set the output path 30 | output_path = f"{file_name_without_ext}_converted.{output_format.lower()}" 31 | 32 | # Convert the image 33 | convert_image(input_path, output_path, output_format) 34 | 35 | if __name__ == "__main__": 36 |     main() 37 | -------------------------------------------------------------------------------- /NELABALLI BHANUPRAKASH REDDY/Task2: -------------------------------------------------------------------------------- 1 | import seaborn as sns 2 | import pandas as pd 3 | import matplotlib.pyplot as plt 4 | 5 | # Load the Iris dataset from Seaborn 6 | iris = sns.load_dataset("iris") 7 | numeric_iris = iris.drop(columns='species') 8 | 9 | # Display the first few rows of the dataset 10 | print("First few rows of the dataset:") 11 | print(iris.head()) 12 | 13 | # Summary statistics 14 | print("\nSummary statistics:") 15 | print(iris.describe()) 16 | 17 | # Checking for missing values 18 | print("\nMissing values:") 19 | print(iris.isnull().sum()) 20 | 21 | # Visualizations 22 | # Pairplot 23 | sns.pairplot(iris, hue="species") 24 | plt.title("Pairplot of Iris Dataset") 25 | plt.show() 26 | 27 | # Boxplot 28 | plt.figure(figsize=(10, 6)) 29 | sns.boxplot(data=iris, orient="h") 30 | plt.title("Boxplot of Iris Dataset") 31 | plt.show() 32 | 33 | # Histograms 34 | plt.figure(figsize=(10, 6)) 35 | iris.hist() 36 | plt.suptitle("Histograms of Iris Dataset") 37 | plt.show() 38 | 39 | # Correlation heatmap 40 | plt.figure(figsize=(8, 6)) 41 | sns.heatmap(numeric_iris.corr(), annot=True, cmap="coolwarm") 42 | plt.title("Correlation Heatmap of Iris Dataset") 43 | plt.show() 44 | -------------------------------------------------------------------------------- /NELABALLI BHANUPRAKASH REDDY/Task3: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import matplotlib.pyplot as plt 3 | from sklearn.model_selection import train_test_split 4 | from sklearn.linear_model import LinearRegression 5 | from sklearn.metrics import mean_squared_error 6 | import pandas as pd 7 | data_url = "http://lib.stat.cmu.edu/datasets/boston" 8 | raw_df = pd.read_csv(data_url, sep="\s+", skiprows=22, header=None) 9 | data = np.hstack([raw_df.values[::2, :], raw_df.values[1::2, :2]]) 10 | target = raw_df.values[1::2, 2] 11 | 12 | # Load the Boston housing dataset 13 | 14 | X = data 15 | y = target 16 | 17 | # Split the data into training and testing sets 18 | X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42) 19 | 20 | # Initialize the linear regression model 21 | model = LinearRegression() 22 | 23 | # Fit the model on the training data 24 | model.fit(X_train, y_train) 25 | 26 | # Predict on the training and testing data 27 | y_train_pred = model.predict(X_train) 28 | y_test_pred = model.predict(X_test) 29 | 30 | # Calculate the scores 31 | train_score = model.score(X_train, y_train) 32 | test_score = model.score(X_test, y_test) 33 | 34 | print("Training score:", train_score) 35 | print("Testing score:", test_score) 36 | 37 | # Plot residuals 38 | plt.scatter(y_train_pred, y_train_pred - y_train, c='blue', marker='o', label='Training data') 39 | plt.scatter(y_test_pred, y_test_pred - y_test, c='lightgreen', marker='s', label='Testing data') 40 | plt.xlabel('Predicted values') 41 | plt.ylabel('Residuals') 42 | plt.legend(loc='upper left') 43 | plt.hlines(y=0, xmin=0, xmax=50, lw=2, color='red') 44 | plt.title('Residual plot') 45 | plt.show() 46 | -------------------------------------------------------------------------------- /NELABALLI BHANUPRAKASH REDDY/Task4: -------------------------------------------------------------------------------- 1 | from PIL import Image 2 | import os 3 | 4 | def get_size_format(b, factor=1024, suffix="B"): 5 | """ 6 | Scale bytes to its proper byte format. 7 | e.g: 1253656 => '1.20MB', 1253656678 => '1.17GB' 8 | """ 9 | for unit in ["", "K", "M", "G", "T", "P", "E", "Z"]: 10 | if b < factor: 11 | return f"{b:.2f}{unit}{suffix}" 12 | b /= factor 13 | return f"{b:.2f}Y{suffix}" 14 | 15 | def compress_img(image_name, new_size_ratio=0.9, quality=90, width=None, height=None, to_jpg=True): 16 | # Load the image into memory 17 | img = Image.open(image_name) 18 | 19 | # Print the original image shape 20 | print("[*] Image shape:", img.size) 21 | 22 | # Get the original image size in bytes 23 | image_size = os.path.getsize(image_name) 24 | print("[*] Size before compression:", get_size_format(image_size)) 25 | 26 | if new_size_ratio < 1.0: 27 | # If resizing ratio is below 1.0, multiply width & height with this ratio to reduce image size 28 | img = img.resize((int(img.size[0] * new_size_ratio), int(img.size[1] * new_size_ratio)), Image.ANTIALIAS) 29 | elif width and height: 30 | # If width and height are set, resize with them instead 31 | img = img.resize((width, height), Image.ANTIALIAS) 32 | 33 | # Split the filename and extension 34 | filename, ext = os.path.splitext(image_name) 35 | 36 | # Make a new filename appending "_compressed" to the original file name 37 | if to_jpg: 38 | # Change the extension to JPEG 39 | new_filename = f"{filename}_compressed.jpg" 40 | else: 41 | # Retain the same extension of the original image 42 | new_filename = f"{filename}_compressed{ext}" 43 | 44 | # Save the compressed image 45 | img.save(new_filename, optimize=True, quality=quality) 46 | 47 | # Print the new image shape 48 | print("[+] New Image shape:", img.size) 49 | print(f"[*] Compressed image saved as: {new_filename}") 50 | 51 | # Example usage: 52 | compress_img("wp1999881.jpg", new_size_ratio=0.8, quality=80, width=800, height=600) 53 | -------------------------------------------------------------------------------- /Naga Sathvik Rapelli/Hard Tasks/Task 10/task10.py: -------------------------------------------------------------------------------- 1 | #1. Load the DataSet: 2 | import seaborn as sns 3 | iris_df = sns.load_dataset('iris') 4 | 5 | #2. Exploratory Data Analysis (EDA): 6 | 7 | print(iris_df.info()) 8 | print(iris_df.describe()) 9 | print(iris_df.head()) 10 | 11 | #3. Data Cleaning: 12 | 13 | print(iris_df.isnull().sum()) 14 | print(iris_df.duplicated().sum()) 15 | 16 | #4. Aggregation: 17 | 18 | species_mean = iris_df.groupby('species').mean() 19 | 20 | #5. Visualizations: 21 | 22 | import matplotlib.pyplot as plt 23 | import seaborn as sns 24 | 25 | sns.pairplot(iris_df, hue='species') 26 | plt.show() 27 | 28 | sns.heatmap(iris_df.corr(), annot=True, cmap='coolwarm') 29 | plt.show() 30 | 31 | #6. Correlation Calculations: 32 | 33 | correlation_matrix = iris_df.corr() 34 | -------------------------------------------------------------------------------- /Naga Sathvik Rapelli/Hard Tasks/Task 11/task11.py: -------------------------------------------------------------------------------- 1 | #1. Load the Dataset: 2 | 3 | from sklearn.datasets import load_boston 4 | boston = load_boston() 5 | 6 | #2. Prepare the Data: 7 | 8 | import pandas as pd 9 | 10 | boston_df = pd.DataFrame(boston.data, columns=boston.feature_names) 11 | boston_df['PRICE'] = boston.target 12 | 13 | X = boston_df.drop('PRICE', axis=1) 14 | y = boston_df['PRICE'] 15 | 16 | #3. Split the Data: 17 | 18 | from sklearn.model_selection import train_test_split 19 | 20 | X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42) 21 | 22 | #4. Train the Model: 23 | 24 | from sklearn.linear_model import LinearRegression 25 | 26 | model = LinearRegression() 27 | model.fit(X_train, y_train) 28 | 29 | #5. Evaluate the Model: 30 | 31 | train_score = model.score(X_train, y_train) 32 | print(f'Training Score: {train_score}') 33 | 34 | test_score = model.score(X_test, y_test) 35 | print(f'Testing Score: {test_score}') 36 | 37 | #6. Plot Residuals: 38 | 39 | import matplotlib.pyplot as plt 40 | 41 | train_residuals = y_train - model.predict(X_train) 42 | test_residuals = y_test - model.predict(X_test) 43 | 44 | plt.figure(figsize=(10, 5)) 45 | plt.scatter(model.predict(X_train), train_residuals, label='Train Residuals', alpha=0.5) 46 | plt.scatter(model.predict(X_test), test_residuals, label='Test Residuals', alpha=0.5) 47 | plt.axhline(y=0, color='r', linestyle='--') 48 | plt.xlabel('Predicted Values') 49 | plt.ylabel('Residuals') 50 | plt.title('Residual Plot') 51 | plt.legend() 52 | plt.show() 53 | -------------------------------------------------------------------------------- /Naga Sathvik Rapelli/Hard Tasks/Task 12/compressed_images/compressed_image.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CSEdgeOfficial/Python-Programming-Internship/b5be041a1aac3fb550b7bfad853a73a2d8535c7e/Naga Sathvik Rapelli/Hard Tasks/Task 12/compressed_images/compressed_image.jpg -------------------------------------------------------------------------------- /Naga Sathvik Rapelli/Hard Tasks/Task 12/task12.py: -------------------------------------------------------------------------------- 1 | from PIL import Image 2 | import os 3 | 4 | def compress_image(input_path, output_path, quality=60): 5 | """ 6 | Compresses an input image while maintaining quality. 7 | 8 | Parameters: 9 | input_path (str): Path to the input image file. 10 | output_path (str): Path to save the compressed image file. 11 | quality (int): Compression quality (0 - 95). Default is 60. 12 | 13 | Returns: 14 | None 15 | """ 16 | input_image = Image.open(input_path) 17 | 18 | if input_image.mode == 'RGBA': 19 | input_image = input_image.convert('RGB') 20 | 21 | compressed_image = input_image.copy() 22 | compressed_image.save(output_path, quality=quality) 23 | 24 | print(f"Compressed image saved at: {output_path}") 25 | 26 | def main(): 27 | input_path = 'C:/Users/SATHVIK/OneDrive/Desktop/Motive.png' 28 | output_folder = 'compressed_images' 29 | os.makedirs(output_folder, exist_ok=True) 30 | 31 | quality = 60 32 | 33 | # Compress image 34 | output_path = os.path.join(output_folder, 'compressed_image.jpg') 35 | compress_image(input_path, output_path, quality) 36 | 37 | if __name__ == "__main__": 38 | main() 39 | 40 | -------------------------------------------------------------------------------- /Naga Sathvik Rapelli/Hard Tasks/Task 9/output_images/Motive.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CSEdgeOfficial/Python-Programming-Internship/b5be041a1aac3fb550b7bfad853a73a2d8535c7e/Naga Sathvik Rapelli/Hard Tasks/Task 9/output_images/Motive.png -------------------------------------------------------------------------------- /Naga Sathvik Rapelli/Hard Tasks/Task 9/output_images/WhatsApp Image 2024-02-15 at 06.43.27_0a95261b.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CSEdgeOfficial/Python-Programming-Internship/b5be041a1aac3fb550b7bfad853a73a2d8535c7e/Naga Sathvik Rapelli/Hard Tasks/Task 9/output_images/WhatsApp Image 2024-02-15 at 06.43.27_0a95261b.png -------------------------------------------------------------------------------- /Naga Sathvik Rapelli/Hard Tasks/Task 9/task9.py: -------------------------------------------------------------------------------- 1 | from PIL import Image 2 | import os 3 | 4 | def convert_image(input_path, output_path, output_format): 5 | try: 6 | with Image.open(input_path) as img: 7 | img.save(output_path, format=output_format) 8 | print(f"Image converted successfully: {input_path} -> {output_path}") 9 | except Exception as e: 10 | print(f"Error converting image: {e}") 11 | 12 | def main(input_folder, output_folder, output_format): 13 | if not os.path.exists(output_folder): 14 | os.makedirs(output_folder) 15 | 16 | for filename in os.listdir(input_folder): 17 | input_path = os.path.join(input_folder, filename) 18 | 19 | if os.path.isfile(input_path) and any(filename.lower().endswith(ext) for ext in ['.jpg', '.jpeg', '.png', '.bmp', '.gif']): 20 | output_filename = os.path.splitext(filename)[0] + '.' + output_format.lower() 21 | output_path = os.path.join(output_folder, output_filename) 22 | 23 | convert_image(input_path, output_path, output_format) 24 | 25 | input_folder = 'C:/Users/SATHVIK/OneDrive/Desktop' 26 | output_folder = 'output_images' 27 | output_format = 'PNG' 28 | main(input_folder, output_folder, output_format) 29 | -------------------------------------------------------------------------------- /Naga Sathvik Rapelli/Task 5/task5.py: -------------------------------------------------------------------------------- 1 | from flask import Flask, render_template, request 2 | import requests 3 | 4 | app = Flask(__name__) 5 | 6 | api_key = "fe35e3bb6b21c465def7ea465e765f7f" 7 | 8 | def get_weather(city): 9 | url = f"http://api.openweathermap.org/data/2.5/weather?q={city}&appid={api_key}&units=metric" 10 | response = requests.get(url) 11 | data = response.json() 12 | return data 13 | 14 | 15 | @app.route('/', methods=['GET', 'POST']) 16 | def home(): 17 | if request.method == 'POST': 18 | city = request.form['city'] 19 | weather_data = get_weather(city) 20 | return render_template('index.html', show_weather=True, weather_data=weather_data) 21 | else: 22 | return render_template('index.html', show_weather=False) 23 | 24 | 25 | if __name__ == '__main__': 26 | app.run(debug=True) -------------------------------------------------------------------------------- /Naga Sathvik Rapelli/Task 5/templates/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Weather App 7 | 24 | 25 | 26 |
27 |

Weather App

28 |
29 | 30 | 31 | 32 |
33 | 34 | {% if show_weather %} 35 |

Weather Report for {{ weather_data['name'] }}

36 |

Temperature: {{ weather_data['main']['temp'] }}°C

37 |

Weather: {{ weather_data['weather'][0]['description'] }}

38 | {% endif %} 39 |
40 | 41 | 42 | -------------------------------------------------------------------------------- /Naga Sathvik Rapelli/Task 6/data.csv: -------------------------------------------------------------------------------- 1 | Title,Description 2 | HTML 5 Tutorial,HTML stands for HyperText Markup Language. It's the regular code used to make web pages. HTML has certain pre-made parts that help in building the structure and content of the webpage. 3 | JavaScript Tutorial,"JavaScript is a high-level, dynamic programming language commonly used for web development to create interactive and dynamic web pages." 4 | React JS Tutorial,"React is an open-source JavaScript library for building user interfaces, commonly used for creating interactive and dynamic web applications." 5 | Node JS Tutorial,"Node.js is free, server-side JavaScript runtime environment that allows coders to execute JavaScript code outside of a web browser.Node.js is a JavaScript runtime built on the V8 JavaScript engine." 6 | MongoDB Tutorial,"MongoDB is a popular open-source NoSQL (non-relational) database management system. It stores data in a flexible, semi-structured BSON format, which is similar to JSON." 7 | -------------------------------------------------------------------------------- /Naga Sathvik Rapelli/Task 6/task6.py: -------------------------------------------------------------------------------- 1 | import requests 2 | from bs4 import BeautifulSoup 3 | import csv 4 | 5 | def scrape_website(url, filename): 6 | response = requests.get(url) 7 | if response.status_code != 200: 8 | print(f"Failed to fetch {url}. Status code: {response.status_code}") 9 | return 10 | 11 | soup = BeautifulSoup(response.content, 'html.parser') 12 | 13 | data_list = [] 14 | for card in soup.find_all('div', class_='card'): 15 | title_element = card.find('div', class_='title').find('h3') 16 | description_element = card.find('div', class_='matter').find('p') 17 | if title_element and description_element: 18 | title = title_element.text.strip() 19 | description = description_element.text.strip() 20 | data_list.append([title, description]) 21 | else: 22 | print("Missing title or description in card") 23 | 24 | if not data_list: 25 | print("No data found on the page") 26 | return 27 | 28 | with open(filename, 'w', newline='', encoding='utf-8') as csvfile: 29 | writer = csv.writer(csvfile) 30 | writer.writerow(['Title', 'Description']) 31 | writer.writerows(data_list) 32 | 33 | print(f"Data scraped successfully and saved to {filename}") 34 | 35 | url = 'https://www.webstacknotes.com/' 36 | filename = 'data.csv' 37 | scrape_website(url, filename) 38 | -------------------------------------------------------------------------------- /Naga Sathvik Rapelli/Task 7/task7.py: -------------------------------------------------------------------------------- 1 | # Define responses based on user input 2 | responses = { 3 | "hi": "Hello! How can I help you?", 4 | "how are you?": "I'm doing well, thank you!", 5 | "bye": "Goodbye! Have a great day!", 6 | "how can I assist you?": "I'm here to help you with any questions or tasks you have.", 7 | "what's up?": "Not much, just here to chat and assist you.", 8 | "how's it going?": "It's going well! Thanks for asking.", 9 | "what's new?": "Not much, just ready to help you out.", 10 | "what can you do?": "I can answer questions, provide information, and assist with various tasks.", 11 | "tell me about yourself": "I'm a chatbot designed to assist you with your inquiries and tasks.", 12 | "who created you?": "I was created by a team of developers to assist users like you.", 13 | "where are you from?": "I exist in the digital realm to provide assistance to users like yourself.", 14 | "what's your favorite color?": "I don't have a favorite color, but I'm here to assist you with any questions you have.", 15 | "do you have any hobbies?": "As a chatbot, I don't have hobbies, but I'm here to assist you with your queries.", 16 | "are you a robot?": "Yes, I am a chatbot designed to assist you with your inquiries.", 17 | "are you human?": "No, I am an artificial intelligence programmed to assist users like yourself.", 18 | "what languages do you speak?": "I can communicate in various human languages to assist you.", 19 | "can you help me?": "Yes, I'm here to assist you with any questions or tasks you have.", 20 | "what's the meaning of life?": "That's a philosophical question! Many people have different interpretations of the meaning of life.", 21 | "do you dream?": "As a chatbot, I don't dream, but I'm here to help you with your questions.", 22 | "how do I use this?": "You can interact with me by typing your questions or commands, and I'll do my best to assist you.", 23 | "where can I find help?": "You can ask me questions, or you can seek assistance from human support if needed.", 24 | "can I trust you?": "Yes, you can trust me to provide accurate information and assistance to the best of my ability.", 25 | "are you intelligent?": "As an artificial intelligence, I'm designed to assist you by providing relevant information and assistance.", 26 | "what's the weather like?": "I can help you check the weather in your area if you provide me with your location.", 27 | "how do I contact support?": "You can usually find contact information for support on the website or app you're using.", 28 | "can you sing?": "I'm not programmed to sing, but I can assist you with your inquiries.", 29 | "do you have any siblings?": "As a chatbot, I don't have siblings, but I'm here to assist you with your questions.", 30 | "what's your favorite food?": "I don't eat, but I'm here to assist you with any questions you have.", 31 | "can you dance?": "I'm not programmed to dance, but I can assist you with your inquiries.", 32 | "what's your favorite movie?": "As a chatbot, I don't have preferences, but I'm here to assist you with your questions.", 33 | "what's your favorite book?": "I don't read, but I'm here to assist you with any questions you have.", 34 | "do you sleep?": "As an artificial intelligence, I don't require sleep, but I'm here to assist you at any time.", 35 | "what's your favorite song?": "I don't have preferences, but I'm here to assist you with your inquiries.", 36 | "can you tell jokes?": "I can try! Why did the computer go to the doctor? Because it had a virus!", 37 | "what's your favorite animal?": "I don't have preferences, but I'm here to assist you with your questions.", 38 | "what's the meaning of love?": "Love can mean different things to different people, but it often involves deep affection and care.", 39 | "what's your favorite sport?": "I don't have preferences, but I'm here to assist you with your inquiries.", 40 | "do you have a sense of humor?": "I can try to be funny! Why was the math book sad? Because it had too many problems!", 41 | "what's the meaning of happiness?": "Happiness is a positive emotional state characterized by feelings of joy, contentment, and satisfaction.", 42 | "can you tell stories?": "I can share information and anecdotes, but I'm not programmed to tell fictional stories.", 43 | "what's the meaning of success?": "Success can mean different things to different people, but it often involves achieving goals and fulfilling aspirations.", 44 | "what's your favorite place?": "As a chatbot, I don't have preferences, but I'm here to assist you with your questions.", 45 | "what's your favorite hobby?": "I don't have hobbies, but I'm here to assist you with your inquiries.", 46 | "can you help me with my homework?": "I can try! What subject are you working on?", 47 | "do you like to travel?": "I don't travel, but I'm here to assist you with your questions.", 48 | "what's the meaning of friendship?": "Friendship is a close and supportive relationship between two or more people.", 49 | "what's the meaning of kindness?": "Kindness is the quality of being friendly, generous, and considerate towards others.", 50 | "what's the meaning of courage?": "Courage is the ability to face challenges, difficulties, and fears with bravery and determination.", 51 | "what's the meaning of determination?": "Determination is the firmness of purpose and the resolve to achieve a goal despite obstacles or setbacks.", 52 | "what's the meaning of resilience?": "Resilience is the ability to adapt and recover from adversity, challenges, or difficult experiences.", 53 | "what's the meaning of empathy?": "Empathy is the ability to understand and share the feelings and perspectives of others.", 54 | "what's the meaning of compassion?": "Compassion is the feeling of deep sympathy and concern for the suffering or misfortune of others.", 55 | "what's the meaning of integrity?": "Integrity is the quality of being honest, ethical, and morally upright in one's thoughts, words, and actions.", 56 | "what's the meaning of gratitude?": "Gratitude is the feeling of thankfulness and appreciation for the kindness, support, or blessings received.", 57 | "what's the meaning of humility?": "Humility is the quality of being modest, humble, and respectful, without arrogance or pride.", 58 | "what's the meaning of patience?": "Patience is the ability to remain calm and composed in the face of delay, frustration, or difficulties.", 59 | "what's the meaning of perseverance?": "Perseverance is the steadfastness and persistence in pursuing goals or objectives despite obstacles or challenges.", 60 | "what's the meaning of forgiveness?": "Forgiveness is the act of letting go of resentment, anger, or bitterness towards someone who has wronged you.", 61 | 62 | } 63 | 64 | # Function to process user input and generate response 65 | def chatbot_response(input_text): 66 | input_text = input_text.lower() 67 | if input_text in responses: 68 | return responses[input_text] 69 | else: 70 | return "Sorry, I don't understand that." 71 | 72 | # Main loop to run the chatbot 73 | while True: 74 | user_input = input("You: ") 75 | response = chatbot_response(user_input) 76 | print("Bot:", response) 77 | -------------------------------------------------------------------------------- /Naga Sathvik Rapelli/Task 8/task8.py: -------------------------------------------------------------------------------- 1 | import PyPDF2 2 | import os 3 | 4 | def merge_pdfs(input_folder, output_path): 5 | pdf_merger = PyPDF2.PdfWriter() 6 | 7 | input_paths = [os.path.join(input_folder, filename) for filename in os.listdir(input_folder) if filename.endswith('.pdf')] 8 | 9 | for path in input_paths: 10 | pdf_reader = PyPDF2.PdfReader(path) 11 | for page_num in range(len(pdf_reader.pages)): 12 | page = pdf_reader.pages[page_num] 13 | pdf_merger.add_page(page) 14 | 15 | with open(output_path, 'wb') as output_pdf: 16 | pdf_merger.write(output_pdf) 17 | 18 | input_folder = 'C:/Users/SATHVIK/OneDrive/Desktop/DESKTOP/APP_POINTS' 19 | output_path = 'C:/Users/SATHVIK/OneDrive/Desktop/merged_pdf.pdf' 20 | 21 | merge_pdfs(input_folder, output_path) 22 | print("PDF files merged successfully and saved as 'merged_pdf.pdf' on your desktop.") 23 | -------------------------------------------------------------------------------- /Naga Sathvik Rapelli/Task1/simple_calculator.py: -------------------------------------------------------------------------------- 1 | # Addition Function 2 | def add(num1, num2): 3 | return num1 + num2 4 | 5 | # Subtraction Function 6 | def subtraction(num1, num2): 7 | return num1 - num2 8 | 9 | # Multiplication Function 10 | def multiply(num1, num2): 11 | return num1 * num2 12 | 13 | # Division Function 14 | def divide(num1, num2): 15 | if num2 == 0: 16 | return "Error: Cannot divide by zero!" 17 | return num1 / num2 18 | 19 | # Basic displaying function... 20 | def calculator(): 21 | print("Welcome to Simple Calculator!") 22 | print("1. Addition") 23 | print("2. Subtraction") 24 | print("3. Multiplication") 25 | print("4. Division") 26 | print("5. Exit") 27 | 28 | while True: 29 | choice = input("Enter your choice (1/2/3/4/5): ") 30 | 31 | if choice in ('1', '2', '3', '4'): 32 | num1 = float(input("Enter first number: ")) 33 | num2 = float(input("Enter second number: ")) 34 | 35 | if choice == '1': 36 | print("Result:", add(num1, num2)) 37 | elif choice == '2': 38 | print("Result:", subtraction(num1, num2)) 39 | elif choice == '3': 40 | print("Result:", multiply(num1, num2)) 41 | elif choice == '4': 42 | print("Result:", divide(num1, num2)) 43 | elif choice == '5': 44 | print("Thnaks for using my Calculator, Use it again!!!") 45 | break 46 | else: 47 | print("Invalid input. Please enter a valid choice.") 48 | 49 | # Main 50 | def main(): 51 | calculator() 52 | 53 | # Program entrance 54 | if __name__ == "__main__": 55 | main() 56 | -------------------------------------------------------------------------------- /Naga Sathvik Rapelli/Task2/ToDoList.py: -------------------------------------------------------------------------------- 1 | class ToDoList: 2 | def __init__(self): 3 | self.tasks = [] 4 | 5 | def add_task(self, task): 6 | self.tasks.append(task) 7 | print("Task added successfully!") 8 | 9 | def delete_task(self, index): 10 | if index < len(self.tasks): 11 | del self.tasks[index] 12 | print("Task deleted successfully!") 13 | else: 14 | print("Invalid task index.") 15 | 16 | def mark_completed(self, index): 17 | if index < len(self.tasks): 18 | self.tasks[index] += " - Completed" 19 | print("Task marked as completed!") 20 | else: 21 | print("Invalid task index.") 22 | 23 | def display_tasks(self): 24 | if self.tasks: 25 | print("Tasks:") 26 | for i, task in enumerate(self.tasks): 27 | print(f"{i+1}. {task}") 28 | else: 29 | print("No tasks.") 30 | 31 | def main(): 32 | todo_list = ToDoList() 33 | 34 | while True: 35 | print("\nTODO LIST") 36 | print("1. Add Task") 37 | print("2. Delete Task") 38 | print("3. Mark Task as Completed") 39 | print("4. Display Tasks") 40 | print("5. Exit") 41 | 42 | choice = input("Enter your choice (1/2/3/4/5): ") 43 | 44 | if choice == '1': 45 | task = input("Enter task: ") 46 | todo_list.add_task(task) 47 | elif choice == '2': 48 | index = int(input("Enter task index to delete: ")) - 1 49 | todo_list.delete_task(index) 50 | elif choice == '3': 51 | index = int(input("Enter task index to mark as completed: ")) - 1 52 | todo_list.mark_completed(index) 53 | elif choice == '4': 54 | todo_list.display_tasks() 55 | elif choice == '5': 56 | print("Exiting. Goodbye!") 57 | break 58 | else: 59 | print("Invalid choice. Please enter a valid option.") 60 | 61 | if __name__ == "__main__": 62 | main() 63 | -------------------------------------------------------------------------------- /Naga Sathvik Rapelli/Task2/ToDoListGUI.py: -------------------------------------------------------------------------------- 1 | import tkinter as tk 2 | from tkinter import messagebox 3 | 4 | class ToDoListGUI: 5 | def __init__(self, master): 6 | self.master = master 7 | self.master.title("To-Do List") 8 | 9 | self.tasks = [] 10 | 11 | self.task_entry = tk.Entry(master, width=50) 12 | self.task_entry.grid(row=0, column=0, padx=10, pady=10) 13 | 14 | self.add_button = tk.Button(master, text="Add Task", command=self.add_task) 15 | self.add_button.grid(row=0, column=1, padx=5, pady=10) 16 | 17 | self.delete_button = tk.Button(master, text="Delete Task", command=self.delete_task) 18 | self.delete_button.grid(row=1, column=1, padx=5, pady=10) 19 | 20 | self.complete_button = tk.Button(master, text="Mark as Completed", command=self.mark_completed) 21 | self.complete_button.grid(row=2, column=1, padx=5, pady=10) 22 | 23 | self.task_listbox = tk.Listbox(master, width=50, height=10) 24 | self.task_listbox.grid(row=1, column=0, padx=10, pady=10, rowspan=2) 25 | 26 | def add_task(self): 27 | task = self.task_entry.get() 28 | if task: 29 | self.tasks.append(task) 30 | self.task_listbox.insert(tk.END, task) 31 | self.task_entry.delete(0, tk.END) 32 | else: 33 | messagebox.showwarning("Warning", "Please enter a task.") 34 | 35 | def delete_task(self): 36 | selected_index = self.task_listbox.curselection() 37 | if selected_index: 38 | index = selected_index[0] 39 | del self.tasks[index] 40 | self.task_listbox.delete(index) 41 | else: 42 | messagebox.showwarning("Warning", "Please select a task to delete.") 43 | 44 | def mark_completed(self): 45 | selected_index = self.task_listbox.curselection() 46 | if selected_index: 47 | index = selected_index[0] 48 | self.tasks[index] += " - Completed" 49 | self.task_listbox.delete(index) 50 | self.task_listbox.insert(tk.END, self.tasks[index]) 51 | else: 52 | messagebox.showwarning("Warning", "Please select a task to mark as completed.") 53 | 54 | def main(): 55 | root = tk.Tk() 56 | todo_app = ToDoListGUI(root) 57 | root.mainloop() 58 | 59 | if __name__ == "__main__": 60 | main() 61 | -------------------------------------------------------------------------------- /Naga Sathvik Rapelli/Task3/Number_guessing_game.py: -------------------------------------------------------------------------------- 1 | import random 2 | 3 | def number_guessing_game(): 4 | # Generate a random number between 1 and 100 5 | secret_number = random.randint(1, 50) 6 | attempts = 0 7 | max_attempts = 10 8 | 9 | print("Welcome to the Number Guessing Game!") 10 | print(f"Guess the secret number between 1 and 50. You have {max_attempts} attempts.") 11 | 12 | while attempts < max_attempts: 13 | try: 14 | guess = int(input("Enter your guess: ")) 15 | attempts += 1 16 | 17 | if guess == secret_number: 18 | print(f"Congratulations! You've guessed the secret number {secret_number} in {attempts} attempts!") 19 | break 20 | elif guess < secret_number: 21 | print("Too low! Try a higher number.") 22 | else: 23 | print("Too high! Try a lower number.") 24 | 25 | except ValueError: 26 | print("Invalid input. Please enter a valid number.") 27 | 28 | else: 29 | print(f"Sorry, you've used all your attempts. The secret number was {secret_number}.") 30 | 31 | def main(): 32 | number_guessing_game() 33 | 34 | if __name__ == "__main__": 35 | main() 36 | -------------------------------------------------------------------------------- /Naga Sathvik Rapelli/Task4/PDF_converter.py: -------------------------------------------------------------------------------- 1 | import PyPDF2 2 | import fitz 3 | import os 4 | 5 | def pdf_to_text(pdf_file, output_folder): 6 | # Open the PDF file 7 | with open(pdf_file, 'rb') as file: 8 | pdf_reader = PyPDF2.PdfFileReader(file) 9 | 10 | # Create output folder if it doesn't exist 11 | if not os.path.exists(output_folder): 12 | os.makedirs(output_folder) 13 | 14 | # Extract text from each page 15 | for page_num in range(pdf_reader.numPages): 16 | page = pdf_reader.getPage(page_num) 17 | text = page.extractText() 18 | 19 | # Write extracted text to a text file 20 | text_file_path = os.path.join(output_folder, f"page_{page_num + 1}.txt") 21 | with open(text_file_path, 'w') as text_file: 22 | text_file.write(text) 23 | 24 | print("Text extraction completed. Text files saved in:", output_folder) 25 | 26 | def pdf_to_images(pdf_file, output_folder): 27 | # Open the PDF file 28 | pdf_document = fitz.open(pdf_file) 29 | 30 | # Create output folder if it doesn't exist 31 | if not os.path.exists(output_folder): 32 | os.makedirs(output_folder) 33 | 34 | # Iterate through each page and save as image 35 | for page_num in range(len(pdf_document)): 36 | page = pdf_document[page_num] 37 | image_path = os.path.join(output_folder, f"page_{page_num + 1}.png") 38 | pix = page.get_pixmap() 39 | pix.writePNG(image_path) 40 | 41 | print("Image conversion completed. Images saved in:", output_folder) 42 | 43 | def main(): 44 | pdf_file = 'sample.pdf' # Change this to the path of your PDF file 45 | output_folder = 'output' # Output folder where converted files will be saved 46 | 47 | # Convert PDF to text 48 | pdf_to_text(pdf_file, output_folder) 49 | 50 | # Convert PDF to images 51 | pdf_to_images(pdf_file, output_folder) 52 | 53 | if __name__ == "__main__": 54 | main() 55 | 56 | -------------------------------------------------------------------------------- /Naga Tejaswini Nandyala/Task1: -------------------------------------------------------------------------------- 1 | from PIL import Image 2 | import os 3 | 4 | def convert_image(input_path, output_path, output_format): 5 | try: 6 | # Open the image 7 | with Image.open(input_path) as img: 8 | # Convert and save the image to the desired format 9 | img.save(output_path, format=output_format) 10 | print(f"Image converted successfully to {output_format} format.") 11 | except Exception as e: 12 | print(f"An error occurred: {e}") 13 | 14 | def main(): 15 | input_path = input("Enter the path to the input image: ") 16 | output_format = input("Enter the desired output format (e.g., JPEG, PNG, BMP, GIF): ").upper() 17 | 18 | # Validate output format 19 | if output_format not in ['JPEG', 'PNG', 'BMP', 'GIF']: 20 | print("Invalid output format. Please choose from JPEG, PNG, BMP, or GIF.") 21 | return 22 | 23 | # Extract the file name and extension 24 | file_name, file_extension = os.path.splitext(input_path) 25 | 26 | # If the input file already has an extension, remove it 27 | file_name_without_ext = file_name.split('.')[0] 28 | 29 | # Set the output path 30 | output_path = f"{file_name_without_ext}_converted.{output_format.lower()}" 31 | 32 | # Convert the image 33 | convert_image(input_path, output_path, output_format) 34 | 35 | if __name__ == "__main__": 36 |     main() 37 | -------------------------------------------------------------------------------- /Naga Tejaswini Nandyala/Task2: -------------------------------------------------------------------------------- 1 | import seaborn as sns 2 | import pandas as pd 3 | import matplotlib.pyplot as plt 4 | 5 | # Load the Iris dataset from Seaborn 6 | iris = sns.load_dataset("iris") 7 | numeric_iris = iris.drop(columns='species') 8 | 9 | # Display the first few rows of the dataset 10 | print("First few rows of the dataset:") 11 | print(iris.head()) 12 | 13 | # Summary statistics 14 | print("\nSummary statistics:") 15 | print(iris.describe()) 16 | 17 | # Checking for missing values 18 | print("\nMissing values:") 19 | print(iris.isnull().sum()) 20 | 21 | # Visualizations 22 | # Pairplot 23 | sns.pairplot(iris, hue="species") 24 | plt.title("Pairplot of Iris Dataset") 25 | plt.show() 26 | 27 | # Boxplot 28 | plt.figure(figsize=(10, 6)) 29 | sns.boxplot(data=iris, orient="h") 30 | plt.title("Boxplot of Iris Dataset") 31 | plt.show() 32 | 33 | # Histograms 34 | plt.figure(figsize=(10, 6)) 35 | iris.hist() 36 | plt.suptitle("Histograms of Iris Dataset") 37 | plt.show() 38 | 39 | # Correlation heatmap 40 | plt.figure(figsize=(8, 6)) 41 | sns.heatmap(numeric_iris.corr(), annot=True, cmap="coolwarm") 42 | plt.title("Correlation Heatmap of Iris Dataset") 43 | plt.show() 44 | -------------------------------------------------------------------------------- /Naga Tejaswini Nandyala/Task3: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import matplotlib.pyplot as plt 3 | from sklearn.model_selection import train_test_split 4 | from sklearn.linear_model import LinearRegression 5 | from sklearn.metrics import mean_squared_error 6 | import pandas as pd 7 | data_url = "http://lib.stat.cmu.edu/datasets/boston" 8 | raw_df = pd.read_csv(data_url, sep="\s+", skiprows=22, header=None) 9 | data = np.hstack([raw_df.values[::2, :], raw_df.values[1::2, :2]]) 10 | target = raw_df.values[1::2, 2] 11 | 12 | # Load the Boston housing dataset 13 | 14 | X = data 15 | y = target 16 | 17 | # Split the data into training and testing sets 18 | X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42) 19 | 20 | # Initialize the linear regression model 21 | model = LinearRegression() 22 | 23 | # Fit the model on the training data 24 | model.fit(X_train, y_train) 25 | 26 | # Predict on the training and testing data 27 | y_train_pred = model.predict(X_train) 28 | y_test_pred = model.predict(X_test) 29 | 30 | # Calculate the scores 31 | train_score = model.score(X_train, y_train) 32 | test_score = model.score(X_test, y_test) 33 | 34 | print("Training score:", train_score) 35 | print("Testing score:", test_score) 36 | 37 | # Plot residuals 38 | plt.scatter(y_train_pred, y_train_pred - y_train, c='blue', marker='o', label='Training data') 39 | plt.scatter(y_test_pred, y_test_pred - y_test, c='lightgreen', marker='s', label='Testing data') 40 | plt.xlabel('Predicted values') 41 | plt.ylabel('Residuals') 42 | plt.legend(loc='upper left') 43 | plt.hlines(y=0, xmin=0, xmax=50, lw=2, color='red') 44 | plt.title('Residual plot') 45 | plt.show() 46 | -------------------------------------------------------------------------------- /Naga Tejaswini Nandyala/Task4: -------------------------------------------------------------------------------- 1 | from PIL import Image 2 | import os 3 | 4 | def get_size_format(b, factor=1024, suffix="B"): 5 | """ 6 | Scale bytes to its proper byte format. 7 | e.g: 1253656 => '1.20MB', 1253656678 => '1.17GB' 8 | """ 9 | for unit in ["", "K", "M", "G", "T", "P", "E", "Z"]: 10 | if b < factor: 11 | return f"{b:.2f}{unit}{suffix}" 12 | b /= factor 13 | return f"{b:.2f}Y{suffix}" 14 | 15 | def compress_img(image_name, new_size_ratio=0.9, quality=90, width=None, height=None, to_jpg=True): 16 | # Load the image into memory 17 | img = Image.open(image_name) 18 | 19 | # Print the original image shape 20 | print("[*] Image shape:", img.size) 21 | 22 | # Get the original image size in bytes 23 | image_size = os.path.getsize(image_name) 24 | print("[*] Size before compression:", get_size_format(image_size)) 25 | 26 | if new_size_ratio < 1.0: 27 | # If resizing ratio is below 1.0, multiply width & height with this ratio to reduce image size 28 | img = img.resize((int(img.size[0] * new_size_ratio), int(img.size[1] * new_size_ratio)), Image.ANTIALIAS) 29 | elif width and height: 30 | # If width and height are set, resize with them instead 31 | img = img.resize((width, height), Image.ANTIALIAS) 32 | 33 | # Split the filename and extension 34 | filename, ext = os.path.splitext(image_name) 35 | 36 | # Make a new filename appending "_compressed" to the original file name 37 | if to_jpg: 38 | # Change the extension to JPEG 39 | new_filename = f"{filename}_compressed.jpg" 40 | else: 41 | # Retain the same extension of the original image 42 | new_filename = f"{filename}_compressed{ext}" 43 | 44 | # Save the compressed image 45 | img.save(new_filename, optimize=True, quality=quality) 46 | 47 | # Print the new image shape 48 | print("[+] New Image shape:", img.size) 49 | print(f"[*] Compressed image saved as: {new_filename}") 50 | 51 | # Example usage: 52 | compress_img("wp1966999.jpg", new_size_ratio=0.8, quality=80, width=800, height=600) 53 | -------------------------------------------------------------------------------- /R.LOKESH/task5/weatherapp.py: -------------------------------------------------------------------------------- 1 | import requests 2 | import json 3 | 4 | def fetch_weather_data(api_key, city): 5 | url = f"http://api.openweathermap.org/data/2.5/weather?q={city}&appid={api_key}&units=metric" 6 | response = requests.get(url) 7 | data = response.json() 8 | return data 9 | 10 | def display_weather(data): 11 | print("Current Weather Conditions:") 12 | print("---------------------------") 13 | print(f"Weather: {data['weather'][0]['description']}") 14 | print(f"Temperature: {data['main']['temp']}°C") 15 | print(f"Humidity: {data['main']['humidity']}%") 16 | print(f"Wind Speed: {data['wind']['speed']} m/s") 17 | 18 | def main(): 19 | api_key = "YOUR_API_KEY" 20 | city = input("Enter city name: ") 21 | weather_data = fetch_weather_data(api_key, city) 22 | if weather_data['cod'] == 200: 23 | display_weather(weather_data) 24 | else: 25 | print("Error fetching weather data. Please check your input.") 26 | 27 | if __name__ == "__main__": 28 | main() 29 | -------------------------------------------------------------------------------- /R.LOKESH/task6/webscrapper.py: -------------------------------------------------------------------------------- 1 | import requests 2 | from bs4 import BeautifulSoup 3 | import csv 4 | 5 | def scrape_website(url): 6 | # Send a GET request to the URL 7 | response = requests.get(url) 8 | 9 | # Check if request was successful (status code 200) 10 | if response.status_code == 200: 11 | # Parse the HTML content of the page 12 | soup = BeautifulSoup(response.text, 'html.parser') 13 | 14 | # Find the elements containing the data you want to extract 15 | # Replace 'example' with actual HTML tags and classes/IDs 16 | data_elements = soup.find_all('div', class_='example') 17 | 18 | # Extract data from the elements and store in a list of dictionaries 19 | scraped_data = [] 20 | for element in data_elements: 21 | # Example: Extract text from a specific tag within the element 22 | data = { 23 | 'title': element.find('h2').text.strip(), 24 | 'description': element.find('p').text.strip() 25 | } 26 | scraped_data.append(data) 27 | 28 | return scraped_data 29 | else: 30 | print("Error: Failed to fetch website") 31 | return [] 32 | 33 | def save_to_csv(data, filename): 34 | # Define CSV header based on keys of the first dictionary in the list 35 | fields = list(data[0].keys()) 36 | 37 | # Write data to CSV file 38 | with open(filename, 'w', newline='') as csvfile: 39 | writer = csv.DictWriter(csvfile, fieldnames=fields) 40 | 41 | # Write header 42 | writer.writeheader() 43 | 44 | # Write rows 45 | for row in data: 46 | writer.writerow(row) 47 | 48 | def main(): 49 | url = "https://example.com" 50 | filename = "data.csv" 51 | 52 | # Scrape website 53 | scraped_data = scrape_website(url) 54 | 55 | # Save data to CSV 56 | save_to_csv(scraped_data, filename) 57 | 58 | print(f"Data has been scraped and saved to {filename}") 59 | 60 | if __name__ == "__main__": 61 | main() 62 | -------------------------------------------------------------------------------- /R.LOKESH/task7/chatbot.py: -------------------------------------------------------------------------------- 1 | import nltk 2 | from nltk.chat.util import Chat, reflections 3 | 4 | # Define pairs of patterns and responses 5 | pairs = [ 6 | (r"hi|hello|hey", ["Hello!", "Hi there!", "Hey!"]), 7 | (r"how are you?", ["I'm doing well, thank you!", "I'm good, thanks for asking."]), 8 | (r"what is your name?", ["My name is Chatbot.", "I'm Chatbot, nice to meet you!"]), 9 | (r"bye|goodbye", ["Goodbye!", "See you later!", "Bye!"]), 10 | (r"(.*)", ["I'm sorry, I don't understand."]) 11 | ] 12 | 13 | # Create a chatbot using the defined pairs 14 | chatbot = Chat(pairs, reflections) 15 | 16 | # Start the conversation loop 17 | print("Chatbot: Hello! I'm Chatbot. How can I help you today?") 18 | while True: 19 | user_input = input("You: ") 20 | response = chatbot.respond(user_input) 21 | print("Chatbot:", response) 22 | -------------------------------------------------------------------------------- /R.LOKESH/task8/pdfmerger.py: -------------------------------------------------------------------------------- 1 | import PyPDF2 2 | 3 | def merge_pdfs(input_files, output_file): 4 | merger = PyPDF2.PdfFileMerger() 5 | for input_file in input_files: 6 | merger.append(input_file) 7 | merger.write(output_file) 8 | merger.close() 9 | print(f"PDF files merged successfully into {output_file}") 10 | 11 | def split_pdf(input_file, output_prefix): 12 | input_pdf = PyPDF2.PdfFileReader(input_file) 13 | for page_number in range(input_pdf.numPages): 14 | output_pdf = PyPDF2.PdfFileWriter() 15 | output_pdf.addPage(input_pdf.getPage(page_number)) 16 | output_filename = f"{output_prefix}_{page_number + 1}.pdf" 17 | with open(output_filename, "wb") as output_file: 18 | output_pdf.write(output_file) 19 | print(f"Page {page_number + 1} split into {output_filename}") 20 | 21 | def main(): 22 | # Merge PDF files 23 | input_files = ["input1.pdf", "input2.pdf", "input3.pdf"] 24 | merge_output_file = "merged_output.pdf" 25 | merge_pdfs(input_files, merge_output_file) 26 | 27 | # Split PDF file 28 | input_file = "input.pdf" 29 | split_output_prefix = "split_output" 30 | split_pdf(input_file, split_output_prefix) 31 | 32 | if __name__ == "__main__": 33 | main() 34 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Python Programming Internship 2 | ============================== 3 | 4 | Title: Python Programming Internship Tasks
5 | Subtitle: CSEdge Internship Program
6 | Author: Team CSEdge
7 | Level: Easy, Medium, Hard
8 | Questions per Level: 4
a 9 | Total Questions: 12
10 | 11 | ### Setup 12 | 13 | To get started with the projects, follow these steps: 14 | 15 | 1. Clone the repository to your local machine using the command: 16 | ```bash 17 | git clone https://github.com/CSEdgeOfficial/Python-Programming-Internship 18 | ``` 19 | 2. Navigate to the cloned directory: 20 | ```bash 21 | cd Python-Programming-Internship 22 | ``` 23 | 3. Create a new folder with your full name to store your projects: 24 | ```bash 25 | mkdir YourFullName && cd YourFullName 26 | ``` 27 | 4. Begin working on the tasks within your named folder. 28 | 29 | ### Pull Request 30 | 31 | After finishing a task, create a separate folder inside your named folder for that particular task and submit a pull request to the `master` branch of this repository. Our team will review your submission and merge it if approved. 32 | 33 | Table of Contents 34 | ----------------- 35 | 36 | Intro
37 | easy-level
38 | medium-level
39 | hard-level
40 | conclusion
41 | 42 | 43 | 44 | Introduction 45 | ------------ 46 | 47 | Welcome to the Python Programming Internship with CSEdge! During this journey, you'll tackle various tasks aimed at expanding your knowledge and expertise in Python programming. This document presents 12 tasks divided into three categories—Easy, Medium, and Hard. 48 | 49 | Instructions 50 | ------------ 51 | 52 | - Attempt the tasks according to their difficulty level, beginning with the easiest ones. 53 | - Focus on solving only one category—Easy, Medium, or Hard—for now. 54 | - Write functions, classes, modules, tests, and documentation where required. 55 | - Keep your code organized, modular, and easy to read. 56 | - Comment your solutions thoroughly, explaining how they work and why you made certain decisions. 57 | - Save your finished work in appropriately labeled folders under your named folder. 58 | - Send the entire collection of source codes, along with necessary instructions, to your designated mentor via a share link on GitHub. 59 | 60 | Evaluation Criteria 61 | ------------------- 62 | 63 | - Correctness of implemented algorithms and logic 64 | - Quality of code (structure, comments, naming conventions, etc.) 65 | - Performance and optimization efforts 66 | - Efficient use of external libraries when needed 67 | - Problem-solving creativity and originality 68 | 69 | Now let's dive into the tasks! 70 | 71 | 72 | 73 | **Beginner Level:** 74 | 75 | 1. Simple Calculator: 76 | - Create a basic calculator application that performs arithmetic operations like addition, subtraction, multiplication, and division. 77 | 78 | 2. To-Do List: 79 | - Develop a console-based or GUI application for managing tasks with features like adding, deleting, and marking tasks as completed. 80 | 81 | 3. Number Guessing Game: 82 | - Implement a program where the computer generates a random number and the player tries to guess it within a certain number of attempts. 83 | 84 | 4. PDF Converter: 85 | - Build a tool that converts PDF files into different formats such as text, images, or other document types. 86 | 87 | 88 | 89 | **Intermediate Level:** 90 | 91 | 5. Weather App: 92 | - Create a program that fetches weather data from an API and displays current weather conditions, forecasts, and temperature trends. 93 | 94 | 6. Web Scraper: 95 | - Develop a tool to extract data from websites by scraping HTML content and storing it in a structured format like CSV or JSON. 96 | 97 | 7. Chatbot: 98 | - Build a simple chatbot using natural language processing techniques to respond to user queries and provide relevant information. 99 | 100 | 8. PDF Merger/Splitter: 101 | - Write a program that merges multiple PDF files into one or splits a PDF file into multiple smaller files. 102 | 103 | 104 | 105 | 106 | **Advanced Level:** 107 | 108 | 9. Image Converter: 109 | - Write a program that accepts images in multiple formats (JPEG, PNG, BMP, GIF) and converts them into a desired format using Python Imaging Library (PIL). 110 | 111 | 10. Data Analysis with Pandas: 112 | - Load the "Iris" dataset from Seaborn and analyze it using Pandas. Perform exploratory data analysis, cleaning, aggregation, visualizations, and correlation calculations. 113 | 114 | 11. Linear Regression with Scikit-learn: 115 | - Apply linear regression to predict house prices from the Boston housing dataset using scikit-learn. Compare train and test scores and plot residuals. 116 | 117 | 12. Image Compression: 118 | - Develop a Python tool for compressing images while maintaining quality. Explore compression techniques like RLE and DCT. Allow users to adjust compression quality, support various image formats, and provide output options. Optionally, include a user interface. Ensure code modularity, performance optimization, and test with diverse images, along with comprehensive documentation. 119 | 120 | # Our Contributors ✨ 121 | 122 | 123 | 124 | 125 | 126 | 127 | FAQ 128 | --- 129 | 130 | ### How can I overcome obstacles faced during tasks in my named folder? 131 | 132 | Should you encounter issues during tasks within your named folder, don't hesitate to raise concerns in the repository's Issue Tab by opening an issue ticket. Our team will swiftly attend to your needs. 133 | 134 | ### Can I utilize other resources to better comprehend these tasks? 135 | 136 | Yes, indeed! Look up authoritative references such as the official documentation and reliable tutorials on sites like YouTube, FreeCodeCamp, Udemy, or Coursera. Moreover, delve into stack overflow discussions addressing typical challenges developers confront. 137 | 138 | ### Must I strictly abide by deadlines for tasks residing within my named folder? 139 | 140 | While firm deadlines aren't imposed, consistent progression through tasks helps optimally absorb concepts and harness acquired skills effectively. By keeping pace, you ensure steady advancement over the internship duration. 141 | 142 | ### Finishing Up 143 | 144 | By actively engaging in these tasks and arranging outcomes within your named folder, you fortify indispensable abilities pivotal to triumph in genuine software engineering scenarios. Have fun, and excel in your coding venture! 145 | -------------------------------------------------------------------------------- /Sai Bharadwaj/Task 2: -------------------------------------------------------------------------------- 1 | from PIL import Image 2 | import os 3 | 4 | def get_size_format(b, factor=1024, suffix="B"): 5 | """ 6 | Scale bytes to its proper byte format. 7 | e.g: 1253656 => '1.20MB', 1253656678 => '1.17GB' 8 | """ 9 | for unit in ["", "K", "M", "G", "T", "P", "E", "Z"]: 10 | if b < factor: 11 | return f"{b:.2f}{unit}{suffix}" 12 | b /= factor 13 | return f"{b:.2f}Y{suffix}" 14 | 15 | def compress_img(image_name, new_size_ratio=0.9, quality=90, width=None, height=None, to_jpg=True): 16 | # Load the image into memory 17 | img = Image.open(image_name) 18 | 19 | # Print the original image shape 20 | print("[*] Image shape:", img.size) 21 | 22 | # Get the original image size in bytes 23 | image_size = os.path.getsize(image_name) 24 | print("[*] Size before compression:", get_size_format(image_size)) 25 | 26 | if new_size_ratio < 1.0: 27 | # If resizing ratio is below 1.0, multiply width & height with this ratio to reduce image size 28 | img = img.resize((int(img.size[0] * new_size_ratio), int(img.size[1] * new_size_ratio)), Image.ANTIALIAS) 29 | elif width and height: 30 | # If width and height are set, resize with them instead 31 | img = img.resize((width, height), Image.ANTIALIAS) 32 | 33 | # Split the filename and extension 34 | filename, ext = os.path.splitext(image_name) 35 | 36 | # Make a new filename appending "_compressed" to the original file name 37 | if to_jpg: 38 | # Change the extension to JPEG 39 | new_filename = f"{filename}_compressed.jpg" 40 | else: 41 | # Retain the same extension of the original image 42 | new_filename = f"{filename}_compressed{ext}" 43 | 44 | # Save the compressed image 45 | img.save(new_filename, optimize=True, quality=quality) 46 | 47 | # Print the new image shape 48 | print("[+] New Image shape:", img.size) 49 | print(f"[*] Compressed image saved as: {new_filename}") 50 | 51 | # Example usage: 52 | compress_img("wp1966881.jpg", new_size_ratio=0.8, quality=80, width=800, height=600) 53 | -------------------------------------------------------------------------------- /Sai Bharadwaj/Task 3: -------------------------------------------------------------------------------- 1 | import seaborn as sns 2 | import pandas as pd 3 | import matplotlib.pyplot as plt 4 | 5 | # Load the Iris dataset from Seaborn 6 | iris = sns.load_dataset("iris") 7 | numeric_iris = iris.drop(columns='species') 8 | 9 | # Display the first few rows of the dataset 10 | print("First few rows of the dataset:") 11 | print(iris.head()) 12 | 13 | # Summary statistics 14 | print("\nSummary statistics:") 15 | print(iris.describe()) 16 | 17 | # Checking for missing values 18 | print("\nMissing values:") 19 | print(iris.isnull().sum()) 20 | 21 | # Visualizations 22 | # Pairplot 23 | sns.pairplot(iris, hue="species") 24 | plt.title("Pairplot of Iris Dataset") 25 | plt.show() 26 | 27 | # Boxplot 28 | plt.figure(figsize=(10, 6)) 29 | sns.boxplot(data=iris, orient="h") 30 | plt.title("Boxplot of Iris Dataset") 31 | plt.show() 32 | 33 | # Histograms 34 | plt.figure(figsize=(10, 6)) 35 | iris.hist() 36 | plt.suptitle("Histograms of Iris Dataset") 37 | plt.show() 38 | 39 | # Correlation heatmap 40 | plt.figure(figsize=(8, 6)) 41 | sns.heatmap(numeric_iris.corr(), annot=True, cmap="coolwarm") 42 | plt.title("Correlation Heatmap of Iris Dataset") 43 | plt.show() 44 | -------------------------------------------------------------------------------- /Sai Bharadwaj/Task 4: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import matplotlib.pyplot as plt 3 | from sklearn.model_selection import train_test_split 4 | from sklearn.linear_model import LinearRegression 5 | from sklearn.metrics import mean_squared_error 6 | import pandas as pd 7 | data_url = "http://lib.stat.cmu.edu/datasets/boston" 8 | raw_df = pd.read_csv(data_url, sep="\s+", skiprows=22, header=None) 9 | data = np.hstack([raw_df.values[::2, :], raw_df.values[1::2, :2]]) 10 | target = raw_df.values[1::2, 2] 11 | 12 | # Load the Boston housing dataset 13 | 14 | X = data 15 | y = target 16 | 17 | # Split the data into training and testing sets 18 | X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42) 19 | 20 | # Initialize the linear regression model 21 | model = LinearRegression() 22 | 23 | # Fit the model on the training data 24 | model.fit(X_train, y_train) 25 | 26 | # Predict on the training and testing data 27 | y_train_pred = model.predict(X_train) 28 | y_test_pred = model.predict(X_test) 29 | 30 | # Calculate the scores 31 | train_score = model.score(X_train, y_train) 32 | test_score = model.score(X_test, y_test) 33 | 34 | print("Training score:", train_score) 35 | print("Testing score:", test_score) 36 | 37 | # Plot residuals 38 | plt.scatter(y_train_pred, y_train_pred - y_train, c='blue', marker='o', label='Training data') 39 | plt.scatter(y_test_pred, y_test_pred - y_test, c='lightgreen', marker='s', label='Testing data') 40 | plt.xlabel('Predicted values') 41 | plt.ylabel('Residuals') 42 | plt.legend(loc='upper left') 43 | plt.hlines(y=0, xmin=0, xmax=50, lw=2, color='red') 44 | plt.title('Residual plot') 45 | plt.show() 46 | -------------------------------------------------------------------------------- /Sai Bharadwaj/task 1: -------------------------------------------------------------------------------- 1 | 2 | from PIL import Image 3 | import os 4 | 5 | def convert_image(input_path, output_path, output_format): 6 | try: 7 | # Open the image 8 | with Image.open(input_path) as img: 9 | # Convert and save the image to the desired format 10 | img.save(output_path, format=output_format) 11 | print(f"Image converted successfully to {output_format} format.") 12 | except Exception as e: 13 | print(f"An error occurred: {e}") 14 | 15 | def main(): 16 | input_path = input("Enter the path to the input image: ") 17 | output_format = input("Enter the desired output format (e.g., JPEG, PNG, BMP, GIF): ").upper() 18 | 19 | # Validate output format 20 | if output_format not in ['JPEG', 'PNG', 'BMP', 'GIF']: 21 | print("Invalid output format. Please choose from JPEG, PNG, BMP, or GIF.") 22 | return 23 | 24 | # Extract the file name and extension 25 | file_name, file_extension = os.path.splitext(input_path) 26 | 27 | # If the input file already has an extension, remove it 28 | file_name_without_ext = file_name.split('.')[0] 29 | 30 | # Set the output path 31 | output_path = f"{file_name_without_ext}_converted.{output_format.lower()}" 32 | 33 | # Convert the image 34 | convert_image(input_path, output_path, output_format) 35 | 36 | if __name__ == "__main__": 37 | main() 38 | -------------------------------------------------------------------------------- /TABBIBBU HITESH/README.md: -------------------------------------------------------------------------------- 1 | Advance Level 2 | 3 | Task 1 :Image Converter: 4 | 5 | Where the program that accepts images in multiple formats that may be in JPEG, PNG, BMP, GIF and converts them into a desired format using Python Imaging Library (PIL) that may be any of the formats mentioned. 6 | 7 | 8 | Task 2:Data Analysis with Pandas: 9 | 10 | In the program on loading the "Iris" dataset from Seaborn and analyzing it using Pandas and performed exploratory data analysis, cleaning, aggregation, visualizations, and correlation calculations. 11 | The output of the program will consits of calculations , graph which will be more understanding to users. 12 | 13 | 14 | Task 3:Linear Regression with Scikit-learn: 15 | 16 | Completed a program by applying linear regression to predict house prices from the Boston housing dataset using scikit-learn and compared train and test scores and plot residuals. 17 | 18 | Task 4:Image Compression: 19 | 20 | Developed a Python program for compressing images while maintaining quality by exploring compression techniques like RLE and DCT and allowing users to adjust compression quality, support various image formats, and provide output options. Optionally, include a user interface. 21 | -------------------------------------------------------------------------------- /TABBIBBU HITESH/Task1: -------------------------------------------------------------------------------- 1 | from PIL import Image 2 | import os 3 | 4 | def convert_image(input_path, output_path, output_format): 5 | try: 6 | # Open the image 7 | with Image.open(input_path) as img: 8 | # Convert and save the image to the desired format 9 | img.save(output_path, format=output_format) 10 | print(f"Image converted successfully to {output_format} format.") 11 | except Exception as e: 12 | print(f"An error occurred: {e}") 13 | 14 | def main(): 15 | input_path = input("Enter the path to the input image: ") 16 | output_format = input("Enter the desired output format (e.g., JPEG, PNG, BMP, GIF): ").upper() 17 | 18 | # Validate output format 19 | if output_format not in ['JPEG', 'PNG', 'BMP', 'GIF']: 20 | print("Invalid output format. Please choose from JPEG, PNG, BMP, or GIF.") 21 | return 22 | 23 | # Extract the file name and extension 24 | file_name, file_extension = os.path.splitext(input_path) 25 | 26 | # If the input file already has an extension, remove it 27 | file_name_without_ext = file_name.split('.')[0] 28 | 29 | # Set the output path 30 | output_path = f"{file_name_without_ext}_converted.{output_format.lower()}" 31 | 32 | # Convert the image 33 | convert_image(input_path, output_path, output_format) 34 | 35 | if __name__ == "__main__": 36 | main() 37 | -------------------------------------------------------------------------------- /TABBIBBU HITESH/Task2: -------------------------------------------------------------------------------- 1 | import seaborn as sns 2 | import pandas as pd 3 | import matplotlib.pyplot as plt 4 | 5 | # Load the Iris dataset from Seaborn 6 | iris = sns.load_dataset("iris") 7 | numeric_iris = iris.drop(columns='species') 8 | 9 | # Display the first few rows of the dataset 10 | print("First few rows of the dataset:") 11 | print(iris.head()) 12 | 13 | # Summary statistics 14 | print("\nSummary statistics:") 15 | print(iris.describe()) 16 | 17 | # Checking for missing values 18 | print("\nMissing values:") 19 | print(iris.isnull().sum()) 20 | 21 | # Visualizations 22 | # Pairplot 23 | sns.pairplot(iris, hue="species") 24 | plt.title("Pairplot of Iris Dataset") 25 | plt.show() 26 | 27 | # Boxplot 28 | plt.figure(figsize=(10, 6)) 29 | sns.boxplot(data=iris, orient="h") 30 | plt.title("Boxplot of Iris Dataset") 31 | plt.show() 32 | 33 | # Histograms 34 | plt.figure(figsize=(10, 6)) 35 | iris.hist() 36 | plt.suptitle("Histograms of Iris Dataset") 37 | plt.show() 38 | 39 | # Correlation heatmap 40 | plt.figure(figsize=(8, 6)) 41 | sns.heatmap(numeric_iris.corr(), annot=True, cmap="coolwarm") 42 | plt.title("Correlation Heatmap of Iris Dataset") 43 | plt.show() 44 | -------------------------------------------------------------------------------- /TABBIBBU HITESH/Task3: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import matplotlib.pyplot as plt 3 | from sklearn.model_selection import train_test_split 4 | from sklearn.linear_model import LinearRegression 5 | from sklearn.metrics import mean_squared_error 6 | import pandas as pd 7 | data_url = "http://lib.stat.cmu.edu/datasets/boston" 8 | raw_df = pd.read_csv(data_url, sep="\s+", skiprows=22, header=None) 9 | data = np.hstack([raw_df.values[::2, :], raw_df.values[1::2, :2]]) 10 | target = raw_df.values[1::2, 2] 11 | 12 | # Load the Boston housing dataset 13 | 14 | X = data 15 | y = target 16 | 17 | # Split the data into training and testing sets 18 | X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42) 19 | 20 | # Initialize the linear regression model 21 | model = LinearRegression() 22 | 23 | # Fit the model on the training data 24 | model.fit(X_train, y_train) 25 | 26 | # Predict on the training and testing data 27 | y_train_pred = model.predict(X_train) 28 | y_test_pred = model.predict(X_test) 29 | 30 | # Calculate the scores 31 | train_score = model.score(X_train, y_train) 32 | test_score = model.score(X_test, y_test) 33 | 34 | print("Training score:", train_score) 35 | print("Testing score:", test_score) 36 | 37 | # Plot residuals 38 | plt.scatter(y_train_pred, y_train_pred - y_train, c='blue', marker='o', label='Training data') 39 | plt.scatter(y_test_pred, y_test_pred - y_test, c='lightgreen', marker='s', label='Testing data') 40 | plt.xlabel('Predicted values') 41 | plt.ylabel('Residuals') 42 | plt.legend(loc='upper left') 43 | plt.hlines(y=0, xmin=0, xmax=50, lw=2, color='red') 44 | plt.title('Residual plot') 45 | plt.show() 46 | -------------------------------------------------------------------------------- /TABBIBBU HITESH/Task4: -------------------------------------------------------------------------------- 1 | from PIL import Image 2 | import os 3 | 4 | def get_size_format(b, factor=1024, suffix="B"): 5 | """ 6 | Scale bytes to its proper byte format. 7 | e.g: 1253656 => '1.20MB', 1253656678 => '1.17GB' 8 | """ 9 | for unit in ["", "K", "M", "G", "T", "P", "E", "Z"]: 10 | if b < factor: 11 | return f"{b:.2f}{unit}{suffix}" 12 | b /= factor 13 | return f"{b:.2f}Y{suffix}" 14 | 15 | def compress_img(image_name, new_size_ratio=0.9, quality=90, width=None, height=None, to_jpg=True): 16 | # Load the image into memory 17 | img = Image.open(image_name) 18 | 19 | # Print the original image shape 20 | print("[*] Image shape:", img.size) 21 | 22 | # Get the original image size in bytes 23 | image_size = os.path.getsize(image_name) 24 | print("[*] Size before compression:", get_size_format(image_size)) 25 | 26 | if new_size_ratio < 1.0: 27 | # If resizing ratio is below 1.0, multiply width & height with this ratio to reduce image size 28 | img = img.resize((int(img.size[0] * new_size_ratio), int(img.size[1] * new_size_ratio)), Image.ANTIALIAS) 29 | elif width and height: 30 | # If width and height are set, resize with them instead 31 | img = img.resize((width, height), Image.ANTIALIAS) 32 | 33 | # Split the filename and extension 34 | filename, ext = os.path.splitext(image_name) 35 | 36 | # Make a new filename appending "_compressed" to the original file name 37 | if to_jpg: 38 | # Change the extension to JPEG 39 | new_filename = f"{filename}_compressed.jpg" 40 | else: 41 | # Retain the same extension of the original image 42 | new_filename = f"{filename}_compressed{ext}" 43 | 44 | # Save the compressed image 45 | img.save(new_filename, optimize=True, quality=quality) 46 | 47 | # Print the new image shape 48 | print("[+] New Image shape:", img.size) 49 | print(f"[*] Compressed image saved as: {new_filename}") 50 | 51 | # Example usage: 52 | Input=input() 53 | compress_img(Input, new_size_ratio=0.8, quality=80, width=800, height=600) 54 | -------------------------------------------------------------------------------- /Yogi Neelam/Task 3: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import matplotlib.pyplot as plt 3 | from sklearn.model_selection import train_test_split 4 | from sklearn.linear_model import LinearRegression 5 | from sklearn.metrics import mean_squared_error 6 | import pandas as pd 7 | data_url = "http://lib.stat.cmu.edu/datasets/boston" 8 | raw_df = pd.read_csv(data_url, sep="\s+", skiprows=22, header=None) 9 | data = np.hstack([raw_df.values[::2, :], raw_df.values[1::2, :2]]) 10 | target = raw_df.values[1::2, 2] 11 | 12 | # Load the Boston housing dataset 13 | 14 | X = data 15 | y = target 16 | 17 | # Split the data into training and testing sets 18 | X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42) 19 | 20 | # Initialize the linear regression model 21 | model = LinearRegression() 22 | 23 | # Fit the model on the training data 24 | model.fit(X_train, y_train) 25 | 26 | # Predict on the training and testing data 27 | y_train_pred = model.predict(X_train) 28 | y_test_pred = model.predict(X_test) 29 | 30 | # Calculate the scores 31 | train_score = model.score(X_train, y_train) 32 | test_score = model.score(X_test, y_test) 33 | 34 | print("Training score:", train_score) 35 | print("Testing score:", test_score) 36 | 37 | # Plot residuals 38 | plt.scatter(y_train_pred, y_train_pred - y_train, c='blue', marker='o', label='Training data') 39 | plt.scatter(y_test_pred, y_test_pred - y_test, c='lightgreen', marker='s', label='Testing data') 40 | plt.xlabel('Predicted values') 41 | plt.ylabel('Residuals') 42 | plt.legend(loc='upper left') 43 | plt.hlines(y=0, xmin=0, xmax=50, lw=2, color='red') 44 | plt.title('Residual plot') 45 | plt.show() 46 | -------------------------------------------------------------------------------- /Yogi Neelam/Task 4: -------------------------------------------------------------------------------- 1 | from PIL import Image 2 | import os 3 | 4 | def get_size_format(b, factor=1024, suffix="B"): 5 | """ 6 | Scale bytes to its proper byte format. 7 | e.g: 1253656 => '1.20MB', 1253656678 => '1.17GB' 8 | """ 9 | for unit in ["", "K", "M", "G", "T", "P", "E", "Z"]: 10 | if b < factor: 11 | return f"{b:.2f}{unit}{suffix}" 12 | b /= factor 13 | return f"{b:.2f}Y{suffix}" 14 | 15 | def compress_img(image_name, new_size_ratio=0.9, quality=90, width=None, height=None, to_jpg=True): 16 | # Load the image into memory 17 | img = Image.open(image_name) 18 | 19 | # Print the original image shape 20 | print("[*] Image shape:", img.size) 21 | 22 | # Get the original image size in bytes 23 | image_size = os.path.getsize(image_name) 24 | print("[*] Size before compression:", get_size_format(image_size)) 25 | 26 | if new_size_ratio < 1.0: 27 | # If resizing ratio is below 1.0, multiply width & height with this ratio to reduce image size 28 | img = img.resize((int(img.size[0] * new_size_ratio), int(img.size[1] * new_size_ratio)), Image.ANTIALIAS) 29 | elif width and height: 30 | # If width and height are set, resize with them instead 31 | img = img.resize((width, height), Image.ANTIALIAS) 32 | 33 | # Split the filename and extension 34 | filename, ext = os.path.splitext(image_name) 35 | 36 | # Make a new filename appending "_compressed" to the original file name 37 | if to_jpg: 38 | # Change the extension to JPEG 39 | new_filename = f"{filename}_compressed.jpg" 40 | else: 41 | # Retain the same extension of the original image 42 | new_filename = f"{filename}_compressed{ext}" 43 | 44 | # Save the compressed image 45 | img.save(new_filename, optimize=True, quality=quality) 46 | 47 | # Print the new image shape 48 | print("[+] New Image shape:", img.size) 49 | print(f"[*] Compressed image saved as: {new_filename}") 50 | 51 | # Example usage: 52 | compress_img("wp1966881.jpg", new_size_ratio=0.8, quality=80, width=800, height=600) 53 | -------------------------------------------------------------------------------- /Yogi Neelam/Task1: -------------------------------------------------------------------------------- 1 | from PIL import Image 2 | import os 3 | 4 | def convert_image(input_path, output_path, output_format): 5 | try: 6 | # Open the image 7 | with Image.open(input_path) as img: 8 | # Convert and save the image to the desired format 9 | img.save(output_path, format=output_format) 10 | print(f"Image converted successfully to {output_format} format.") 11 | except Exception as e: 12 | print(f"An error occurred: {e}") 13 | 14 | def main(): 15 | input_path = input("Enter the path to the input image: ") 16 | output_format = input("Enter the desired output format (e.g., JPEG, PNG, BMP, GIF): ").upper() 17 | 18 | # Validate output format 19 | if output_format not in ['JPEG', 'PNG', 'BMP', 'GIF']: 20 | print("Invalid output format. Please choose from JPEG, PNG, BMP, or GIF.") 21 | return 22 | 23 | # Extract the file name and extension 24 | file_name, file_extension = os.path.splitext(input_path) 25 | 26 | # If the input file already has an extension, remove it 27 | file_name_without_ext = file_name.split('.')[0] 28 | 29 | # Set the output path 30 | output_path = f"{file_name_without_ext}_converted.{output_format.lower()}" 31 | 32 | # Convert the image 33 | convert_image(input_path, output_path, output_format) 34 | 35 | if __name__ == "__main__": 36 | main() 37 | -------------------------------------------------------------------------------- /Yogi Neelam/Task2: -------------------------------------------------------------------------------- 1 | import seaborn as sns 2 | import pandas as pd 3 | import matplotlib.pyplot as plt 4 | 5 | # Load the Iris dataset from Seaborn 6 | iris = sns.load_dataset("iris") 7 | numeric_iris = iris.drop(columns='species') 8 | 9 | # Display the first few rows of the dataset 10 | print("First few rows of the dataset:") 11 | print(iris.head()) 12 | 13 | # Summary statistics 14 | print("\nSummary statistics:") 15 | print(iris.describe()) 16 | 17 | # Checking for missing values 18 | print("\nMissing values:") 19 | print(iris.isnull().sum()) 20 | 21 | # Visualizations 22 | # Pairplot 23 | sns.pairplot(iris, hue="species") 24 | plt.title("Pairplot of Iris Dataset") 25 | plt.show() 26 | 27 | # Boxplot 28 | plt.figure(figsize=(10, 6)) 29 | sns.boxplot(data=iris, orient="h") 30 | plt.title("Boxplot of Iris Dataset") 31 | plt.show() 32 | 33 | # Histograms 34 | plt.figure(figsize=(10, 6)) 35 | iris.hist() 36 | plt.suptitle("Histograms of Iris Dataset") 37 | plt.show() 38 | 39 | # Correlation heatmap 40 | plt.figure(figsize=(8, 6)) 41 | sns.heatmap(numeric_iris.corr(), annot=True, cmap="coolwarm") 42 | plt.title("Correlation Heatmap of Iris Dataset") 43 | plt.show() 44 | --------------------------------------------------------------------------------