Skip to content

Commit ca756c4

Browse files
authored
Merge branch 'code-differently:main' into Lesson_05
2 parents 78de0a6 + 83d16b5 commit ca756c4

File tree

2 files changed

+113
-0
lines changed

2 files changed

+113
-0
lines changed

lesson_04/xaviercruz/README.md

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
## Java Implementation
2+
3+
```java
4+
5+
public class Main{
6+
public static void main(String args[]){
7+
8+
System.out.println(isPrime(3)); // Output: true
9+
System.out.println(isPrime(4)); // Output: false;
10+
}
11+
12+
13+
public static boolean isPrime(int n){
14+
if (n <= 1) {
15+
return false;
16+
}
17+
for (int i = 2; i < Math.sqrt(n); i++) {
18+
if (n % i == 0) {
19+
return false;
20+
}
21+
}
22+
return true;
23+
}
24+
}
25+
26+
27+
```
28+
29+
## Python Implementation
30+
31+
```python
32+
33+
def is_prime(n: int) -> bool:
34+
if n <= 1:
35+
return False
36+
for i in range(2, int(math.sqrt(n)) + 1):
37+
if n % i == 0:
38+
return False
39+
return True
40+
41+
print(is_prime(3)) # Output: true
42+
print(is_prime(4)) # Output: false
43+
44+
```
45+
46+
## Explanation
47+
48+
### Core Differences
49+
50+
**Syntax**:
51+
52+
- 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.
53+
54+
- 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.
55+
56+
**Type Declaration**:
57+
58+
- 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.
59+
60+
- 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.
61+
62+
**Libraries and Imports**:
63+
64+
- Java: You need to import specific libraries (e.g., `Math` for square root calculations) explicitly.
65+
66+
- 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.
67+
68+
**Boolean Representation**:
69+
70+
- Java: Uses `true` and `false` (with a lowercase 'T' and 'F') for boolean values.
71+
72+
- 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.
73+
74+
### Core Similarities
75+
76+
**Logic of Prime Detection**:
77+
78+
- Both implementations use a similar logic to determine if a number is prime:
79+
- A number less than or equal to 1 is not prime.
80+
- The algorithm checks for divisibility from 2 up to the square root of the number.
81+
- If any divisor is found, the number is not prime; otherwise, it is prime.
82+
83+
**Control Structures**:
84+
85+
- 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.
86+
87+
**Functionality**:
88+
89+
- Both implementations return a boolean value indicating whether the input number is prime.
90+
91+
## Conclusion
92+
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.

lesson_05/josephcaballero/README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# User Stories
2+
3+
## User Story 1
4+
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.
5+
6+
## User Story 2
7+
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
8+
9+
## User Story 3
10+
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.
11+
12+
# Finding Bugs
13+
14+
## Dark Mode Bug
15+
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.
16+
17+
## Sidebar Text Deletion
18+
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.
19+
20+
## Creating New Tasks
21+
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 commit comments

Comments
 (0)