├── 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 |Temperature: {{ weather_data['main']['temp'] }}°C
37 |Weather: {{ weather_data['weather'][0]['description'] }}
38 | {% endif %} 39 |