Skip to content

Commit

Permalink
Merge branch 'code-differently:main' into lesson_06
Browse files Browse the repository at this point in the history
  • Loading branch information
haldanek authored Oct 9, 2024
2 parents 759645d + 83d16b5 commit c4baaca
Show file tree
Hide file tree
Showing 2 changed files with 113 additions and 0 deletions.
92 changes: 92 additions & 0 deletions lesson_04/xaviercruz/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
## Java Implementation

```java

public class Main{
public static void main(String args[]){

System.out.println(isPrime(3)); // Output: true
System.out.println(isPrime(4)); // Output: false;
}


public static boolean isPrime(int n){
if (n <= 1) {
return false;
}
for (int i = 2; i < Math.sqrt(n); i++) {
if (n % i == 0) {
return false;
}
}
return true;
}
}


```

## Python Implementation

```python

def is_prime(n: int) -> bool:
if n <= 1:
return False
for i in range(2, int(math.sqrt(n)) + 1):
if n % i == 0:
return False
return True

print(is_prime(3)) # Output: true
print(is_prime(4)) # Output: false

```

## Explanation

### Core Differences

**Syntax**:

- Java: Java requires explicit class definitions, and all code must reside within a class. The main method is the entry point of the application. Java uses semicolons to terminate statements and curly braces to define blocks of code.

- Python: Python has a more concise and readable syntax, using indentation to define blocks of code without the need for curly braces or semicolons. There is no need for an explicit main method; you can simply write functions at the top level.

**Type Declaration**:

- Java: It is a statically typed language, meaning variable types must be declared explicitly (e.g., `int n`). This can help catch type-related errors at compile time.

- Python: Python is dynamically typed, allowing variables to be assigned without explicit type declarations. Type hints can be used (as seen in `n: int`), but they are not enforced at runtime.

**Libraries and Imports**:

- Java: You need to import specific libraries (e.g., `Math` for square root calculations) explicitly.

- Python: The math library needs to be imported, as shown in the Python implementation. However, the import syntax is simple (`import math`), and Python's built-in functions often eliminate the need for additional libraries.

**Boolean Representation**:

- Java: Uses `true` and `false` (with a lowercase 'T' and 'F') for boolean values.

- Python: Uses `True` and `False` (with a capital 'T' and 'F') but it’s more flexible with types and doesn’t require strict boolean checks.

### Core Similarities

**Logic of Prime Detection**:

- Both implementations use a similar logic to determine if a number is prime:
- A number less than or equal to 1 is not prime.
- The algorithm checks for divisibility from 2 up to the square root of the number.
- If any divisor is found, the number is not prime; otherwise, it is prime.

**Control Structures**:

- Both languages employ similar control structures such as if statements and for loops. The iteration over possible divisors is done using a loop, and the logic to return a boolean value is consistent.

**Functionality**:

- Both implementations return a boolean value indicating whether the input number is prime.

## Conclusion
Both Java and Python successfully implement a prime number detection algorithm with logical similarities and notable differences in syntax, type handling, and structure. The choice between the two languages often comes down to the specific use case, existing codebase, or personal preference, as each offers unique advantages. Java's robustness and performance are great for large-scale applications, while Python's simplicity and readability are ideal for rapid development and scripting.
21 changes: 21 additions & 0 deletions lesson_05/josephcaballero/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# User Stories

## User Story 1
As a Store Owner I want to be able to track my inventory more effectively so that I take less losses and don't show false inventory.

## User Story 2
As an Internet user I want to be able to go online without ads popping up left and right so i dont get distacted or even irritated

## User Story 3
As a Website Visitor I want to be able to effectively be able to traverse the website on any device and not be blinded by the colors or have to squint to see anything so I can have a good viewing experience.

# Finding Bugs

## Dark Mode Bug
Upon clicking the dark mode button the screen didnt change color only the top bar did, not only that the bar actually made it so some of the buttons weren't able to be seen and even changed one.

## Sidebar Text Deletion
Upon clicking the sidebar and collapsing it I was greeted with more than I expected when the sidebar actually got rid of the respective text but also the tab for today's tasks seemed to have also been removed as well when collapsing the sidebar.

## Creating New Tasks
When trying to create new tasks I see that my text disappears after I press the "add task" button and only reappears when I reload the page or log back in .

0 comments on commit c4baaca

Please sign in to comment.