diff --git a/Python Project/Mand_Project.ipynb b/Python Project/Mand_Project.ipynb new file mode 100644 index 0000000..245810b --- /dev/null +++ b/Python Project/Mand_Project.ipynb @@ -0,0 +1,352 @@ +{ + "nbformat": 4, + "nbformat_minor": 0, + "metadata": { + "colab": { + "provenance": [] + }, + "kernelspec": { + "name": "python3", + "display_name": "Python 3" + }, + "language_info": { + "name": "python" + } + }, + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "XUsOSSuUUzhk", + "outputId": "62119328-e829-435e-c681-5ff39be56f6b" + }, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "['Mahesh', 'Ali', 'Jacob']\n" + ] + } + ], + "source": [ + "# Q1\n", + "\n", + "# Defining two lists of employee names\n", + "list1 = [\"Ramesh\", \"Suresh\", \"Mahesh\", \"Ali\", \"Jacob\", \"Saritha\"]\n", + "list2 = [\"Ali\", \"Mukesh\", \"Mahesh\", \"Jacob\", \"Sai\", \"Sarita\"]\n", + "\n", + "common_names = []\n", + "\n", + "for name in list1:\n", + " if name in list2:\n", + " common_names.append(name)\n", + "\n", + "# Display the common names\n", + "print(common_names)\n", + "\n" + ] + }, + { + "cell_type": "code", + "source": [ + "# Q2\n", + "\n", + "# Defining the string with names\n", + "names_str = \"Ramesh Suresh Mohit\"\n", + "\n", + "names_list = names_str.split()\n", + "\n", + "# Define the ages for each name\n", + "ages = {\n", + " \"Ramesh\": 25,\n", + " \"Suresh\": 22,\n", + " \"Mohit\": 26\n", + "}\n", + "\n", + "for name in names_list:\n", + " print(f\"{name}: {ages[name]}\")\n", + "\n" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "e77kMPNk7Edl", + "outputId": "b9fdb21b-8c26-480a-9db7-62748b0cdafc" + }, + "execution_count": null, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "Ramesh: 25\n", + "Suresh: 22\n", + "Mohit: 26\n" + ] + } + ] + }, + { + "cell_type": "code", + "source": [ + "# Q3\n", + "\n", + "# Defining the quantities and costs\n", + "quantities = {\"paracetamol\": 2, \"azithromycin\": 3, \"vitamin_c\": 5}\n", + "costs = {\"paracetamol\": 35, \"azithromycin\": 49, \"vitamin_c\": 33}\n", + "\n", + "# Calculate the total cost for each medicine\n", + "total_cost_each = {medicine: quantities[medicine] * costs[medicine] for medicine in quantities}\n", + "\n", + "# Calculate the total cost of all medicines\n", + "total_cost_all = sum(total_cost_each.values())\n", + "\n", + "# Amount given by the patient\n", + "amount_given = 2000\n", + "\n", + "# Calculate the refund\n", + "refund = amount_given - total_cost_all\n", + "\n", + "total_cost_each, total_cost_all, refund\n", + "\n" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "1E9xRZ0F7LSm", + "outputId": "a52e7936-d442-48ea-d1a2-355ddbd10a86" + }, + "execution_count": null, + "outputs": [ + { + "output_type": "execute_result", + "data": { + "text/plain": [ + "({'paracetamol': 70, 'azithromycin': 147, 'vitamin_c': 165}, 382, 1618)" + ] + }, + "metadata": {}, + "execution_count": 8 + } + ] + }, + { + "cell_type": "code", + "source": [ + "# Q4\n", + "\n", + "def count_vowels(sentence):\n", + " # Define vowels\n", + " vowels = \"aeiouAEIOU\"\n", + "\n", + " # Count vowels\n", + " vowel_count = sum(1 for char in sentence if char in vowels)\n", + "\n", + " return vowel_count\n", + "\n", + "# Test the function with the provided sentence\n", + "user_sentence = input(\"Enter a sentence: \")\n", + "vowel_count = count_vowels(user_sentence)\n", + "\n", + "\n", + "print(f\"The sentence '{user_sentence}' contains {vowel_count} vowels.\")\n", + "\n" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "TB2huMID7Zd5", + "outputId": "2c8f5635-6e41-480e-dbb0-0e7688c64e9d" + }, + "execution_count": null, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "Enter a sentence: hey this is somnath\n", + "The sentence 'hey this is somnath' contains 5 vowels.\n" + ] + } + ] + }, + { + "cell_type": "code", + "source": [ + "# Q5\n", + "\n", + "# Get user input for age\n", + "age = int(input(\"Enter your age: \"))\n", + "\n", + "# Define the eligibility criteria\n", + "voting_age = 18\n", + "\n", + "# Check eligibility and display the result\n", + "if age >= voting_age:\n", + " print(\"Congrats! You are eligible for voting.\")\n", + "else:\n", + " years_to_wait = voting_age - age\n", + " print(f\"you have to return after {years_to_wait} number of years. The eligibility criteria for voting is 18 years. \")\n" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "KoPAtMsD7g-0", + "outputId": "2bbe4661-517d-4fa8-ca08-215815f9cd71" + }, + "execution_count": null, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "Enter your age: 21\n", + "Congrats! You are eligible for voting.\n" + ] + } + ] + }, + { + "cell_type": "code", + "source": [ + "# Q6\n", + "\n", + "# Given list\n", + "A = [1, 2, 3, 4, 5]\n", + "\n", + "# Initialize an empty list to store cumulative sums\n", + "cumulative_sum = []\n", + "\n", + "# Initialize a variable to keep track of the running sum\n", + "running_sum = 0\n", + "\n", + "# Calculate cumulative sum and store in the new list\n", + "for num in A:\n", + " running_sum += num\n", + " cumulative_sum.append(running_sum)\n", + "\n", + "# Display the result\n", + "print(\"Input List:\", A)\n", + "print(\"Cumulative Sum List:\", cumulative_sum)\n", + "\n", + "\n" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "S0IIQQEC7nB6", + "outputId": "cc904747-bc8c-48e1-bf17-0b1fdf7efddc" + }, + "execution_count": null, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "Input List: [1, 2, 3, 4, 5]\n", + "Cumulative Sum List: [1, 3, 6, 10, 15]\n" + ] + } + ] + }, + { + "cell_type": "code", + "source": [ + "# Q7\n", + "\n", + "def encode_message(sentence):\n", + " vowels = \"aeiouAEIOU\"\n", + " words = sentence.split()\n", + " encoded_words = []\n", + "\n", + " for word in words:\n", + " # Check if the word starts with a vowel\n", + " if word[0] in vowels:\n", + " encoded_word = word[0] + word[-1]\n", + " else:\n", + " # Remove all vowels if the word starts with a consonant\n", + " encoded_word = ''.join([char for char in word if char not in vowels])\n", + " encoded_words.append(encoded_word)\n", + "\n", + " return ' '.join(encoded_words)\n", + "\n", + "# Test the function with the provided sentence\n", + "input_text = \"The quick brown fox used to sleep inside this box\"\n", + "encoded_msg = encode_message(input_text)\n", + "encoded_msg\n", + "\n" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/", + "height": 35 + }, + "id": "yBKYA4Ey7szk", + "outputId": "40a80a6a-8c61-4d42-8153-41fba0d868bf" + }, + "execution_count": null, + "outputs": [ + { + "output_type": "execute_result", + "data": { + "text/plain": [ + "'Th qck brwn fx ud t slp ie ths bx'" + ], + "application/vnd.google.colaboratory.intrinsic+json": { + "type": "string" + } + }, + "metadata": {}, + "execution_count": 13 + } + ] + }, + { + "cell_type": "code", + "source": [ + "# Q8\n", + "\n", + "def run_length_encoding(input_string):\n", + " # Initialize variables\n", + " encoded_string = \"\"\n", + " current_count = 1\n", + "\n", + " # Iterate over the string\n", + " for i in range(1, len(input_string)):\n", + " # Check if the current character is the same as the previous\n", + " if input_string[i] == input_string[i - 1]:\n", + " current_count += 1\n", + " else:\n", + " # Append the count and character to the encoded string\n", + " encoded_string += str(current_count) + input_string[i - 1]\n", + " current_count = 1\n", + "\n", + " # Append the last character and its count\n", + " encoded_string += str(current_count) + input_string[-1]\n", + "\n", + " return encoded_string\n", + "\n", + "# Test the function with the provided string\n", + "input_str = \"aabbbccdddae\"\n", + "encoded_str = run_length_encoding(input_str)\n", + "encoded_str\n", + "\n" + ], + "metadata": { + "id": "IqqnwtY17w5-" + }, + "execution_count": null, + "outputs": [] + } + ] +} \ No newline at end of file diff --git a/Python Project/Python_Project_Questions.txt b/Python Project/Python_Project_Questions.txt new file mode 100644 index 0000000..745c0a0 --- /dev/null +++ b/Python Project/Python_Project_Questions.txt @@ -0,0 +1,95 @@ +Q1: + +You are working in a bank, and you have been given two lists of the employees who worked in 2021. Employees’ names in list 1 are Ramesh, Suresh, Mahesh, Ali, Jacob, and Saritha. List 2 contains the names of Ali, Mukesh, Mahesh, Jacob, Sai, and Sarita. Please write a program that helps to identify people who are common in both lists. Please do not use any in-built function. + + + +Q2: + +While entering data, someone entered a few names as a common string “Ramesh Suresh Mohit”. Please write a program which separates all the names and converts them into a list. Once converted into a list, please write a program that adds their age. + + + +Ramesh: 25 + +Suresh: 22 + +Mohit: 26 + + + +Q3: + +You are working in a medical store. A patient came to your medical store and asked to buy 2 strips of paracetamol, 3 strips of azithromycin, and 5 strips of Vitamin C. One strip of paracetamol costs Rs 35, one strip of azithromycin costs Rs 49, and one strip of vitamin c costs Rs. 33. Patient gave you Rs 2000. Please tell us what is the total cost of each medicine, the total cost of all medicine, and how much money you refunded to the patient. + + + +Q4: + +Accept a sentence as input and find the number of vowels in it. Assume that the sentence has no punctuation marks. For example, I am learning python contains 6 vowels. This function should be applicable for all other different sentences. + + + +Q5: + +You have been appointed by the election commission to create a website. Your first task is to work on a program which tells candidates if they are eligible for voting or not. If they are eligible, your output should be ‘Congrats! You are eligible’; otherwise, it should tell that you have to return after X number of years. The eligibility criteria for voting is 18 years. + + + +For example, If someone is 18 or above, your output should be ‘Congrats! You are eligible’. If someone’s age is 15 years, it should print output as ‘return after 3 years’. + + + +Q6: + +Given a list of integers, find the cumulative sum of the elements of the list and store them in another list. + + + +A = [1, 2, 3, 4, 5] + + + +Output: + +[1, 3, 6, 10, 15] + + +Q7: + +WAP to encode a message entered by user as per below conditions: + + + +for every word in the sentence, + +1. If the word starts with a vowel, encode it as the first and last letter of the word. + +2. If the word starts with a consonant, remove all vowels from it. + + + +Ensure the case insensitive comparisons/checks are performed. + + + +Please enter your text:The quick brown fox used to sleep inside this box + +Encoded Msg: Th qck brwn fx ud t slp ie ths bx + + + +Q8: + +Write a program to implement run length encoding of a string + + + +RLE:Consecutive repetition of a character has to be replaced with the count of occurrences and the character. + + + +Enter your string :aabbbccdddae + +Encoded: 2a3b2c3d1a1e + diff --git a/Python Project/Readme.md b/Python Project/Readme.md new file mode 100644 index 0000000..c7f0544 --- /dev/null +++ b/Python Project/Readme.md @@ -0,0 +1 @@ +# Python data Analysis diff --git a/Instagram_Analysis.sql b/SQL Project/Instagram_Analysis.sql similarity index 100% rename from Instagram_Analysis.sql rename to SQL Project/Instagram_Analysis.sql diff --git a/ig_clone_data.sql b/SQL Project/ig_clone_data.sql similarity index 100% rename from ig_clone_data.sql rename to SQL Project/ig_clone_data.sql diff --git a/SQL Project/readme.md b/SQL Project/readme.md new file mode 100644 index 0000000..a1688ad --- /dev/null +++ b/SQL Project/readme.md @@ -0,0 +1,100 @@ +# Advanced SQL Analytics Project: Exploring an Instagram-like Dataset + +## Project Overview + +Welcome to the Advanced SQL Analytics Project! This project aims to challenge your SQL skills by exploring a simplified version of an Instagram-like database schema. This schema includes essential components of a social media platform where users can post photos, like, comment, follow each other, and more. + +## Table of Contents + +1. [Introduction](#introduction) +2. [Database Schema](#database-schema) +3. [Project Objectives](#project-objectives) +4. [SQL Concepts and Techniques](#sql-concepts-and-techniques) +5. [Detailed Analysis Tasks](#detailed-analysis-tasks) +6. [Insights and Findings](#insights-and-findings) +7. [Conclusion](#conclusion) +8. [How to Use This Repository](#how-to-use-this-repository) +9. [Acknowledgments](#acknowledgments) + +## Introduction + +In this project, we delve into an Instagram-like dataset to perform advanced SQL analytics. The primary goal is to extract meaningful insights from complex datasets, enhancing your ability to work with real-world data scenarios. + +## Database Schema + +The dataset represents a simplified version of a social media platform with the following core components: + +- **Users**: Information about users, including their IDs and usernames. +- **Posts**: Details of the photos posted by users, including post IDs, user IDs, timestamps, and captions. +- **Likes**: Records of which users liked which posts. +- **Comments**: Details of comments made by users on posts, including comment IDs, user IDs, post IDs, and timestamps. +- **Followers**: Information on which users follow other users. + +## Project Objectives + +The primary objectives of this project are: + +1. To enhance proficiency in advanced SQL functions and techniques. +2. To perform intricate data analysis tasks using a variety of SQL queries. +3. To gain insights into user behavior and content interaction on a social media platform. +4. To prepare for real-world data analysis challenges through hands-on practice. + +## SQL Concepts and Techniques + +Throughout this project, we utilized a range of advanced SQL concepts and techniques, including: + +- **Window Functions**: To perform calculations across a set of table rows related to the current row. +- **Grouping**: To aggregate data based on specific criteria. +- **Subqueries**: To perform nested queries and retrieve specific data insights. +- **Joins**: To combine rows from two or more tables based on related columns. +- **CTEs (Common Table Expressions)**: To simplify complex queries and improve readability. + +## Detailed Analysis Tasks + +Here are some of the detailed analysis tasks performed in this project: + +1. **User Engagement Analysis**: + - Identify the most active users based on posts, likes, and comments. + - Analyze user engagement patterns over time. + +2. **Content Performance Analysis**: + - Determine which types of posts receive the most likes and comments. + - Identify peak times for user engagement. + +3. **Follower Network Analysis**: + - Analyze the follower relationships between users. + - Identify influential users based on their follower count. + +4. **Post Interaction Analysis**: + - Examine the distribution of likes and comments across posts. + - Identify posts with unusually high or low engagement. + +## Insights and Findings + +From my analysis, I gained several key insights: + +- **User Activity**: Certain users are significantly more active, contributing a majority of posts, likes, and comments. +- **Engagement Patterns**: User engagement peaks during specific times of the day, suggesting optimal posting times. +- **Content Trends**: Posts with certain types of content or hashtags receive higher engagement. +- **Influential Users**: A small number of users have a large follower base, indicating their influence within the network. + +## Conclusion + +This project provided a comprehensive exercise in advanced SQL analytics, allowing us to extract valuable insights from a complex dataset. By working through these tasks, we enhanced our SQL skills and prepared for real-world data analysis scenarios. + +## How to Use This Repository + +1. **Clone the Repository**: + ```bash + git clone https://github.com/yourusername/instagram-sql-analytics.git + ``` + +2. **Load the Dataset**: Import the provided SQL scripts to set up the database schema and populate it with data. + +3. **Run the SQL Queries**: Use your preferred SQL client to execute the analysis tasks outlined in the project. + +4. **Explore the Insights**: Review the findings and insights derived from the analysis tasks. + +## Acknowledgments + +Special thanks to the creators of the dataset and the open-source SQL community for their valuable resources and contributions.