From 9843c467d9b89dd256eb0852492b43c99472f107 Mon Sep 17 00:00:00 2001 From: faguncb Date: Tue, 16 Dec 2025 00:07:57 +0530 Subject: [PATCH 1/4] Fibonnaci series generator --- programs/mcq/fibonacci_series_generator.py | 40 ++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 programs/mcq/fibonacci_series_generator.py diff --git a/programs/mcq/fibonacci_series_generator.py b/programs/mcq/fibonacci_series_generator.py new file mode 100644 index 0000000..a0a889b --- /dev/null +++ b/programs/mcq/fibonacci_series_generator.py @@ -0,0 +1,40 @@ +# Print header +print("Fibonacci Sequence Generator") +print("=============================\n") + +# Define the Fibonacci generator function +# (use yield to make it a generator) +def fibonacci_generator(n): + # Initialize the first two Fibonacci numbers + a = 0 + b = 1 + + # Yield the first number + yield a + # Yield the second number + yield b + + # Generate remaining Fibonacci numbers + # (loop to generate the rest of the sequence) + for i in range(n - 2): + # Calculate next Fibonacci number (sum of previous two) + next_num = a + b + # Yield the next number + yield next_num + # Update the previous two numbers for next iteration + a = b + b = next_num + +# Ask user how many Fibonacci numbers to generate +count = int(input("How many Fibonacci numbers do you want? ")) + +# Print generation message +print("\nGenerating Fibonacci sequence...\n") + +# Use the generator to produce and display Fibonacci numbers +# (loop through the generator and print each number) +for index, fib_num in enumerate(fibonacci_generator(count), start=1): + print(f"Fibonacci #{index}: {fib_num}") + +# Print completion message +print("\nGeneration complete!") From ddb45b41a5d047a5a43fd8ac5bff10a756d0a6b1 Mon Sep 17 00:00:00 2001 From: faguncb Date: Tue, 16 Dec 2025 00:41:43 +0530 Subject: [PATCH 2/4] Calculator implementation --- programs/mcq/manual_calculations.py | 18 ++++++++++++++++++ programs/mcq/statistics_module.py | 16 ++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 programs/mcq/manual_calculations.py create mode 100644 programs/mcq/statistics_module.py diff --git a/programs/mcq/manual_calculations.py b/programs/mcq/manual_calculations.py new file mode 100644 index 0000000..f6f2eb5 --- /dev/null +++ b/programs/mcq/manual_calculations.py @@ -0,0 +1,18 @@ +#@title Author's Solution 1 (Manual Calculations) {"display-mode":"form"} +def number_stats(nums): + avg = sum(nums) / len(nums) + var = sum((x - avg) ** 2 for x in nums) / len(nums) + std = var ** 0.5 + return min(nums), max(nums), avg, var, std + +nums = list(map(float, input("Enter numbers separated by commas: ").split(","))) +mn, mx, avg, var, std = number_stats(nums) + +print("\nNumber Statistics Report") +print("------------------------") +print(f"Count: {len(nums)}") +print(f"Min: {mn}") +print(f"Max: {mx}") +print(f"Average: {avg:.2f}") +print(f"Variance: {var:.2f}") +print(f"Standard Deviation: {std:.2f}") \ No newline at end of file diff --git a/programs/mcq/statistics_module.py b/programs/mcq/statistics_module.py new file mode 100644 index 0000000..e193800 --- /dev/null +++ b/programs/mcq/statistics_module.py @@ -0,0 +1,16 @@ +#@title Author's Solution 2 (Using statistics module) {"display-mode":"form"} +import statistics + +nums = list(map(float, input("Enter numbers separated by commas: ").split(","))) +avg = statistics.mean(nums) +var = statistics.pvariance(nums) +std = statistics.pstdev(nums) + +print("\nNumber Statistics Report") +print("------------------------") +print(f"Count: {len(nums)}") +print(f"Min: {min(nums)}") +print(f"Max: {max(nums)}") +print(f"Average: {avg:.2f}") +print(f"Variance: {var:.2f}") +print(f"Standard Deviation: {std:.2f}") \ No newline at end of file From 9f061d36d8b690da98b29ede6bbd5a2ac1281402 Mon Sep 17 00:00:00 2001 From: faguncb Date: Tue, 16 Dec 2025 00:42:35 +0530 Subject: [PATCH 3/4] Added .gitignore file --- .gitignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..485dee6 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.idea From 9d5e8f8ca57913909539c5a6ad281a1c914f5170 Mon Sep 17 00:00:00 2001 From: faguncb Date: Mon, 12 Jan 2026 21:36:14 +0530 Subject: [PATCH 4/4] Added grade calculator program --- grade_calculator.py | 71 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 grade_calculator.py diff --git a/grade_calculator.py b/grade_calculator.py new file mode 100644 index 0000000..2c76a8b --- /dev/null +++ b/grade_calculator.py @@ -0,0 +1,71 @@ +# Print header +print("Grade Calculator") +print("================\n") + +# Function to calculate average score +# (takes a list of scores, returns the average) +def calculate_average(scores): + average = sum(scores) / len(scores) + return average + +# Function to convert numeric score to letter grade +# (takes a score number, returns letter A-F) +def get_letter_grade(score): + if score >= 90: + return "A" + elif score >= 80: + return "B" + elif score >= 70: + return "C" + elif score >= 60: + return "D" + else: + return "F" + +# Function to determine pass/fail status +# (takes a score, returns "PASS" or "FAIL") +def get_status(score): + if score >= 60: + return "PASS" + else: + return "FAIL" + +# Function to generate the complete report +# (takes name and scores, calls other functions, prints report) +def generate_report(name, scores): + # Calculate average using the calculate_average function + average = calculate_average(scores) + + # Get letter grade using the get_letter_grade function + letter_grade = get_letter_grade(average) + + # Get pass/fail status using the get_status function + status = get_status(average) + + # Print the report + print("\nStudent Grade Report") + print("====================") + print(f"Name: {name}\n") + print(f"Test Scores: {', '.join(map(str, scores))}") + print(f"Average Score: {average:.1f}") + print(f"Letter Grade: {letter_grade}") + print(f"Status: {status}\n") + +# Get user input +# (student name) +name = input("Enter student name: ") + +# Get test scores +# (comma-separated string, convert to list of integers) +scores_input = input("\nEnter test scores (comma-separated): ") +scores = [int(score.strip()) for score in scores_input.split(',')] + +# Print processing message +print("\nProcessing grades...") + +# Generate the report +# (call the generate_report function) +generate_report(name, scores) + +# Print completion message +print("Report generated successfully!")