Skip to content

Commit 1640492

Browse files
committed
Delete unnecessary code files
1 parent ba75e99 commit 1640492

34 files changed

+420
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
## Summary
2+
This function checks if a given list of binary numbers is divisible by 5.
3+
4+
## Example Usage
5+
```python
6+
binary_numbers = "101,110,111,1001"
7+
result = check_binary_divisibility(binary_numbers)
8+
print(result)
9+
```
10+
11+
## Code Analysis
12+
### Inputs
13+
- `bin_numbers`: a string containing a comma-separated list of binary numbers.
14+
___
15+
### Flow
16+
1. Split the `bin_numbers` string into individual binary numbers using the comma as a delimiter.
17+
2. Iterate over each binary number.
18+
3. Convert each binary number to its decimal equivalent using `int(num, 2)`.
19+
4. Check if the decimal number is divisible by 5 using the modulo operator `%`.
20+
5. If the number is divisible by 5, add it to the `divisible_by_5` list.
21+
6. Join the numbers in the `divisible_by_5` list with commas using `','.join(divisible_by_5)`.
22+
7. Return the resulting string.
23+
___
24+
### Outputs
25+
- A string containing the binary numbers from the input list that are divisible by 5.
26+
___
File renamed without changes.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
## Summary
2+
This code defines a function named `calculate_average` that calculates the average of a given number of students' marks.
3+
4+
## Example Usage
5+
```python
6+
average = calculate_average(3)
7+
print(average)
8+
```
9+
This code will prompt the user to enter the marks of 3 students, calculate their average, and then print the result.
10+
11+
## Code Analysis
12+
### Inputs
13+
- `num_students`: an integer representing the number of students for which the average needs to be calculated.
14+
___
15+
### Flow
16+
1. Initialize `total_marks` variable to 0.
17+
2. Iterate `num_students` times:
18+
- Prompt the user to enter a student's mark.
19+
- Add the entered mark to `total_marks`.
20+
3. Calculate the average by dividing `total_marks` by `num_students`.
21+
4. Return the calculated average.
22+
___
23+
### Outputs
24+
- `average`: a float representing the average of the students' marks.
25+
___
File renamed without changes.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
## Summary
2+
This code defines a function called `calculate_distance` that takes a list of movements as input and calculates the distance traveled based on those movements. The function uses a dictionary to keep track of the current position, with 'x' and 'y' coordinates. It iterates over each movement in the list, extracting the direction and number of steps. It then updates the position accordingly by adding or subtracting the steps from the 'x' or 'y' coordinate. Finally, it calculates the distance from the origin using the Pythagorean theorem and returns the rounded value.
3+
4+
## Example Usage
5+
```python
6+
movements = ["UP 5", "RIGHT 3", "DOWN 2", "LEFT 1"]
7+
distance = calculate_distance(movements)
8+
print(distance) # Output: 5
9+
```
10+
11+
## Code Analysis
12+
### Inputs
13+
- `movements` (list): A list of strings representing the movements. Each string consists of a direction ('UP', 'DOWN', 'LEFT', or 'RIGHT') followed by the number of steps to take.
14+
___
15+
### Flow
16+
1. Initialize the `position` dictionary with 'x' and 'y' coordinates set to 0.
17+
2. Iterate over each `move` in the `movements` list.
18+
3. Split the `move` string into `direction` and `steps`.
19+
4. Convert `steps` to an integer.
20+
5. Based on the `direction`, update the `position` dictionary by adding or subtracting the `steps` from the corresponding coordinate.
21+
6. Calculate the distance from the origin using the Pythagorean theorem: square the 'x' coordinate, square the 'y' coordinate, sum the squares, and take the square root.
22+
7. Round the distance to the nearest integer.
23+
8. Return the calculated distance.
24+
___
25+
### Outputs
26+
- `distance` (int): The calculated distance traveled based on the given movements.
27+
___
File renamed without changes.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
## Summary
2+
This function calculates the electricity bill based on the number of units consumed.
3+
4+
## Example Usage
5+
```python
6+
bill = calculate_electricity_bill(100)
7+
print(bill)
8+
```
9+
Output:
10+
```
11+
82.5
12+
```
13+
14+
## Code Analysis
15+
### Inputs
16+
- units: an integer representing the number of units consumed
17+
___
18+
### Flow
19+
1. Check if the number of units is less than or equal to 50. If true, calculate the bill by multiplying the units by 0.50.
20+
2. If the number of units is greater than 50, check if it is less than or equal to 150. If true, calculate the bill by adding the cost of the first 50 units (50 * 0.50) to the cost of the remaining units ((units - 50) * 0.75).
21+
3. If the number of units is greater than 150, check if it is less than or equal to 250. If true, calculate the bill by adding the cost of the first 50 units (50 * 0.50), the cost of the next 100 units (100 * 0.75), and the cost of the remaining units ((units - 150) * 1.20).
22+
4. If the number of units is greater than 250, calculate the bill by adding the cost of the first 50 units (50 * 0.50), the cost of the next 100 units (100 * 0.75), the cost of the next 100 units (100 * 1.20), and the cost of the remaining units ((units - 250) * 1.50).
23+
5. Calculate the surcharge by multiplying the bill by 0.20.
24+
6. Calculate the total bill by adding the bill and the surcharge.
25+
___
26+
### Outputs
27+
- total_bill: a float representing the total electricity bill, including the surcharge.
28+
___
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
## Summary
2+
This code defines a function named `calculate_gross_salary` that calculates the gross salary based on the given basic salary. It takes the basic salary as input and calculates the house rent allowance (HRA), dearness allowance (DA), net salary, provident fund (PPF) deduction, and gross salary. The function then prints the calculated values.
3+
4+
## Example Usage
5+
```python
6+
calculate_gross_salary(15000)
7+
```
8+
This will calculate the gross salary for a basic salary of 15000 and print the breakdown of the salary components.
9+
10+
## Code Analysis
11+
### Inputs
12+
- `basic_salary` (numeric): The basic salary of an employee.
13+
___
14+
### Flow
15+
1. The function checks if the `basic_salary` is less than or equal to 10000. If true, it calculates the HRA as 20% of the `basic_salary` and the DA as 80% of the `basic_salary`.
16+
2. If the `basic_salary` is greater than 10000 but less than or equal to 20000, it calculates the HRA as 25% of the `basic_salary` and the DA as 90% of the `basic_salary`.
17+
3. If the `basic_salary` is greater than 20000, it calculates the HRA as 30% of the `basic_salary` and the DA as 95% of the `basic_salary`.
18+
4. The function then calculates the net salary by adding the `basic_salary`, HRA, and DA.
19+
5. It calculates the PPF deduction as 10% of the net salary.
20+
6. Finally, it calculates the gross salary by subtracting the PPF deduction from the net salary.
21+
___
22+
### Outputs
23+
- The function prints the breakdown of the salary components, including the basic salary, DA, HRA, net salary, PPF deduction, and gross salary.
24+
___
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
## Summary
2+
The `check_character_type` function checks the type of a given character and prints a corresponding message.
3+
4+
## Example Usage
5+
```python
6+
check_character_type('A')
7+
```
8+
Output: "The character 'A' is an alphabet."
9+
10+
## Code Analysis
11+
### Inputs
12+
- `char` (string): The character to be checked.
13+
___
14+
### Flow
15+
1. Check if the character is an alphabet using the `isalpha()` method.
16+
2. If it is an alphabet, print a message stating that.
17+
3. If not, check if the character is a digit using the `isdigit()` method.
18+
4. If it is a digit, print a message stating that.
19+
5. If neither an alphabet nor a digit, print a message stating that the character is a special symbol.
20+
___
21+
### Outputs
22+
- None
23+
___
File renamed without changes.

check_number_range/check_number_range.md

Whitespace-only changes.
File renamed without changes.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
## Summary
2+
The `main` function prompts the user to enter their age, checks if they are eligible to vote using the `check_voting_eligibility` function, and prints a corresponding message.
3+
4+
## Example Usage
5+
```python
6+
Enter your age: 20
7+
You have the right to vote.
8+
```
9+
10+
## Code Analysis
11+
### Inputs
12+
- `age` (integer): the age of the user
13+
___
14+
### Flow
15+
1. Prompt the user to enter their age.
16+
2. Convert the input to an integer and assign it to the variable `age`.
17+
3. Call the `check_voting_eligibility` function with the `age` as an argument.
18+
4. If the return value is `True`, print "You have the right to vote."
19+
5. If the return value is `False`, print "You do not have the right to vote."
20+
___
21+
### Outputs
22+
- None
23+
___
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
## Summary
2+
This code defines a function called `determine_triangle_type` that takes three arguments representing the lengths of the sides of a triangle. The function determines the type of the triangle (equilateral, isosceles, or scalene) based on the lengths of the sides and prints the result.
3+
4+
## Example Usage
5+
```python
6+
determine_triangle_type(5, 5, 5)
7+
# Output: Equilateral triangle
8+
9+
determine_triangle_type(5, 5, 6)
10+
# Output: Isosceles triangle
11+
12+
determine_triangle_type(3, 4, 5)
13+
# Output: Scalene triangle
14+
```
15+
16+
## Code Analysis
17+
### Inputs
18+
- `side1`: an integer representing the length of the first side of the triangle.
19+
- `side2`: an integer representing the length of the second side of the triangle.
20+
- `side3`: an integer representing the length of the third side of the triangle.
21+
___
22+
### Flow
23+
1. Check if all sides are equal (`side1 == side2 == side3`). If true, print "Equilateral triangle".
24+
2. If the above condition is false, check if any two sides are equal (`side1 == side2` or `side2 == side3` or `side1 == side3`). If true, print "Isosceles triangle".
25+
3. If both conditions above are false, print "Scalene triangle".
26+
___
27+
### Outputs
28+
- The function does not return any value. It prints the type of the triangle based on the lengths of its sides.
29+
___
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
## Summary
2+
This function finds the largest and smallest numbers among a given set of numbers.
3+
4+
## Example Usage
5+
```python
6+
find_smallest_and_largest(5)
7+
```
8+
Enter a number: 10
9+
Enter a number: 5
10+
Enter a number: 8
11+
Enter a number: 3
12+
Enter a number: 12
13+
The largest number is: 12
14+
The smallest number is: 3
15+
16+
## Code Analysis
17+
### Inputs
18+
- `n` (integer): The number of numbers to be entered.
19+
___
20+
### Flow
21+
1. Initialize the variables `largest` and `smallest` to negative infinity and positive infinity respectively.
22+
2. Iterate `n` times.
23+
3. Prompt the user to enter a number.
24+
4. Check if the entered number is larger than the current `largest` number. If so, update `largest` with the entered number.
25+
5. Check if the entered number is smaller than the current `smallest` number. If so, update `smallest` with the entered number.
26+
6. Print the largest and smallest numbers.
27+
___
28+
### Outputs
29+
- The largest number among the entered numbers.
30+
- The smallest number among the entered numbers.
31+
___

input-output/input-output.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
## Code Explanation
2+
3+
The provided Python code snippet is a part of a script that takes a user's input, splits the input into individual string integers, converts them to integers, and prints each one. If a value cannot be converted to an integer, it prints a message indicating that the value is not an integer.
4+
5+
### Inputs
6+
7+
The code snippet takes a string input from the user, which should contain integers separated by spaces.
8+
9+
### Flow
10+
11+
1. The code prompts the user to enter integers separated by spaces.
12+
2. The input string is split into individual string integers using the `split()` method.
13+
3. Each string integer is converted to an integer using the `int()` function.
14+
4. If the conversion is successful, the integer is printed.
15+
5. If the conversion fails (i.e., the string cannot be converted to an integer), a message indicating that the value is not an integer is printed.
16+
17+
### Outputs
18+
19+
The code snippet prints each integer value entered by the user on a separate line. If a value cannot be converted to an integer, it prints a message indicating that the value is not an integer.
20+
21+
### Usage example
22+
23+
```python
24+
Enter integers separated by spaces: 10 20 30 abc 40
File renamed without changes.

is_leap_year/is_leap_year.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
## Summary
2+
This function checks if a given year is a leap year.
3+
4+
## Example Usage
5+
```python
6+
is_leap_year(2000)
7+
# Output: True
8+
9+
is_leap_year(1900)
10+
# Output: False
11+
```
12+
13+
## Code Analysis
14+
### Inputs
15+
- year: an integer representing the year to be checked
16+
___
17+
### Flow
18+
1. Check if the year is divisible by 400. If it is, return True.
19+
2. If the year is not divisible by 400, check if it is not divisible by 100 and divisible by 4. If it is, return True.
20+
3. If none of the above conditions are met, return False.
21+
___
22+
### Outputs
23+
- True if the year is a leap year
24+
- False if the year is not a leap year
25+
___
File renamed without changes.

largest_number/largest_number.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
## Summary
2+
The `find_largest_of_four` function takes four numbers as input and returns the largest number among them.
3+
4+
## Example Usage
5+
```python
6+
largest = find_largest_of_four(5, 10, 3, 8)
7+
print(largest) # Output: 10
8+
```
9+
10+
## Code Analysis
11+
### Inputs
12+
- `num1`: The first number to compare.
13+
- `num2`: The second number to compare.
14+
- `num3`: The third number to compare.
15+
- `num4`: The fourth number to compare.
16+
___
17+
### Flow
18+
1. The function takes four numbers as input.
19+
2. It compares each number with the others using multiple `>=` conditions.
20+
3. If the first number is greater than or equal to all the other numbers, it is returned as the largest.
21+
4. If the second number is greater than or equal to all the other numbers, it is returned as the largest.
22+
5. If the third number is greater than or equal to all the other numbers, it is returned as the largest.
23+
6. If none of the above conditions are met, the fourth number is returned as the largest.
24+
___
25+
### Outputs
26+
- The largest number among the four input numbers.
27+
___
File renamed without changes.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
## Summary
2+
The `find_roots` function calculates the roots of a quadratic equation using the quadratic formula. It determines whether the roots are real or complex based on the discriminant value.
3+
4+
## Example Usage
5+
```python
6+
roots = find_roots(1, -3, 2)
7+
print(roots)
8+
```
9+
10+
## Code Analysis
11+
### Inputs
12+
- `a`: the coefficient of the quadratic term
13+
- `b`: the coefficient of the linear term
14+
- `c`: the constant term
15+
___
16+
### Flow
17+
1. Calculate the discriminant using the formula `b**2 - 4*a*c`.
18+
2. If the discriminant is greater than 0, there are two distinct real roots. Calculate the roots using the quadratic formula: `(-b + sqrt(discriminant)) / (2*a)` and `(-b - sqrt(discriminant)) / (2*a)`.
19+
3. If the discriminant is equal to 0, there is one real root. Calculate the root using the formula `-b / (2*a)`.
20+
4. If the discriminant is less than 0, there are complex roots. Calculate the real and imaginary parts of the roots using the formulas `-b / (2*a)` and `sqrt(-discriminant) / (2*a)`, respectively.
21+
___
22+
### Outputs
23+
- If the discriminant is greater than 0, the function returns a tuple containing the two distinct real roots.
24+
- If the discriminant is equal to 0, the function returns a tuple containing the single real root.
25+
- If the discriminant is less than 0, the function returns a tuple containing the complex roots in the form of `(real_part + imaginary_part * 1j, real_part - imaginary_part * 1j)`.
26+
___
File renamed without changes.

rps/rps.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
## Summary
2+
The `determine_winner` function determines the winner of a rock-paper-scissors game between two players.
3+
4+
## Example Usage
5+
```python
6+
result = determine_winner("rock", "scissors")
7+
print(result)
8+
```
9+
Output:
10+
```
11+
Player 1 wins.
12+
```
13+
14+
## Code Analysis
15+
### Inputs
16+
- `player1` (string): The choice of player 1 (either "rock", "paper", or "scissors").
17+
- `player2` (string): The choice of player 2 (either "rock", "paper", or "scissors").
18+
___
19+
### Flow
20+
1. If `player1` and `player2` have the same choice, return "It's a tie."
21+
2. If `player1` has "rock" and `player2` has "scissors", or if `player1` has "scissors" and `player2` has "paper", or if `player1` has "paper" and `player2` has "rock", return "Player 1 wins."
22+
3. Otherwise, return "Player 2 wins."
23+
___
24+
### Outputs
25+
- The function returns a string indicating the winner of the rock-paper-scissors game.
26+
___

rps.py renamed to rps/rps.py

File renamed without changes.

0 commit comments

Comments
 (0)