From 4f7a2280bd8c7d2bf14276d7177fa999902c07b7 Mon Sep 17 00:00:00 2001 From: SHATAKSHI MITTRA Date: Mon, 6 Jan 2025 20:09:27 +0530 Subject: [PATCH 1/5] Add Data Types question --- questions-by-shatakshi/data_types.proq | 125 +++++++++++++++++++++++++ 1 file changed, 125 insertions(+) create mode 100644 questions-by-shatakshi/data_types.proq diff --git a/questions-by-shatakshi/data_types.proq b/questions-by-shatakshi/data_types.proq new file mode 100644 index 0000000..7b007d4 --- /dev/null +++ b/questions-by-shatakshi/data_types.proq @@ -0,0 +1,125 @@ +--- +title: Basic Operations on Data Types +tags: ['int', 'float', 'str', 'list', 'dict', 'set', 'function', 'no loops'] +--- + +### Problem Statement +Write a function `perform_operations` that takes a list of mixed data types, and returns a dictionary containing the results of different operations on these data types. + +The dictionary should have the following keys: +- `'int_sum'`: sum of all integer elements in the list. +- `'float_sum'`: sum of all float elements in the list, rounded to two decimals. +- `'str_concat'`: concatenation of all string elements. +- `'list_concat'`: concatenation of all list elements (use list.extend). +- `'dict_merge'`: merging of all dictionary elements (use dict.update). +- `'set_union'`: union of all set elements (use set.union). + +The function should handle empty or missing values gracefully by returning appropriate defaults: +- For `'int_sum'`, return 0 if no integers are present. +- For `'float_sum'`, return 0 if no floats are present. +- For `'str_concat'`, return an empty string if no strings are present. +- For `'list_concat'`, return an empty list if no lists are present. +- For `'dict_merge'`, return an empty dictionary if no dictionaries are present. +- For `'set_union'`, return an empty set if no sets are present. + +### Solution + +```python +# Driver Code (to handle I/O) +def driver_function(): + # Accepting inputs from the user or from test cases + input_list = eval(input()) # Read the mixed data list + + # Calling the solution function and printing the result + result = perform_operations(input_list) + print(result) + +# Template Function that needs to be implemented by the student + + +### Test Cases + +#### Public Test Cases + +## Input 1 +[1, 2.5, 'Hello', [1, 2], {'a': 1}, {1, 2}] + +## Output 1 +{ + 'int_sum': 3, + 'float_sum': 2.5, + 'str_concat': 'Hello', + 'list_concat': [1, 2], + 'dict_merge': {'a': 1}, + 'set_union': {1, 2} +} + +## Input 2 +[3, 4.2, 'World', [], {}, {3, 4}] + +## Output 2 +{ + 'int_sum': 7, + 'float_sum': 4.2, + 'str_concat': 'World', + 'list_concat': [], + 'dict_merge': {}, + 'set_union': {3, 4} +} + + +#### Private Test Cases + +## Input 1 +[10, 'Python', [5, 6], {'x': 10}, {1, 2}] + +## Output 1 +{ + 'int_sum': 10, + 'float_sum': 0, + 'str_concat': 'Python', + 'list_concat': [5, 6], + 'dict_merge': {'x': 10}, + 'set_union': {1, 2} +} + +## Input 2 +[1, 2, 3, 4, 5] + +## Output 2 +{ + 'int_sum': 15, + 'float_sum': 0, + 'str_concat': '', + 'list_concat': [], + 'dict_merge': {}, + 'set_union': set() +} \ No newline at end of file From e111596d43d670591da4fa18f4fa6ff829dacf4b Mon Sep 17 00:00:00 2001 From: SHATAKSHI MITTRA Date: Wed, 8 Jan 2025 11:09:26 +0530 Subject: [PATCH 2/5] Add Data processing question --- questions-by-shatakshi/data_processing.proq | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 questions-by-shatakshi/data_processing.proq diff --git a/questions-by-shatakshi/data_processing.proq b/questions-by-shatakshi/data_processing.proq new file mode 100644 index 0000000..e69de29 From ea0fd0408910f0569230501b4a8e1f3b02104e23 Mon Sep 17 00:00:00 2001 From: SHATAKSHI MITTRA Date: Wed, 8 Jan 2025 11:36:06 +0530 Subject: [PATCH 3/5] Add Data processing I/O question --- questions-by-shatakshi/data_processing3.proq | 121 +++++++++++++++++++ 1 file changed, 121 insertions(+) create mode 100644 questions-by-shatakshi/data_processing3.proq diff --git a/questions-by-shatakshi/data_processing3.proq b/questions-by-shatakshi/data_processing3.proq new file mode 100644 index 0000000..a11347d --- /dev/null +++ b/questions-by-shatakshi/data_processing3.proq @@ -0,0 +1,121 @@ +--- +title: Data Processing I/O +tags: ['list', 'comprehension', 'filter', 'aggregation', 'function', 'stdin', 'stdout'] +--- + +### Problem Statement: +Write a function `process_and_output` that takes a list of integers from the input, multiplies each number by 3, filters out the numbers greater than a provided `filter_threshold`, and calculates the sum of the filtered numbers. Finally, it should print the results in the specified format: + +The function should perform the following steps: +1. Multiply each number in the list by 3. +2. Filter out numbers that are greater than the `filter_threshold` after multiplication. +3. Calculate the sum of the filtered numbers. +4. Print the results in the following format: + - List of multiplied numbers. + - List of filtered numbers. + - Sum of filtered numbers. + +### Input: +- A list of integers (space-separated). +- A single integer `filter_threshold`. + +### Output: +- Print the results in the following format: +Doubled Numbers: +Filtered Numbers: +Sum of Filtered Numbers: + + + + +### Constraints: +- The input list will contain at least 1 and at most 100 integers. +- Each integer will be in the range [-10^6, 10^6]. +- The filter threshold will be an integer in the range [-10^6, 10^6]. + +### Solution: + +```python +# Driver Code (to handle I/O) +def driver_function(): + # Accepting inputs from stdin + numbers = list(map(int, input().split())) # Read the list of numbers + filter_threshold = int(input()) # Read the threshold value + + # Calling the solution function and printing the result + process_and_output(numbers, filter_threshold) + +# Template Function that needs to be implemented by the student + + +### Test Cases + +#### Public Test Cases + +## Input 1 +1 2 3 4 5 +10 + +## Output 1 +Doubled Numbers: [3, 6, 9, 12, 15] +Filtered Numbers: [3, 6, 9] +Sum of Filtered Numbers: 18 + +## Input 2 +-1 -2 -3 -4 -5 +-6 + +## Output 2 +Doubled Numbers: [-3, -6, -9, -12, -15] +Filtered Numbers: [-3, -6] +Sum of Filtered Numbers: -9 + +#### Private Test Cases + +## Input 1 +10 20 30 40 50 +60 + +## Output 1 +Doubled Numbers: [30, 60, 90, 120, 150] +Filtered Numbers: [30, 60] +Sum of Filtered Numbers: 90 + +## Input 2 +-10 -20 -30 -40 -50 +-100 + +## Output 2 +Doubled Numbers: [-30, -60, -90, -120, -150] +Filtered Numbers: [-30, -60, -90] +Sum of Filtered Numbers: -180 From a9469ccac37d3d93786bde0148816db8835cbc9a Mon Sep 17 00:00:00 2001 From: SHATAKSHI MITTRA Date: Wed, 8 Jan 2025 11:54:12 +0530 Subject: [PATCH 4/5] Add Function type question --- questions-by-shatakshi/function_typeques.proq | 142 ++++++++++++++++++ 1 file changed, 142 insertions(+) create mode 100644 questions-by-shatakshi/function_typeques.proq diff --git a/questions-by-shatakshi/function_typeques.proq b/questions-by-shatakshi/function_typeques.proq new file mode 100644 index 0000000..4c368bb --- /dev/null +++ b/questions-by-shatakshi/function_typeques.proq @@ -0,0 +1,142 @@ +--- +title: Student Score Management System +tags: ['list', 'function', 'sorting', 'filtering', 'input-output', 'aggregation'] +--- + +## Problem Statement + +You are tasked with building a system that manages the scores of students. The system will handle multiple operations, including adding students, removing them, updating scores, and calculating statistics based on the current list of students. + +## Solution Template + + + + +# The system uses a dictionary to manage students and their scores for efficient lookups, updates, and removals. +# Scores are processed and sorted using Python's built-in `sorted()` function and dictionary comprehensions for filtering. + + +## Test Cases + +# Public Test Case 1 +input: | + add_student John 85 + add_student Jane 92 + add_student Bob 78 + update_score John 90 + average_score + highest_score + print_all_students + filter_by_score 80 +output: | + Average Score: 86.67 + Highest Score: ['Jane'] + John: 90 + Jane: 92 + Bob: 78 + John: 90 + Jane: 92 + +# Public Test Case 2 +input: | + add_student Alice 88 + add_student Bob 90 + remove_student Alice + average_score + highest_score + print_all_students +output: | + Average Score: 90.0 + Highest Score: ['Bob'] + Bob: 90 + +# Private Test Case 1 +input: | + add_student Charlie 72 + add_student Dave 95 + update_score Charlie 80 + remove_student Alice + filter_by_score 80 +output: | + Dave: 95 + Charlie: 80 + +# Private Test Case 2 +input: | + add_student Eve 65 + add_student Frank 80 + add_student Grace 90 + remove_student Frank + average_score + highest_score + print_all_students +output: | + Average Score: 77.5 + Highest Score: ['Grace'] + Grace: 90 + Eve: 65 From b742bf06f3e7bf1db05652b5783992a0912dbb0d Mon Sep 17 00:00:00 2001 From: SHATAKSHI MITTRA Date: Wed, 8 Jan 2025 11:57:28 +0530 Subject: [PATCH 5/5] Replaces empty file with correct version --- questions-by-shatakshi/data_processing.proq | 108 ++++++++++++++++++++ 1 file changed, 108 insertions(+) diff --git a/questions-by-shatakshi/data_processing.proq b/questions-by-shatakshi/data_processing.proq index e69de29..dbd7154 100644 --- a/questions-by-shatakshi/data_processing.proq +++ b/questions-by-shatakshi/data_processing.proq @@ -0,0 +1,108 @@ +--- +title: Process and Filter Numbers +tags: ['list', 'comprehension', 'filter', 'aggregation', 'function'] +--- + +### Problem Statement +Write a function `process_numbers` that takes a list of integers and a filter threshold as input, and performs the following operations: +1. Multiply each number in the list by 2. +2. Filter out numbers greater than the `filter_threshold` after multiplication. +3. Calculate the sum of the filtered numbers. + +The function should return a tuple containing: +- A list of the doubled numbers. +- A list of the filtered numbers. +- The sum of the filtered numbers. + +### Input +1. `numbers` - a list of integers. +2. `filter_threshold` - an integer specifying the threshold for filtering. + +### Output +A tuple with: +1. A list of doubled numbers. +2. A list of filtered numbers. +3. The sum of the filtered numbers. + +### Constraints +- The input list will contain at least 1 and at most 100 integers. +- Each integer will be in the range [-10^6, 10^6]. +- The filter threshold will be an integer in the range [-10^6, 10^6]. + +### Solution + +```python +# Driver Code (to handle I/O) +def driver_function(): + # Accepting inputs from the user or from test cases + numbers = eval(input()) # Read the list of numbers + filter_threshold = int(input()) # Read the threshold value + + # Calling the solution function and printing the result + result = process_numbers(numbers, filter_threshold) + print(result) + +# Template Function that needs to be implemented by the student + + +### Test Cases + +#### Public Test Cases + +## Input 1 +[1, 2, 3, 4, 5] +2 + +## Output 1 +([2, 4, 6, 8, 10], [4, 6, 8, 10], 28) + +## Input 2 +[10, 20, 30, 40, 50] +25 + +## Output 2 +([20, 40, 60, 80, 100], [40, 60, 80, 100], 280) + +#### Private Test Cases + +## Input 1 +[100, 200, 300, 400, 500] +150 + +## Output 1 +([200, 400, 600, 800, 1000], [200, 400, 600, 800, 1000], 3000) + +## Input 2 +[500, 400, 300, 200, 100] +250 + +## Output 2 +([1000, 800, 600, 400, 200], [1000, 800, 600, 400], 2800)