From 56b7baa01b01e3d89dd139074c2f867795c0dfd9 Mon Sep 17 00:00:00 2001 From: SHIVADITYA BHATTACHARYA Date: Wed, 8 Jan 2025 23:49:09 +0530 Subject: [PATCH] Only first 2 questions made --- .../dtq1.md | 102 +++++++++++++ .../q2_data_processing.md | 141 ++++++++++++++++++ 2 files changed, 243 insertions(+) create mode 100644 Questions by Shivaditya Bhattacharya (22f3000819)/dtq1.md create mode 100644 Questions by Shivaditya Bhattacharya (22f3000819)/q2_data_processing.md diff --git a/Questions by Shivaditya Bhattacharya (22f3000819)/dtq1.md b/Questions by Shivaditya Bhattacharya (22f3000819)/dtq1.md new file mode 100644 index 0000000..1034cd5 --- /dev/null +++ b/Questions by Shivaditya Bhattacharya (22f3000819)/dtq1.md @@ -0,0 +1,102 @@ +--- +title: Playing with Data Types +tags: [datatypes, int, float, str, list, dictionary] +--- + +# Problem Statement +You are given the following: + +1. First name and last name of a person in lower-case. Make only the first character of each upper-case and contatenate them to make the full name. + +2. The person's monthly salary and performance bonus percentage. Calculate the bonus amount and total salary for the month. + +3. A comma-seperated string of the person's projects. Find the number of projects he's worked on without using a loop. + +Return a dictionary of the format: +{ + "full_name": str, + "bonus": float, + "salary_after_bonus": float, + "number_of_projects": int, + "projects": list, +} + +# Solution +```python test.py -r 'python test.py' + +# some prefix + + + +# some suffix + + +{% include '../function_type_and_modify_check_suffix.py.jinja' %} + +``` + +# Public Test Cases + +## Input 1 +``` +first_name = 'vineet' +last_name = 'solanki' +salary = 45000 +bonus_percent = 8.356 +projects = "DigiCop,eSuraksha,KaviSammelan" +``` + +## Output 1 +``` +{'full_name': 'Vineet Solanki', 'bonus': 3760.2, 'salary_after_bonus': 48760.2, 'number_of_projects': 3, 'projects': ['DigiCop', 'eSuraksha', 'KaviSammelan']} +``` + + +# Private Test Cases + + +## Input 1 +``` +first_name = 'ayushi' +last_name = 'saha' +salary = 72758 +bonus_percent = 9 +projects = "NLP-ChatBot,ClientHelp" +``` + +## Output 1 +``` +{'full_name': 'Ayushi Saha', 'bonus': 6548.22, 'salary_after_bonus': 79306.22, 'number_of_projects': 2, 'projects': ['NLP-ChatBot', 'ClientHelp']} +``` \ No newline at end of file diff --git a/Questions by Shivaditya Bhattacharya (22f3000819)/q2_data_processing.md b/Questions by Shivaditya Bhattacharya (22f3000819)/q2_data_processing.md new file mode 100644 index 0000000..4021d3c --- /dev/null +++ b/Questions by Shivaditya Bhattacharya (22f3000819)/q2_data_processing.md @@ -0,0 +1,141 @@ +--- +title: Daily shop records +tags: [aggregation, filtering, I/O, definite input] +--- + +# Problem Statement +You are provided with a list of dictionaries where each dictionary contains information about a shopper, including their name, age, and a dictionary of items they have bought, with item names as keys and quantities as values. + +Return a dictionary having the format: +{ + "shoppers": list of names, + "filtered_by_age": Shoppers above the given age filter, + "average_age": Average age of shoppers, + "sorted_shoppers": Shoppers sorted by age, + "items_group": Group shopper names by items bought, + "unique_items": Set of unique items bought from the shop +} + +# Solution +```python test.py -r 'python test.py' + +# some prefix + + + +# some suffix + + +{% include '../function_type_and_modify_check_suffix.py.jinja' %} + +``` + +# Public Test Cases + +## Input 1 +``` +shoppers = [ + {"name": "Alice", "age": 25, "items_bought": {"Apples": 3, "Bananas": 5}}, + {"name": "Bob", "age": 35, "items_bought": {"Oranges": 2, "Milk": 1}}, + {"name": "Charlie", "age": 30, "items_bought": {"Apples": 1, "Bread": 2}}, + {"name": "David", "age": 22, "items_bought": {"Milk": 2, "Eggs": 12}}, + {"name": "Eve", "age": 28, "items_bought": {"Bananas": 4, "Oranges": 3}}, +] +age_filter = 25 +``` + +## Output 1 +``` +shoppers: ['Alice', 'Bob', 'Charlie', 'David', 'Eve'] +filtered_by_age: ['Bob', 'Charlie', 'Eve'] +average_age: 28.0 +sorted_shoppers: [{'name': 'David', 'age': 22, 'items_bought': {'Milk': 2, 'Eggs': 12}}, {'name': 'Alice', 'age': 25, 'items_bought': {'Apples': 3, 'Bananas': 5}}, {'name': 'Eve', 'age': 28, 'items_bought': {'Bananas': 4, 'Oranges': 3}}, {'name': 'Charlie', 'age': 30, 'items_bought': {'Apples': 1, 'Bread': 2}}, {'name': 'Bob', 'age': 35, 'items_bought': {'Oranges': 2, 'Milk': 1}}] +items_group: {'Apples': ['Alice', 'Charlie'], 'Bananas': ['Alice', 'Eve'], 'Oranges': ['Bob', 'Eve'], 'Milk': ['Bob', 'David'], 'Bread': ['Charlie'], 'Eggs': ['David']} +unique_items: {'Bananas', 'Oranges', 'Bread', 'Eggs', 'Milk', 'Apples'} +``` + +# Private Test Cases + + +## Input 1 +``` +shoppers = [ + {"name": "Alice", "age": 25, "items_bought": {"Apples": 3, "Bananas": 5, "Oranges": 2, "Milk": 1}}, + {"name": "Bob", "age": 35, "items_bought": {"Oranges": 2, "Milk": 1, "Cheese": 1, "Bread": 2}}, + {"name": "Charlie", "age": 30, "items_bought": {"Apples": 1, "Bread": 2, "Eggs": 6, "Butter": 1}}, + {"name": "David", "age": 22, "items_bought": {"Milk": 2, "Eggs": 12, "Bread": 3, "Cheese": 1}}, + {"name": "Eve", "age": 28, "items_bought": {"Bananas": 4, "Oranges": 3, "Tomatoes": 5, "Cucumbers": 2}}, + {"name": "Frank", "age": 40, "items_bought": {"Cheese": 2, "Wine": 1, "Apples": 3, "Bread": 4}}, + {"name": "Grace", "age": 27, "items_bought": {"Oranges": 5, "Apples": 3, "Bread": 2, "Butter": 1}}, + {"name": "Hank", "age": 32, "items_bought": {"Milk": 3, "Cereal": 2, "Eggs": 4, "Tomatoes": 6}}, + {"name": "Ivy", "age": 38, "items_bought": {"Eggs": 6, "Bread": 4, "Milk": 2, "Tomatoes": 3}}, + {"name": "Jack", "age": 29, "items_bought": {"Bananas": 5, "Tomatoes": 4, "Milk": 1, "Oranges": 2}}, + {"name": "Karen", "age": 33, "items_bought": {"Apples": 2, "Oranges": 4, "Bananas": 3, "Bread": 1}}, + {"name": "Louis", "age": 24, "items_bought": {"Milk": 1, "Cereal": 3, "Bread": 2, "Eggs": 5}}, +] + +``` + +## Output 1 +``` +shoppers: ['Alice', 'Bob', 'Charlie', 'David', 'Eve', 'Frank', 'Grace', 'Hank', 'Ivy', 'Jack', 'Karen', 'Louis'] +filtered_by_age: ['Bob', 'Charlie', 'Eve', 'Frank', 'Grace', 'Hank', 'Ivy', 'Jack', 'Karen'] +average_age: 30.25 +sorted_shoppers: [{'name': 'David', 'age': 22, 'items_bought': {'Milk': 2, 'Eggs': 12, 'Bread': 3, 'Cheese': 1}}, {'name': 'Louis', 'age': 24, 'items_bought': {'Milk': 1, 'Cereal': 3, 'Bread': 2, 'Eggs': 5}}, {'name': 'Alice', 'age': 25, 'items_bought': {'Apples': 3, 'Bananas': 5, 'Oranges': 2, 'Milk': 1}}, {'name': 'Grace', 'age': 27, 'items_bought': {'Oranges': 5, 'Apples': 3, 'Bread': 2, 'Butter': 1}}, {'name': 'Eve', 'age': 28, 'items_bought': {'Bananas': 4, 'Oranges': 3, 'Tomatoes': 5, 'Cucumbers': 2}}, {'name': 'Jack', 'age': 29, 'items_bought': {'Bananas': 5, 'Tomatoes': 4, 'Milk': 1, 'Oranges': 2}}, {'name': 'Charlie', 'age': 30, 'items_bought': {'Apples': 1, 'Bread': 2, 'Eggs': 6, 'Butter': 1}}, {'name': 'Hank', 'age': 32, 'items_bought': {'Milk': 3, 'Cereal': 2, 'Eggs': 4, 'Tomatoes': 6}}, {'name': 'Karen', 'age': 33, 'items_bought': {'Apples': 2, 'Oranges': 4, 'Bananas': 3, 'Bread': 1}}, {'name': 'Bob', 'age': 35, 'items_bought': {'Oranges': 2, 'Milk': 1, 'Cheese': 1, 'Bread': 2}}, {'name': 'Ivy', 'age': 38, 'items_bought': {'Eggs': 6, 'Bread': 4, 'Milk': 2, 'Tomatoes': 3}}, {'name': 'Frank', 'age': 40, 'items_bought': {'Cheese': 2, 'Wine': 1, 'Apples': 3, 'Bread': 4}}] +items_group: {'Apples': ['Alice', 'Charlie', 'Frank', 'Grace', 'Karen'], 'Bananas': ['Alice', 'Eve', 'Jack', 'Karen'], 'Oranges': ['Alice', 'Bob', 'Eve', 'Grace', 'Jack', 'Karen'], 'Milk': ['Alice', 'Bob', 'David', 'Hank', 'Ivy', 'Jack', 'Louis'], 'Cheese': ['Bob', 'David', 'Frank'], 'Bread': ['Bob', 'Charlie', 'David', 'Frank', 'Grace', 'Ivy', 'Karen', 'Louis'], 'Eggs': ['Charlie', 'David', 'Hank', 'Ivy', 'Louis'], 'Butter': ['Charlie', 'Grace'], 'Tomatoes': ['Eve', 'Hank', 'Ivy', 'Jack'], 'Cucumbers': ['Eve'], 'Wine': ['Frank'], 'Cereal': ['Hank', 'Louis']} +unique_items: {'Bananas', 'Cucumbers', 'Cheese', 'Cereal', 'Tomatoes', 'Apples', 'Milk', 'Oranges', 'Butter', 'Eggs', 'Bread', 'Wine'} +``` \ No newline at end of file