From d5b2e3c2e8a9b2ccc7c9515ee5fbcdbfc116ff76 Mon Sep 17 00:00:00 2001 From: Neil Date: Tue, 24 Jun 2025 18:10:10 +0530 Subject: [PATCH] refactor: change project.py to align with assessment policy Remove old outputs and programs Change project.py to not include outputs in master output file --- practical-file/outputs.txt | 404 ------------------ practical-file/outputs/question_01_output.txt | 13 - practical-file/outputs/question_02_output.txt | 14 - practical-file/outputs/question_03_output.txt | 15 - practical-file/outputs/question_04_output.txt | 13 - practical-file/outputs/question_05_output.txt | 15 - practical-file/outputs/question_06_output.txt | 26 -- practical-file/outputs/question_07_output.txt | 34 -- practical-file/outputs/question_08_output.txt | 18 - practical-file/outputs/question_09_output.txt | 23 - practical-file/outputs/question_10_output.txt | 38 -- practical-file/outputs/question_11_output.txt | 29 -- practical-file/outputs/question_12_output.txt | 22 - practical-file/outputs/question_13_output.txt | 18 - practical-file/outputs/question_14_output.txt | 27 -- practical-file/outputs/question_15_output.txt | 20 - practical-file/outputs/question_16_output.txt | 25 -- practical-file/outputs/question_17_output.txt | 21 - practical-file/outputs/question_18_output.txt | 17 - practical-file/project.py | 23 - practical-file/questions/question_01.py | 7 - .../questions/question_01_output.txt | 13 - practical-file/questions/question_02.py | 8 - .../questions/question_02_output.txt | 14 - practical-file/questions/question_03.py | 8 - .../questions/question_03_output.txt | 15 - practical-file/questions/question_04.py | 7 - .../questions/question_04_output.txt | 13 - practical-file/questions/question_05.py | 8 - .../questions/question_05_output.txt | 15 - practical-file/questions/question_06.py | 18 - .../questions/question_06_output.txt | 26 -- practical-file/questions/question_07.py | 25 -- .../questions/question_07_output.txt | 34 -- practical-file/questions/question_08.py | 11 - .../questions/question_08_output.txt | 18 - practical-file/questions/question_09.py | 15 - .../questions/question_09_output.txt | 23 - practical-file/questions/question_10.py | 29 -- .../questions/question_10_output.txt | 38 -- practical-file/questions/question_11.py | 17 - .../questions/question_11_output.txt | 29 -- practical-file/questions/question_12.py | 13 - .../questions/question_12_output.txt | 22 - practical-file/questions/question_13.py | 10 - .../questions/question_13_output.txt | 18 - practical-file/questions/question_14.py | 16 - .../questions/question_14_output.txt | 27 -- practical-file/questions/question_15.py | 12 - .../questions/question_15_output.txt | 20 - practical-file/questions/question_16.py | 15 - .../questions/question_16_output.txt | 25 -- practical-file/questions/question_17.py | 14 - .../questions/question_17_output.txt | 21 - practical-file/questions/question_18.py | 11 - .../questions/question_18_output.txt | 17 - 56 files changed, 1447 deletions(-) delete mode 100644 practical-file/outputs/question_01_output.txt delete mode 100644 practical-file/outputs/question_02_output.txt delete mode 100644 practical-file/outputs/question_03_output.txt delete mode 100644 practical-file/outputs/question_04_output.txt delete mode 100644 practical-file/outputs/question_05_output.txt delete mode 100644 practical-file/outputs/question_06_output.txt delete mode 100644 practical-file/outputs/question_07_output.txt delete mode 100644 practical-file/outputs/question_08_output.txt delete mode 100644 practical-file/outputs/question_09_output.txt delete mode 100644 practical-file/outputs/question_10_output.txt delete mode 100644 practical-file/outputs/question_11_output.txt delete mode 100644 practical-file/outputs/question_12_output.txt delete mode 100644 practical-file/outputs/question_13_output.txt delete mode 100644 practical-file/outputs/question_14_output.txt delete mode 100644 practical-file/outputs/question_15_output.txt delete mode 100644 practical-file/outputs/question_16_output.txt delete mode 100644 practical-file/outputs/question_17_output.txt delete mode 100644 practical-file/outputs/question_18_output.txt delete mode 100644 practical-file/questions/question_01.py delete mode 100644 practical-file/questions/question_01_output.txt delete mode 100644 practical-file/questions/question_02.py delete mode 100644 practical-file/questions/question_02_output.txt delete mode 100644 practical-file/questions/question_03.py delete mode 100644 practical-file/questions/question_03_output.txt delete mode 100644 practical-file/questions/question_04.py delete mode 100644 practical-file/questions/question_04_output.txt delete mode 100644 practical-file/questions/question_05.py delete mode 100644 practical-file/questions/question_05_output.txt delete mode 100644 practical-file/questions/question_06.py delete mode 100644 practical-file/questions/question_06_output.txt delete mode 100644 practical-file/questions/question_07.py delete mode 100644 practical-file/questions/question_07_output.txt delete mode 100644 practical-file/questions/question_08.py delete mode 100644 practical-file/questions/question_08_output.txt delete mode 100644 practical-file/questions/question_09.py delete mode 100644 practical-file/questions/question_09_output.txt delete mode 100644 practical-file/questions/question_10.py delete mode 100644 practical-file/questions/question_10_output.txt delete mode 100644 practical-file/questions/question_11.py delete mode 100644 practical-file/questions/question_11_output.txt delete mode 100644 practical-file/questions/question_12.py delete mode 100644 practical-file/questions/question_12_output.txt delete mode 100644 practical-file/questions/question_13.py delete mode 100644 practical-file/questions/question_13_output.txt delete mode 100644 practical-file/questions/question_14.py delete mode 100644 practical-file/questions/question_14_output.txt delete mode 100644 practical-file/questions/question_15.py delete mode 100644 practical-file/questions/question_15_output.txt delete mode 100644 practical-file/questions/question_16.py delete mode 100644 practical-file/questions/question_16_output.txt delete mode 100644 practical-file/questions/question_17.py delete mode 100644 practical-file/questions/question_17_output.txt delete mode 100644 practical-file/questions/question_18.py delete mode 100644 practical-file/questions/question_18_output.txt diff --git a/practical-file/outputs.txt b/practical-file/outputs.txt index 83dc8a3..e69de29 100644 --- a/practical-file/outputs.txt +++ b/practical-file/outputs.txt @@ -1,404 +0,0 @@ -Question 01: Write a Python program to accept two integers and print their sum. - -Answer: -def main(int1: int, int2: int) -> int: - print(f"{int1} + {int2} = {int1 + int2}") - -if __name__ == '__main__': - main(2, 2) - - -Output: -2 + 2 = 4 - - -Question 02: Write a Python program that accepts the radius of a circle and prints its area. - -Answer: -def main(radius: int): - print(f"Area: {3.14 * radius * radius}") - # or you can do 3.13 * radius ** 2 - -if __name__ == '__main__': - main(7) - - -Output: -Area: 153.86 - - -Question 03: Write a Python program to accept the length and width of a rectangle and compute its perimeter and area. - -Answer: -def main(length: int, width: int) -> None: - print("Perimeter:", 2 * (length + width)) - print("Area:", length * width) - -if __name__ == '__main__': - main(10, 10) - - -Output: -Perimeter: 40 -Area: 100 - - -Question 04: Write a Python program to compute simple interest for a given principal amount, time, and rate of interest. - -Answer: -def main(principal: int, time: int, rate: float) -> None: - print(f"Simple Interest: {principal * rate * time / 100}") - -if __name__ == '__main__': - main(10000, 10, 5.0) - - -Output: -Simple Interest: 5000.0 - - -Question 05: Write a Python program to find whether a given number is even or odd. - -Answer: -def main(num: int) -> None: - print("Even" if num % 2 == 0 else "Odd") - -if __name__ == '__main__': - main(2) - main(3) - - -Output: -Even -Odd - - -Question 06: Write a Python program to find the largest among three numbers. - -Answer: -def main(numbers: list[int]) -> None: - if not numbers: - print("No numbers provided.") - return - - largest = numbers[0] - for num in numbers: - if num > largest: - largest = num - - print("Largest number:", largest) - -if __name__ == '__main__': - main([1, 2, 3]) - main([3, 1, 2]) - main([5, 10, 15, 20]) - - -Output: -Largest number: 3 -Largest number: 3 -Largest number: 20 - - -Question 07: Write a Python program to perform arithmetic calculation. The program should accept two operands and an operator, then display the result. - -Answer: -def main(num1: float, num2: float, operator: str) -> None: - if operator == '+': - result = num1 + num2 - elif operator == '-': - result = num1 - num2 - elif operator == '*': - result = num1 * num2 - elif operator == '/': - if num2 == 0: - print("Error: Division by zero") - raise ZeroDivisionError - result = num1 / num2 - else: - print("Error: Invalid operator") - raise ValueError("Invalid operator. Use +, -, *, or /.") - - print(f"Result: {result}") - -if __name__ == '__main__': - main(10, 5, '+') - main(10, 5, '-') - main(10, 5, '*') - main(10, 5, '/') - - -Output: -Result: 15 -Result: 5 -Result: 50 -Result: 2.0 - - -Question 08: Write a Python program to check whether a given year is a leap year or not. - -Answer: -def main(year: int) -> None: - if (year % 4 == 0 and year % 100 != 0) or (year % 400 == 0): - print(f"{year} is a leap year.") - else: - print(f"{year} is not a leap year.") - -if __name__ == '__main__': - main(2020) - main(2021) - - -Output: -2020 is a leap year. -2021 is not a leap year. - - -Question 09: Write a Python program to check if a number is positive, negative, or zero. - -Answer: -def main(num: int) -> None: - if num > 0: - print(f"{num} is positive.") - elif num < 0: - print(f"{num} is negative.") - else: - print("The number is zero.") - - -if __name__ == '__main__': - main(10) - main(-5) - main(0) - - -Output: -10 is positive. --5 is negative. -The number is zero. - - -Question 10: Write a Python program to accept marks of a student and print the grade according to the given criteria: - -Answer: -- Marks ≥ 90: A -- Marks ≥ 80: B -- Marks ≥ 70: C -- Marks ≥ 60: D -- Otherwise: Fail -""" - -def main(marks: int) -> None: - if marks >= 90: - grade = 'A' - elif marks >= 80: - grade = 'B' - elif marks >= 70: - grade = 'C' - elif marks >= 60: - grade = 'D' - else: - grade = 'Fail' - - print(f"Grade: {grade}") - -if __name__ == '__main__': - main(95) - main(85) - main(75) - main(65) - main(55) - -Output: -Grade: A -Grade: B -Grade: C -Grade: D -Grade: Fail - - -Question 11: Write a Python program to check whether a given character is a vowel or consonant. - -Answer: -def main(char: str) -> None: - vowels = 'aeiou' - if char.lower() in vowels: - print(f"{char} is a vowel.") - elif char.isalpha(): - print(f"{char} is a consonant.") - else: - raise ValueError("Invalid input. Please enter an alphabetic character.") - - -if __name__ == '__main__': - main('a') - main('b') - main('A') - main('1') # also works with a int - - -Output: -Traceback (most recent call last): - File "\\nas.local\share\data\school\Grade 11 CS\Practical File\question_11.py", line 17, in - main('1') # also works with a int - ^^^^^^^^^ - File "\\nas.local\share\data\school\Grade 11 CS\Practical File\question_11.py", line 10, in main - raise ValueError("Invalid input. Please enter an alphabetic character.") -ValueError: Invalid input. Please enter an alphabetic character. - - -Question 12: Write a Python program to check whether a number is divisible by both 5 and 11. - -Answer: -def main(num: int) -> None: - if num % 5 == 0 and num % 11 == 0: - print(f"{num} is divisible by both 5 and 11.") - else: - print(f"{num} is not divisible by both 5 and 11.") - -if __name__ == '__main__': - main(55) - main(22) - main(10) - main(121) - - -Output: -55 is divisible by both 5 and 11. -22 is not divisible by both 5 and 11. -10 is not divisible by both 5 and 11. -121 is not divisible by both 5 and 11. - - -Question 13: Write a Python program to find the absolute value of a number. - -Answer: -def main(num: float) -> None: - abs_value = abs(num) - print(f"The absolute value of {num} is {abs_value}") - -if __name__ == '__main__': - main(-5.5) - main(3.14) - main(0) - - -Output: -The absolute value of -5.5 is 5.5 -The absolute value of 3.14 is 3.14 -The absolute value of 0 is 0 - - -Question 14: Write a Python program to check if a character is an uppercase or lowercase letter. - -Answer: -def main(char: str) -> None: - if char.isupper(): - print(f"{char} is an uppercase letter.") - elif char.islower(): - print(f"{char} is a lowercase letter.") - else: - raise ValueError("Invalid input. Please enter an alphabetic character.") - -if __name__ == '__main__': - main('A') - main('a') - main('B') - main('b') - main('1') # also works with a int - -Output: -Traceback (most recent call last): - File "\\nas.local\share\data\school\Grade 11 CS\Practical File\question_14.py", line 16, in - main('1') # also works with a int - ^^^^^^^^^ - File "\\nas.local\share\data\school\Grade 11 CS\Practical File\question_14.py", line 9, in main - raise ValueError("Invalid input. Please enter an alphabetic character.") -ValueError: Invalid input. Please enter an alphabetic character. - - -Question 15: Write a Python program to accept age and check whether the person is eligible to vote (18 or older). - -Answer: -def main(age: int) -> None: - if age >= 18: - print(f"Age {age} is eligible to vote.") - else: - print(f"Age {age} is not eligible to vote.") - -if __name__ == '__main__': - main(18) - main(17) - main(20) - - -Output: -Age 18 is eligible to vote. -Age 17 is not eligible to vote. -Age 20 is eligible to vote. - - -Question 16: Write a Python program to accept three sides and check whether they form a valid triangle. - -Answer: -def main(sides: tuple[int, int, int]) -> None: - a, b, c = sides - if a + b > c and a + c > b and b + c > a: - print(f"The sides {sides} form a valid triangle.") - else: - print(f"The sides {sides} do not form a valid triangle.") - -if __name__ == '__main__': - main((3, 4, 5)) - main((1, 2, 3)) - main((5, 12, 13)) - main((7, 10, 5)) - main((1, 1, 2)) - - -Output: -The sides (3, 4, 5) form a valid triangle. -The sides (1, 2, 3) do not form a valid triangle. -The sides (5, 12, 13) form a valid triangle. -The sides (7, 10, 5) form a valid triangle. -The sides (1, 1, 2) do not form a valid triangle. - - -Question 17: Write a Python program to accept cost price and selling price, then print whether there is profit, loss, or no gain. - -Answer: -def main(cost_price: float, selling_price: float) -> None: - if selling_price > cost_price: - print(f"Profit: {selling_price - cost_price}") - elif selling_price < cost_price: - print(f"Loss: {cost_price - selling_price}") - else: - print("No gain, no loss.") - -if __name__ == '__main__': - main(100.0, 120.0) - main(150.0, 130.0) - main(200.0, 200.0) - -Output: -Profit: 20.0 -Loss: 20.0 -No gain, no loss. - - -Question 18: Write a Python program to accept two numbers and check whether they are equal or not - -Answer: -def main(num1: int, num2: int) -> None: - if num1 == num2: - print(f"{num1} and {num2} are equal.") - else: - print(f"{num1} and {num2} are not equal.") - -if __name__ == '__main__': - main(10, 10) - main(10, 20) - -Output: -10 and 10 are equal. -10 and 20 are not equal. diff --git a/practical-file/outputs/question_01_output.txt b/practical-file/outputs/question_01_output.txt deleted file mode 100644 index 65cb1d5..0000000 --- a/practical-file/outputs/question_01_output.txt +++ /dev/null @@ -1,13 +0,0 @@ -Question 01: -Write a Python program to accept two integers and print their sum. - -Answer: -def main(int1: int, int2: int) -> int: - print(f"{int1} + {int2} = {int1 + int2}") - -if __name__ == '__main__': - main(2, 2) - - -Output: -2 + 2 = 4 diff --git a/practical-file/outputs/question_02_output.txt b/practical-file/outputs/question_02_output.txt deleted file mode 100644 index 34ae01f..0000000 --- a/practical-file/outputs/question_02_output.txt +++ /dev/null @@ -1,14 +0,0 @@ -Question 02: -Write a Python program that accepts the radius of a circle and prints its area. - -Answer: -def main(radius: int): - print(f"Area: {3.14 * radius * radius}") - # or you can do 3.13 * radius ** 2 - -if __name__ == '__main__': - main(7) - - -Output: -Area: 153.86 diff --git a/practical-file/outputs/question_03_output.txt b/practical-file/outputs/question_03_output.txt deleted file mode 100644 index 391aec0..0000000 --- a/practical-file/outputs/question_03_output.txt +++ /dev/null @@ -1,15 +0,0 @@ -Question 03: -Write a Python program to accept the length and width of a rectangle and compute its perimeter and area. - -Answer: -def main(length: int, width: int) -> None: - print("Perimeter:", 2 * (length + width)) - print("Area:", length * width) - -if __name__ == '__main__': - main(10, 10) - - -Output: -Perimeter: 40 -Area: 100 diff --git a/practical-file/outputs/question_04_output.txt b/practical-file/outputs/question_04_output.txt deleted file mode 100644 index 21fea65..0000000 --- a/practical-file/outputs/question_04_output.txt +++ /dev/null @@ -1,13 +0,0 @@ -Question 04: -Write a Python program to compute simple interest for a given principal amount, time, and rate of interest. - -Answer: -def main(principal: int, time: int, rate: float) -> None: - print(f"Simple Interest: {principal * rate * time / 100}") - -if __name__ == '__main__': - main(10000, 10, 5.0) - - -Output: -Simple Interest: 5000.0 diff --git a/practical-file/outputs/question_05_output.txt b/practical-file/outputs/question_05_output.txt deleted file mode 100644 index a8e0387..0000000 --- a/practical-file/outputs/question_05_output.txt +++ /dev/null @@ -1,15 +0,0 @@ -Question 05: -Write a Python program to find whether a given number is even or odd. - -Answer: -def main(num: int) -> None: - print("Even" if num % 2 == 0 else "Odd") - -if __name__ == '__main__': - main(2) - main(3) - - -Output: -Even -Odd diff --git a/practical-file/outputs/question_06_output.txt b/practical-file/outputs/question_06_output.txt deleted file mode 100644 index 7d172a1..0000000 --- a/practical-file/outputs/question_06_output.txt +++ /dev/null @@ -1,26 +0,0 @@ -Question 06: -Write a Python program to find the largest among three numbers. - -Answer: -def main(numbers: list[int]) -> None: - if not numbers: - print("No numbers provided.") - return - - largest = numbers[0] - for num in numbers: - if num > largest: - largest = num - - print("Largest number:", largest) - -if __name__ == '__main__': - main([1, 2, 3]) - main([3, 1, 2]) - main([5, 10, 15, 20]) - - -Output: -Largest number: 3 -Largest number: 3 -Largest number: 20 diff --git a/practical-file/outputs/question_07_output.txt b/practical-file/outputs/question_07_output.txt deleted file mode 100644 index c55a0ec..0000000 --- a/practical-file/outputs/question_07_output.txt +++ /dev/null @@ -1,34 +0,0 @@ -Question 07: -Write a Python program to perform arithmetic calculation. The program should accept two operands and an operator, then display the result. - -Answer: -def main(num1: float, num2: float, operator: str) -> None: - if operator == '+': - result = num1 + num2 - elif operator == '-': - result = num1 - num2 - elif operator == '*': - result = num1 * num2 - elif operator == '/': - if num2 == 0: - print("Error: Division by zero") - raise ZeroDivisionError - result = num1 / num2 - else: - print("Error: Invalid operator") - raise ValueError("Invalid operator. Use +, -, *, or /.") - - print(f"Result: {result}") - -if __name__ == '__main__': - main(10, 5, '+') - main(10, 5, '-') - main(10, 5, '*') - main(10, 5, '/') - - -Output: -Result: 15 -Result: 5 -Result: 50 -Result: 2.0 diff --git a/practical-file/outputs/question_08_output.txt b/practical-file/outputs/question_08_output.txt deleted file mode 100644 index a61dea2..0000000 --- a/practical-file/outputs/question_08_output.txt +++ /dev/null @@ -1,18 +0,0 @@ -Question 08: -Write a Python program to check whether a given year is a leap year or not. - -Answer: -def main(year: int) -> None: - if (year % 4 == 0 and year % 100 != 0) or (year % 400 == 0): - print(f"{year} is a leap year.") - else: - print(f"{year} is not a leap year.") - -if __name__ == '__main__': - main(2020) - main(2021) - - -Output: -2020 is a leap year. -2021 is not a leap year. diff --git a/practical-file/outputs/question_09_output.txt b/practical-file/outputs/question_09_output.txt deleted file mode 100644 index d973aff..0000000 --- a/practical-file/outputs/question_09_output.txt +++ /dev/null @@ -1,23 +0,0 @@ -Question 09: -Write a Python program to check if a number is positive, negative, or zero. - -Answer: -def main(num: int) -> None: - if num > 0: - print(f"{num} is positive.") - elif num < 0: - print(f"{num} is negative.") - else: - print("The number is zero.") - - -if __name__ == '__main__': - main(10) - main(-5) - main(0) - - -Output: -10 is positive. --5 is negative. -The number is zero. diff --git a/practical-file/outputs/question_10_output.txt b/practical-file/outputs/question_10_output.txt deleted file mode 100644 index d3270af..0000000 --- a/practical-file/outputs/question_10_output.txt +++ /dev/null @@ -1,38 +0,0 @@ -Question 10: -Write a Python program to accept marks of a student and print the grade according to the given criteria: - -Answer: -- Marks ≥ 90: A -- Marks ≥ 80: B -- Marks ≥ 70: C -- Marks ≥ 60: D -- Otherwise: Fail -""" - -def main(marks: int) -> None: - if marks >= 90: - grade = 'A' - elif marks >= 80: - grade = 'B' - elif marks >= 70: - grade = 'C' - elif marks >= 60: - grade = 'D' - else: - grade = 'Fail' - - print(f"Grade: {grade}") - -if __name__ == '__main__': - main(95) - main(85) - main(75) - main(65) - main(55) - -Output: -Grade: A -Grade: B -Grade: C -Grade: D -Grade: Fail diff --git a/practical-file/outputs/question_11_output.txt b/practical-file/outputs/question_11_output.txt deleted file mode 100644 index b4d80a4..0000000 --- a/practical-file/outputs/question_11_output.txt +++ /dev/null @@ -1,29 +0,0 @@ -Question 11: -Write a Python program to check whether a given character is a vowel or consonant. - -Answer: -def main(char: str) -> None: - vowels = 'aeiou' - if char.lower() in vowels: - print(f"{char} is a vowel.") - elif char.isalpha(): - print(f"{char} is a consonant.") - else: - raise ValueError("Invalid input. Please enter an alphabetic character.") - - -if __name__ == '__main__': - main('a') - main('b') - main('A') - main('1') # also works with a int - - -Output: -Traceback (most recent call last): - File "\\homeassistant.local\share\data\school\Grade 11 CS\Practical File\question_11.py", line 17, in - main('1') # also works with a int - ^^^^^^^^^ - File "\\homeassistant.local\share\data\school\Grade 11 CS\Practical File\question_11.py", line 10, in main - raise ValueError("Invalid input. Please enter an alphabetic character.") -ValueError: Invalid input. Please enter an alphabetic character. diff --git a/practical-file/outputs/question_12_output.txt b/practical-file/outputs/question_12_output.txt deleted file mode 100644 index b401f48..0000000 --- a/practical-file/outputs/question_12_output.txt +++ /dev/null @@ -1,22 +0,0 @@ -Question 12: -Write a Python program to check whether a number is divisible by both 5 and 11. - -Answer: -def main(num: int) -> None: - if num % 5 == 0 and num % 11 == 0: - print(f"{num} is divisible by both 5 and 11.") - else: - print(f"{num} is not divisible by both 5 and 11.") - -if __name__ == '__main__': - main(55) - main(22) - main(10) - main(121) - - -Output: -55 is divisible by both 5 and 11. -22 is not divisible by both 5 and 11. -10 is not divisible by both 5 and 11. -121 is not divisible by both 5 and 11. diff --git a/practical-file/outputs/question_13_output.txt b/practical-file/outputs/question_13_output.txt deleted file mode 100644 index 4da879f..0000000 --- a/practical-file/outputs/question_13_output.txt +++ /dev/null @@ -1,18 +0,0 @@ -Question 13: -Write a Python program to find the absolute value of a number. - -Answer: -def main(num: float) -> None: - abs_value = abs(num) - print(f"The absolute value of {num} is {abs_value}") - -if __name__ == '__main__': - main(-5.5) - main(3.14) - main(0) - - -Output: -The absolute value of -5.5 is 5.5 -The absolute value of 3.14 is 3.14 -The absolute value of 0 is 0 diff --git a/practical-file/outputs/question_14_output.txt b/practical-file/outputs/question_14_output.txt deleted file mode 100644 index ab94cd5..0000000 --- a/practical-file/outputs/question_14_output.txt +++ /dev/null @@ -1,27 +0,0 @@ -Question 14: -Write a Python program to check if a character is an uppercase or lowercase letter. - -Answer: -def main(char: str) -> None: - if char.isupper(): - print(f"{char} is an uppercase letter.") - elif char.islower(): - print(f"{char} is a lowercase letter.") - else: - raise ValueError("Invalid input. Please enter an alphabetic character.") - -if __name__ == '__main__': - main('A') - main('a') - main('B') - main('b') - main('1') # also works with a int - -Output: -Traceback (most recent call last): - File "\\homeassistant.local\share\data\school\Grade 11 CS\Practical File\question_14.py", line 16, in - main('1') # also works with a int - ^^^^^^^^^ - File "\\homeassistant.local\share\data\school\Grade 11 CS\Practical File\question_14.py", line 9, in main - raise ValueError("Invalid input. Please enter an alphabetic character.") -ValueError: Invalid input. Please enter an alphabetic character. diff --git a/practical-file/outputs/question_15_output.txt b/practical-file/outputs/question_15_output.txt deleted file mode 100644 index 01a2ef9..0000000 --- a/practical-file/outputs/question_15_output.txt +++ /dev/null @@ -1,20 +0,0 @@ -Question 15: -Write a Python program to accept age and check whether the person is eligible to vote (18 or older). - -Answer: -def main(age: int) -> None: - if age >= 18: - print(f"Age {age} is eligible to vote.") - else: - print(f"Age {age} is not eligible to vote.") - -if __name__ == '__main__': - main(18) - main(17) - main(20) - - -Output: -Age 18 is eligible to vote. -Age 17 is not eligible to vote. -Age 20 is eligible to vote. diff --git a/practical-file/outputs/question_16_output.txt b/practical-file/outputs/question_16_output.txt deleted file mode 100644 index c70c567..0000000 --- a/practical-file/outputs/question_16_output.txt +++ /dev/null @@ -1,25 +0,0 @@ -Question 16: -Write a Python program to accept three sides and check whether they form a valid triangle. - -Answer: -def main(sides: tuple[int, int, int]) -> None: - a, b, c = sides - if a + b > c and a + c > b and b + c > a: - print(f"The sides {sides} form a valid triangle.") - else: - print(f"The sides {sides} do not form a valid triangle.") - -if __name__ == '__main__': - main((3, 4, 5)) - main((1, 2, 3)) - main((5, 12, 13)) - main((7, 10, 5)) - main((1, 1, 2)) - - -Output: -The sides (3, 4, 5) form a valid triangle. -The sides (1, 2, 3) do not form a valid triangle. -The sides (5, 12, 13) form a valid triangle. -The sides (7, 10, 5) form a valid triangle. -The sides (1, 1, 2) do not form a valid triangle. diff --git a/practical-file/outputs/question_17_output.txt b/practical-file/outputs/question_17_output.txt deleted file mode 100644 index 63d23df..0000000 --- a/practical-file/outputs/question_17_output.txt +++ /dev/null @@ -1,21 +0,0 @@ -Question 17: -Write a Python program to accept cost price and selling price, then print whether there is profit, loss, or no gain. - -Answer: -def main(cost_price: float, selling_price: float) -> None: - if selling_price > cost_price: - print(f"Profit: {selling_price - cost_price}") - elif selling_price < cost_price: - print(f"Loss: {cost_price - selling_price}") - else: - print("No gain, no loss.") - -if __name__ == '__main__': - main(100.0, 120.0) - main(150.0, 130.0) - main(200.0, 200.0) - -Output: -Profit: 20.0 -Loss: 20.0 -No gain, no loss. diff --git a/practical-file/outputs/question_18_output.txt b/practical-file/outputs/question_18_output.txt deleted file mode 100644 index 3701b30..0000000 --- a/practical-file/outputs/question_18_output.txt +++ /dev/null @@ -1,17 +0,0 @@ -Question 18: -Write a Python program to accept two numbers and check whether they are equal or not - -Answer: -def main(num1: int, num2: int) -> None: - if num1 == num2: - print(f"{num1} and {num2} are equal.") - else: - print(f"{num1} and {num2} are not equal.") - -if __name__ == '__main__': - main(10, 10) - main(10, 20) - -Output: -10 and 10 are equal. -10 and 20 are not equal. diff --git a/practical-file/project.py b/practical-file/project.py index 7616b09..6fc0abd 100644 --- a/practical-file/project.py +++ b/practical-file/project.py @@ -27,30 +27,9 @@ def create_question_file(question_text, question_num): with open(filename, 'w') as f: f.write(f"# Question: {question_text}\n\n") f.write("") - f.write("def main():\n") - f.write(" pass\n\n") - f.write("") - f.write("if __name__ == '__main__':\n") - f.write(" main()\n") return filename -def open_in_vscode(filename): - try: - vscode_commands = ['code', 'code-insiders', 'codium'] - - for cmd in vscode_commands: - try: - subprocess.run([cmd, filename], check=True) - return True - except (subprocess.CalledProcessError, FileNotFoundError): - continue - - return False - - except Exception as e: - return False - def wait_for_completion(): input("Press Enter when the question is done: ") return True @@ -104,7 +83,6 @@ def append_to_master_file(question_text, question_num, code_content, execution_o f.write(f"Question {question_num:02d}: {question_text}\n\n") f.write("Answer:\n") f.write(code_content) - f.write("\n\nOutput:\n") if execution_output['returncode'] == 0: if execution_output['stdout']: @@ -149,7 +127,6 @@ def main(): question_num = find_next_question_number() filename = create_question_file(question, question_num) - open_in_vscode(filename) wait_for_completion() code_content = read_code_from_file(filename) diff --git a/practical-file/questions/question_01.py b/practical-file/questions/question_01.py deleted file mode 100644 index b49f45c..0000000 --- a/practical-file/questions/question_01.py +++ /dev/null @@ -1,7 +0,0 @@ -# Question: Write a Python program to accept two integers and print their sum. - -def main(int1: int, int2: int) -> int: - print(f"{int1} + {int2} = {int1 + int2}") - -if __name__ == '__main__': - main(2, 2) diff --git a/practical-file/questions/question_01_output.txt b/practical-file/questions/question_01_output.txt deleted file mode 100644 index 65cb1d5..0000000 --- a/practical-file/questions/question_01_output.txt +++ /dev/null @@ -1,13 +0,0 @@ -Question 01: -Write a Python program to accept two integers and print their sum. - -Answer: -def main(int1: int, int2: int) -> int: - print(f"{int1} + {int2} = {int1 + int2}") - -if __name__ == '__main__': - main(2, 2) - - -Output: -2 + 2 = 4 diff --git a/practical-file/questions/question_02.py b/practical-file/questions/question_02.py deleted file mode 100644 index d54eb3a..0000000 --- a/practical-file/questions/question_02.py +++ /dev/null @@ -1,8 +0,0 @@ -# Question: Write a Python program that accepts the radius of a circle and prints its area. - -def main(radius: int): - print(f"Area: {3.14 * radius * radius}") - # or you can do 3.13 * radius ** 2 - -if __name__ == '__main__': - main(7) diff --git a/practical-file/questions/question_02_output.txt b/practical-file/questions/question_02_output.txt deleted file mode 100644 index 34ae01f..0000000 --- a/practical-file/questions/question_02_output.txt +++ /dev/null @@ -1,14 +0,0 @@ -Question 02: -Write a Python program that accepts the radius of a circle and prints its area. - -Answer: -def main(radius: int): - print(f"Area: {3.14 * radius * radius}") - # or you can do 3.13 * radius ** 2 - -if __name__ == '__main__': - main(7) - - -Output: -Area: 153.86 diff --git a/practical-file/questions/question_03.py b/practical-file/questions/question_03.py deleted file mode 100644 index 08839a6..0000000 --- a/practical-file/questions/question_03.py +++ /dev/null @@ -1,8 +0,0 @@ -# Question: Write a Python program to accept the length and width of a rectangle and compute its perimeter and area. - -def main(length: int, width: int) -> None: - print("Perimeter:", 2 * (length + width)) - print("Area:", length * width) - -if __name__ == '__main__': - main(10, 10) diff --git a/practical-file/questions/question_03_output.txt b/practical-file/questions/question_03_output.txt deleted file mode 100644 index 391aec0..0000000 --- a/practical-file/questions/question_03_output.txt +++ /dev/null @@ -1,15 +0,0 @@ -Question 03: -Write a Python program to accept the length and width of a rectangle and compute its perimeter and area. - -Answer: -def main(length: int, width: int) -> None: - print("Perimeter:", 2 * (length + width)) - print("Area:", length * width) - -if __name__ == '__main__': - main(10, 10) - - -Output: -Perimeter: 40 -Area: 100 diff --git a/practical-file/questions/question_04.py b/practical-file/questions/question_04.py deleted file mode 100644 index 0d3d80e..0000000 --- a/practical-file/questions/question_04.py +++ /dev/null @@ -1,7 +0,0 @@ -# Question: Write a Python program to compute simple interest for a given principal amount, time, and rate of interest. - -def main(principal: int, time: int, rate: float) -> None: - print(f"Simple Interest: {principal * rate * time / 100}") - -if __name__ == '__main__': - main(10000, 10, 5.0) diff --git a/practical-file/questions/question_04_output.txt b/practical-file/questions/question_04_output.txt deleted file mode 100644 index 21fea65..0000000 --- a/practical-file/questions/question_04_output.txt +++ /dev/null @@ -1,13 +0,0 @@ -Question 04: -Write a Python program to compute simple interest for a given principal amount, time, and rate of interest. - -Answer: -def main(principal: int, time: int, rate: float) -> None: - print(f"Simple Interest: {principal * rate * time / 100}") - -if __name__ == '__main__': - main(10000, 10, 5.0) - - -Output: -Simple Interest: 5000.0 diff --git a/practical-file/questions/question_05.py b/practical-file/questions/question_05.py deleted file mode 100644 index 7682792..0000000 --- a/practical-file/questions/question_05.py +++ /dev/null @@ -1,8 +0,0 @@ -# Question: Write a Python program to find whether a given number is even or odd. - -def main(num: int) -> None: - print("Even" if num % 2 == 0 else "Odd") - -if __name__ == '__main__': - main(2) - main(3) diff --git a/practical-file/questions/question_05_output.txt b/practical-file/questions/question_05_output.txt deleted file mode 100644 index a8e0387..0000000 --- a/practical-file/questions/question_05_output.txt +++ /dev/null @@ -1,15 +0,0 @@ -Question 05: -Write a Python program to find whether a given number is even or odd. - -Answer: -def main(num: int) -> None: - print("Even" if num % 2 == 0 else "Odd") - -if __name__ == '__main__': - main(2) - main(3) - - -Output: -Even -Odd diff --git a/practical-file/questions/question_06.py b/practical-file/questions/question_06.py deleted file mode 100644 index f9eb234..0000000 --- a/practical-file/questions/question_06.py +++ /dev/null @@ -1,18 +0,0 @@ -# Question: Write a Python program to find the largest among three numbers. - -def main(numbers: list[int]) -> None: - if not numbers: - print("No numbers provided.") - return - - largest = numbers[0] - for num in numbers: - if num > largest: - largest = num - - print("Largest number:", largest) - -if __name__ == '__main__': - main([1, 2, 3]) - main([3, 1, 2]) - main([5, 10, 15, 20]) diff --git a/practical-file/questions/question_06_output.txt b/practical-file/questions/question_06_output.txt deleted file mode 100644 index 7d172a1..0000000 --- a/practical-file/questions/question_06_output.txt +++ /dev/null @@ -1,26 +0,0 @@ -Question 06: -Write a Python program to find the largest among three numbers. - -Answer: -def main(numbers: list[int]) -> None: - if not numbers: - print("No numbers provided.") - return - - largest = numbers[0] - for num in numbers: - if num > largest: - largest = num - - print("Largest number:", largest) - -if __name__ == '__main__': - main([1, 2, 3]) - main([3, 1, 2]) - main([5, 10, 15, 20]) - - -Output: -Largest number: 3 -Largest number: 3 -Largest number: 20 diff --git a/practical-file/questions/question_07.py b/practical-file/questions/question_07.py deleted file mode 100644 index af62e31..0000000 --- a/practical-file/questions/question_07.py +++ /dev/null @@ -1,25 +0,0 @@ -# Question: Write a Python program to perform arithmetic calculation. The program should accept two operands and an operator, then display the result. - -def main(num1: float, num2: float, operator: str) -> None: - if operator == '+': - result = num1 + num2 - elif operator == '-': - result = num1 - num2 - elif operator == '*': - result = num1 * num2 - elif operator == '/': - if num2 == 0: - print("Error: Division by zero") - raise ZeroDivisionError - result = num1 / num2 - else: - print("Error: Invalid operator") - raise ValueError("Invalid operator. Use +, -, *, or /.") - - print(f"Result: {result}") - -if __name__ == '__main__': - main(10, 5, '+') - main(10, 5, '-') - main(10, 5, '*') - main(10, 5, '/') diff --git a/practical-file/questions/question_07_output.txt b/practical-file/questions/question_07_output.txt deleted file mode 100644 index c55a0ec..0000000 --- a/practical-file/questions/question_07_output.txt +++ /dev/null @@ -1,34 +0,0 @@ -Question 07: -Write a Python program to perform arithmetic calculation. The program should accept two operands and an operator, then display the result. - -Answer: -def main(num1: float, num2: float, operator: str) -> None: - if operator == '+': - result = num1 + num2 - elif operator == '-': - result = num1 - num2 - elif operator == '*': - result = num1 * num2 - elif operator == '/': - if num2 == 0: - print("Error: Division by zero") - raise ZeroDivisionError - result = num1 / num2 - else: - print("Error: Invalid operator") - raise ValueError("Invalid operator. Use +, -, *, or /.") - - print(f"Result: {result}") - -if __name__ == '__main__': - main(10, 5, '+') - main(10, 5, '-') - main(10, 5, '*') - main(10, 5, '/') - - -Output: -Result: 15 -Result: 5 -Result: 50 -Result: 2.0 diff --git a/practical-file/questions/question_08.py b/practical-file/questions/question_08.py deleted file mode 100644 index 89407f5..0000000 --- a/practical-file/questions/question_08.py +++ /dev/null @@ -1,11 +0,0 @@ -# Question: Write a Python program to check whether a given year is a leap year or not. - -def main(year: int) -> None: - if (year % 4 == 0 and year % 100 != 0) or (year % 400 == 0): - print(f"{year} is a leap year.") - else: - print(f"{year} is not a leap year.") - -if __name__ == '__main__': - main(2020) - main(2021) diff --git a/practical-file/questions/question_08_output.txt b/practical-file/questions/question_08_output.txt deleted file mode 100644 index a61dea2..0000000 --- a/practical-file/questions/question_08_output.txt +++ /dev/null @@ -1,18 +0,0 @@ -Question 08: -Write a Python program to check whether a given year is a leap year or not. - -Answer: -def main(year: int) -> None: - if (year % 4 == 0 and year % 100 != 0) or (year % 400 == 0): - print(f"{year} is a leap year.") - else: - print(f"{year} is not a leap year.") - -if __name__ == '__main__': - main(2020) - main(2021) - - -Output: -2020 is a leap year. -2021 is not a leap year. diff --git a/practical-file/questions/question_09.py b/practical-file/questions/question_09.py deleted file mode 100644 index af7bc25..0000000 --- a/practical-file/questions/question_09.py +++ /dev/null @@ -1,15 +0,0 @@ -# Question: Write a Python program to check if a number is positive, negative, or zero. - -def main(num: int) -> None: - if num > 0: - print(f"{num} is positive.") - elif num < 0: - print(f"{num} is negative.") - else: - print("The number is zero.") - - -if __name__ == '__main__': - main(10) - main(-5) - main(0) diff --git a/practical-file/questions/question_09_output.txt b/practical-file/questions/question_09_output.txt deleted file mode 100644 index d973aff..0000000 --- a/practical-file/questions/question_09_output.txt +++ /dev/null @@ -1,23 +0,0 @@ -Question 09: -Write a Python program to check if a number is positive, negative, or zero. - -Answer: -def main(num: int) -> None: - if num > 0: - print(f"{num} is positive.") - elif num < 0: - print(f"{num} is negative.") - else: - print("The number is zero.") - - -if __name__ == '__main__': - main(10) - main(-5) - main(0) - - -Output: -10 is positive. --5 is negative. -The number is zero. diff --git a/practical-file/questions/question_10.py b/practical-file/questions/question_10.py deleted file mode 100644 index a3a091d..0000000 --- a/practical-file/questions/question_10.py +++ /dev/null @@ -1,29 +0,0 @@ -""" -Question: Write a Python program to accept marks of a student and print the grade according to the given criteria: -- Marks ≥ 90: A -- Marks ≥ 80: B -- Marks ≥ 70: C -- Marks ≥ 60: D -- Otherwise: Fail -""" - -def main(marks: int) -> None: - if marks >= 90: - grade = 'A' - elif marks >= 80: - grade = 'B' - elif marks >= 70: - grade = 'C' - elif marks >= 60: - grade = 'D' - else: - grade = 'Fail' - - print(f"Grade: {grade}") - -if __name__ == '__main__': - main(95) - main(85) - main(75) - main(65) - main(55) \ No newline at end of file diff --git a/practical-file/questions/question_10_output.txt b/practical-file/questions/question_10_output.txt deleted file mode 100644 index d3270af..0000000 --- a/practical-file/questions/question_10_output.txt +++ /dev/null @@ -1,38 +0,0 @@ -Question 10: -Write a Python program to accept marks of a student and print the grade according to the given criteria: - -Answer: -- Marks ≥ 90: A -- Marks ≥ 80: B -- Marks ≥ 70: C -- Marks ≥ 60: D -- Otherwise: Fail -""" - -def main(marks: int) -> None: - if marks >= 90: - grade = 'A' - elif marks >= 80: - grade = 'B' - elif marks >= 70: - grade = 'C' - elif marks >= 60: - grade = 'D' - else: - grade = 'Fail' - - print(f"Grade: {grade}") - -if __name__ == '__main__': - main(95) - main(85) - main(75) - main(65) - main(55) - -Output: -Grade: A -Grade: B -Grade: C -Grade: D -Grade: Fail diff --git a/practical-file/questions/question_11.py b/practical-file/questions/question_11.py deleted file mode 100644 index bfbdb8f..0000000 --- a/practical-file/questions/question_11.py +++ /dev/null @@ -1,17 +0,0 @@ -# Question: Write a Python program to check whether a given character is a vowel or consonant. - -def main(char: str) -> None: - vowels = 'aeiou' - if char.lower() in vowels: - print(f"{char} is a vowel.") - elif char.isalpha(): - print(f"{char} is a consonant.") - else: - raise ValueError("Invalid input. Please enter an alphabetic character.") - - -if __name__ == '__main__': - main('a') - main('b') - main('A') - main('1') # also works with a int diff --git a/practical-file/questions/question_11_output.txt b/practical-file/questions/question_11_output.txt deleted file mode 100644 index b4d80a4..0000000 --- a/practical-file/questions/question_11_output.txt +++ /dev/null @@ -1,29 +0,0 @@ -Question 11: -Write a Python program to check whether a given character is a vowel or consonant. - -Answer: -def main(char: str) -> None: - vowels = 'aeiou' - if char.lower() in vowels: - print(f"{char} is a vowel.") - elif char.isalpha(): - print(f"{char} is a consonant.") - else: - raise ValueError("Invalid input. Please enter an alphabetic character.") - - -if __name__ == '__main__': - main('a') - main('b') - main('A') - main('1') # also works with a int - - -Output: -Traceback (most recent call last): - File "\\homeassistant.local\share\data\school\Grade 11 CS\Practical File\question_11.py", line 17, in - main('1') # also works with a int - ^^^^^^^^^ - File "\\homeassistant.local\share\data\school\Grade 11 CS\Practical File\question_11.py", line 10, in main - raise ValueError("Invalid input. Please enter an alphabetic character.") -ValueError: Invalid input. Please enter an alphabetic character. diff --git a/practical-file/questions/question_12.py b/practical-file/questions/question_12.py deleted file mode 100644 index c6a5617..0000000 --- a/practical-file/questions/question_12.py +++ /dev/null @@ -1,13 +0,0 @@ -# Question: Write a Python program to check whether a number is divisible by both 5 and 11. - -def main(num: int) -> None: - if num % 5 == 0 and num % 11 == 0: - print(f"{num} is divisible by both 5 and 11.") - else: - print(f"{num} is not divisible by both 5 and 11.") - -if __name__ == '__main__': - main(55) - main(22) - main(10) - main(121) diff --git a/practical-file/questions/question_12_output.txt b/practical-file/questions/question_12_output.txt deleted file mode 100644 index b401f48..0000000 --- a/practical-file/questions/question_12_output.txt +++ /dev/null @@ -1,22 +0,0 @@ -Question 12: -Write a Python program to check whether a number is divisible by both 5 and 11. - -Answer: -def main(num: int) -> None: - if num % 5 == 0 and num % 11 == 0: - print(f"{num} is divisible by both 5 and 11.") - else: - print(f"{num} is not divisible by both 5 and 11.") - -if __name__ == '__main__': - main(55) - main(22) - main(10) - main(121) - - -Output: -55 is divisible by both 5 and 11. -22 is not divisible by both 5 and 11. -10 is not divisible by both 5 and 11. -121 is not divisible by both 5 and 11. diff --git a/practical-file/questions/question_13.py b/practical-file/questions/question_13.py deleted file mode 100644 index d4a07dc..0000000 --- a/practical-file/questions/question_13.py +++ /dev/null @@ -1,10 +0,0 @@ -# Question: Write a Python program to find the absolute value of a number. - -def main(num: float) -> None: - abs_value = abs(num) - print(f"The absolute value of {num} is {abs_value}") - -if __name__ == '__main__': - main(-5.5) - main(3.14) - main(0) diff --git a/practical-file/questions/question_13_output.txt b/practical-file/questions/question_13_output.txt deleted file mode 100644 index 4da879f..0000000 --- a/practical-file/questions/question_13_output.txt +++ /dev/null @@ -1,18 +0,0 @@ -Question 13: -Write a Python program to find the absolute value of a number. - -Answer: -def main(num: float) -> None: - abs_value = abs(num) - print(f"The absolute value of {num} is {abs_value}") - -if __name__ == '__main__': - main(-5.5) - main(3.14) - main(0) - - -Output: -The absolute value of -5.5 is 5.5 -The absolute value of 3.14 is 3.14 -The absolute value of 0 is 0 diff --git a/practical-file/questions/question_14.py b/practical-file/questions/question_14.py deleted file mode 100644 index 84837d6..0000000 --- a/practical-file/questions/question_14.py +++ /dev/null @@ -1,16 +0,0 @@ -# Question: Write a Python program to check if a character is an uppercase or lowercase letter. - -def main(char: str) -> None: - if char.isupper(): - print(f"{char} is an uppercase letter.") - elif char.islower(): - print(f"{char} is a lowercase letter.") - else: - raise ValueError("Invalid input. Please enter an alphabetic character.") - -if __name__ == '__main__': - main('A') - main('a') - main('B') - main('b') - main('1') # also works with a int \ No newline at end of file diff --git a/practical-file/questions/question_14_output.txt b/practical-file/questions/question_14_output.txt deleted file mode 100644 index ab94cd5..0000000 --- a/practical-file/questions/question_14_output.txt +++ /dev/null @@ -1,27 +0,0 @@ -Question 14: -Write a Python program to check if a character is an uppercase or lowercase letter. - -Answer: -def main(char: str) -> None: - if char.isupper(): - print(f"{char} is an uppercase letter.") - elif char.islower(): - print(f"{char} is a lowercase letter.") - else: - raise ValueError("Invalid input. Please enter an alphabetic character.") - -if __name__ == '__main__': - main('A') - main('a') - main('B') - main('b') - main('1') # also works with a int - -Output: -Traceback (most recent call last): - File "\\homeassistant.local\share\data\school\Grade 11 CS\Practical File\question_14.py", line 16, in - main('1') # also works with a int - ^^^^^^^^^ - File "\\homeassistant.local\share\data\school\Grade 11 CS\Practical File\question_14.py", line 9, in main - raise ValueError("Invalid input. Please enter an alphabetic character.") -ValueError: Invalid input. Please enter an alphabetic character. diff --git a/practical-file/questions/question_15.py b/practical-file/questions/question_15.py deleted file mode 100644 index d77b59f..0000000 --- a/practical-file/questions/question_15.py +++ /dev/null @@ -1,12 +0,0 @@ -# Question: Write a Python program to accept age and check whether the person is eligible to vote (18 or older). - -def main(age: int) -> None: - if age >= 18: - print(f"Age {age} is eligible to vote.") - else: - print(f"Age {age} is not eligible to vote.") - -if __name__ == '__main__': - main(18) - main(17) - main(20) diff --git a/practical-file/questions/question_15_output.txt b/practical-file/questions/question_15_output.txt deleted file mode 100644 index 01a2ef9..0000000 --- a/practical-file/questions/question_15_output.txt +++ /dev/null @@ -1,20 +0,0 @@ -Question 15: -Write a Python program to accept age and check whether the person is eligible to vote (18 or older). - -Answer: -def main(age: int) -> None: - if age >= 18: - print(f"Age {age} is eligible to vote.") - else: - print(f"Age {age} is not eligible to vote.") - -if __name__ == '__main__': - main(18) - main(17) - main(20) - - -Output: -Age 18 is eligible to vote. -Age 17 is not eligible to vote. -Age 20 is eligible to vote. diff --git a/practical-file/questions/question_16.py b/practical-file/questions/question_16.py deleted file mode 100644 index df27549..0000000 --- a/practical-file/questions/question_16.py +++ /dev/null @@ -1,15 +0,0 @@ -# Question: Write a Python program to accept three sides and check whether they form a valid triangle. - -def main(sides: tuple[int, int, int]) -> None: - a, b, c = sides - if a + b > c and a + c > b and b + c > a: - print(f"The sides {sides} form a valid triangle.") - else: - print(f"The sides {sides} do not form a valid triangle.") - -if __name__ == '__main__': - main((3, 4, 5)) - main((1, 2, 3)) - main((5, 12, 13)) - main((7, 10, 5)) - main((1, 1, 2)) diff --git a/practical-file/questions/question_16_output.txt b/practical-file/questions/question_16_output.txt deleted file mode 100644 index c70c567..0000000 --- a/practical-file/questions/question_16_output.txt +++ /dev/null @@ -1,25 +0,0 @@ -Question 16: -Write a Python program to accept three sides and check whether they form a valid triangle. - -Answer: -def main(sides: tuple[int, int, int]) -> None: - a, b, c = sides - if a + b > c and a + c > b and b + c > a: - print(f"The sides {sides} form a valid triangle.") - else: - print(f"The sides {sides} do not form a valid triangle.") - -if __name__ == '__main__': - main((3, 4, 5)) - main((1, 2, 3)) - main((5, 12, 13)) - main((7, 10, 5)) - main((1, 1, 2)) - - -Output: -The sides (3, 4, 5) form a valid triangle. -The sides (1, 2, 3) do not form a valid triangle. -The sides (5, 12, 13) form a valid triangle. -The sides (7, 10, 5) form a valid triangle. -The sides (1, 1, 2) do not form a valid triangle. diff --git a/practical-file/questions/question_17.py b/practical-file/questions/question_17.py deleted file mode 100644 index a6560ee..0000000 --- a/practical-file/questions/question_17.py +++ /dev/null @@ -1,14 +0,0 @@ -# Question: Write a Python program to accept cost price and selling price, then print whether there is profit, loss, or no gain. - -def main(cost_price: float, selling_price: float) -> None: - if selling_price > cost_price: - print(f"Profit: {selling_price - cost_price}") - elif selling_price < cost_price: - print(f"Loss: {cost_price - selling_price}") - else: - print("No gain, no loss.") - -if __name__ == '__main__': - main(100.0, 120.0) - main(150.0, 130.0) - main(200.0, 200.0) \ No newline at end of file diff --git a/practical-file/questions/question_17_output.txt b/practical-file/questions/question_17_output.txt deleted file mode 100644 index 63d23df..0000000 --- a/practical-file/questions/question_17_output.txt +++ /dev/null @@ -1,21 +0,0 @@ -Question 17: -Write a Python program to accept cost price and selling price, then print whether there is profit, loss, or no gain. - -Answer: -def main(cost_price: float, selling_price: float) -> None: - if selling_price > cost_price: - print(f"Profit: {selling_price - cost_price}") - elif selling_price < cost_price: - print(f"Loss: {cost_price - selling_price}") - else: - print("No gain, no loss.") - -if __name__ == '__main__': - main(100.0, 120.0) - main(150.0, 130.0) - main(200.0, 200.0) - -Output: -Profit: 20.0 -Loss: 20.0 -No gain, no loss. diff --git a/practical-file/questions/question_18.py b/practical-file/questions/question_18.py deleted file mode 100644 index 1c983d9..0000000 --- a/practical-file/questions/question_18.py +++ /dev/null @@ -1,11 +0,0 @@ -# Question: Write a Python program to accept two numbers and check whether they are equal or not - -def main(num1: int, num2: int) -> None: - if num1 == num2: - print(f"{num1} and {num2} are equal.") - else: - print(f"{num1} and {num2} are not equal.") - -if __name__ == '__main__': - main(10, 10) - main(10, 20) \ No newline at end of file diff --git a/practical-file/questions/question_18_output.txt b/practical-file/questions/question_18_output.txt deleted file mode 100644 index 3701b30..0000000 --- a/practical-file/questions/question_18_output.txt +++ /dev/null @@ -1,17 +0,0 @@ -Question 18: -Write a Python program to accept two numbers and check whether they are equal or not - -Answer: -def main(num1: int, num2: int) -> None: - if num1 == num2: - print(f"{num1} and {num2} are equal.") - else: - print(f"{num1} and {num2} are not equal.") - -if __name__ == '__main__': - main(10, 10) - main(10, 20) - -Output: -10 and 10 are equal. -10 and 20 are not equal.