Skip to content

Commit 0c7b30d

Browse files
authored
Merge branch 'code-differently:main' into Lesson_04
2 parents 12a1de4 + 7438405 commit 0c7b30d

File tree

11 files changed

+415
-0
lines changed

11 files changed

+415
-0
lines changed

lesson_04/ananatawamcintyre/README.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
2+
# Python Implementation
3+
4+
---
5+
6+
```python
7+
def is_prime(n):
8+
"""Check if a number is prime."""
9+
if n < 2:
10+
return False
11+
for i in range(2, int(n ** 0.5) + 1):
12+
if n % i == 0:
13+
return False
14+
return True
15+
16+
# Example usage
17+
if is_prime(num):
18+
print(f"{3} is a prime number.")
19+
else:
20+
print(f"{4} is not a prime number.")
21+
22+
```
23+
24+
# JavaScript Implementation
25+
26+
---
27+
28+
```JavaScript
29+
30+
function isPrime(n) {
31+
if (n < 2) return false;
32+
for (let i = 2; i <= Math.sqrt(n); i++) {
33+
if (n % i === 0) return false;
34+
}
35+
return true;
36+
}
37+
38+
// Example usage
39+
if (isPrime(num)) {
40+
console.log(`${3} is a prime number.`);
41+
} else {
42+
console.log(`${4} is not a prime number.`);
43+
}
44+
45+
46+
```
47+
48+
# Explanation
49+
50+
---
51+
52+
As seen above, I have created a code that helps the user determine whether a number is a prime number or not. I utilized both Python and Javascript to do so and this was my first time writing out my own code with those languages. The sample numbers **(3)** and **(4)** were used to show the reader, **you**, what an example of a prime number looks like. **Is_prime** stands for the command that determines whether a number **(num or n)** is prime or not.
53+
54+
## Similarities
55+
56+
- Both implementations display the number **(3)** as the prime number and **(4)** as the non-prime number.
57+
- Both use **"if"** and **"is_prime"** to point out if a number is prime or not.
58+
- Both implementations return **"true"** or **"false"** depending on whether the number is a prime number or not.
59+
60+
## Differences
61+
62+
- The codeword used to determine the answer for the Java Code implementation is **console.log**.
63+
- The codeword used to determine the answer for the Python implementation is **print**.
64+
- Python uses **def** before is_prime and JavaScript uses **function** before is_prime.
65+
66+
---
67+
68+
### Bonus message from the creator:
69+
Hello World! Again, this was my first time creating my own code. I had lots of fun working in JavaScript and Python, but would love to hear some good feedback or even complaints that you, the reader, may have. I spent a good **2 hours** trying to figure out how to get both Python and Javascript to work in a Markdown file. If any part of my code was confusing or uneasy to read, let a sista know! Happy coding! - A'nanatawa

lesson_04/davidadenaike/readme.md

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
2+
## Python implementation
3+
4+
```python
5+
def is_even(number):
6+
return number % 2 == 0
7+
8+
# Example usage:
9+
print(is_even(4)) # Output: True
10+
print(is_even(7)) # Output: False
11+
```
12+
13+
## JavaScript implementation
14+
15+
```javascript
16+
function isEven(number) {
17+
return number % 2 === 0;
18+
}
19+
20+
// Example usage:
21+
console.log(isEven(4)); // Output: true
22+
console.log(isEven(7)); // Output: false
23+
```
24+
25+
note need to write 100 words explanation of the two
26+
-->
27+
28+
## JavaScript
29+
```java script
30+
31+
function isPrime(number) {
32+
if (number <= 1) {
33+
return false; // Numbers less than or equal to 1 are not prime
34+
}
35+
36+
for (let i = 2; i <= Math.sqrt(number); i++) {
37+
if (number % i === 0) {
38+
return false; // If divisible by any number other than 1 and itself, it's not prime
39+
}
40+
}
41+
42+
return true; // If no divisors found, the number is prime
43+
}
44+
```
45+
46+
47+
## Java
48+
```java
49+
import java.util.Scanner;
50+
51+
public class PrimeNumberChecker {
52+
53+
// Method to check if a number is prime
54+
public static boolean isPrime(int num) {
55+
// Handle cases for numbers less than 2
56+
if (num <= 1) {
57+
return false;
58+
}
59+
60+
// Check divisibility from 2 to the square root of num
61+
for (int i = 2; i * i <= num; i++) {
62+
if (num % i == 0) {
63+
return false; // num is divisible by i, so it's not prime
64+
}
65+
}
66+
67+
return true; // num is prime if no divisors were found
68+
}
69+
70+
public static void main(String[] args) {
71+
Scanner scanner = new Scanner(System.in);
72+
73+
// Input number from user
74+
System.out.print("Enter a number: ");
75+
int number = scanner.nextInt();
76+
77+
// Check if the number is prime
78+
if (isPrime(number)) {
79+
System.out.println(number + " is a prime number.");
80+
} else {
81+
System.out.println(number + " is not a prime number.");
82+
}
83+
84+
scanner.close();
85+
}
86+
}
87+
```
88+
89+
## Explanation
90+
91+
Java uses a method called `PrimeNumberChecker` to check if a number is prime. The method is made up of two components. An `if` statement and a `for` loop. The `if` statement handles numbers that are less than 2. As the for loop then checks for divisibility from 2 to the square root of the number represented as int “i”. Both the if statement and for loop is nested within a public class `PrimeNumberChecker`
92+
93+
JavaScript however is more straight forward. It uses a function called `‘isPrime’` that checks numbers that are less than or equal to 1. Once it does that, it returns false since the result would not be a prime number. Afterward an `if` statement is used, similarly to java. Then a `for` loop checks if the number is divisible by any number other than 1 and itself.
94+
95+
### Differences
96+
Biggest difference is that java because it is an object-oriented language has the method `‘PrimeNumberChecker’` in a class to use.
97+
98+
### Similarities:
99+
Both languages use an if statement and a for loop to determine whether a number is prime or not.

lesson_04/jeremiahwing/README.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
## JAVA Implementation
2+
3+
```java
4+
5+
public class EvenCheck {
6+
// Method to check if a number is even
7+
public static boolean isEven(int number) {
8+
return number % 2 == 0;
9+
}
10+
11+
// Main method for running the program
12+
public static void main(String[] args) {
13+
System.out.println(isEven(4)); // Output: true
14+
System.out.println(isEven(7)); // Output: false
15+
}
16+
}
17+
```
18+
19+
20+
## C++ Implementation
21+
#include <iostream>
22+
using namespace std;
23+
24+
```
25+
26+
// Function to check if a number is even
27+
bool isEven(int number) {
28+
return number % 2 == 0;
29+
}
30+
31+
int main() {
32+
33+
cout << isEven(4) << endl; // Output: 1 (true)
34+
cout << isEven(7) << endl; // Output: 0 (false)
35+
return 0;
36+
}
37+
38+
```
39+
40+
## Explanation
41+
42+
First I want to talk about a prime number. A prime number is a natural number only divisible by 1 and its self.
43+
44+
Implementing it into code;
45+
46+
47+
The "Java" implementation uses a function named called IsPrime. This Method needs a number as an imput and checks if its prime. The first being if the number is less than or equal to 1. If the results arent a prime number the method is false. However it runs a loop starting from 2 to the sqrt of the number. Being that if the number is divisible by anything in that range the meothod will be false. if no divide then method is true.
48+
49+
50+
The "C++" Implementation also uses the function IsPrime. This function also works in a simimlar way then java. In thid method you need to first check if the number is 1 or less than, which returns false in that sense. After, the function literally loops from 2 up to the sqrt of the number simlar to java, looking for nay divisors. If i does find a divide then this method will return false. Concluding that if no divisor was found then menthod remains true.
51+
52+
# Similarities and Differences Index Chart
53+
54+
| Feature | Similarities | Differences |
55+
|-----------------------|-----------------------------------------------|-----------------------------------------------|
56+
| **Syntax** | Both programs usse a function with a simlilar purpose | Java uses "IsPrime" as C++ uses "isPrime" but written out differently.|
57+
| **Input** | Both take number input to check if output is prime. | Java has a personal writting style while C++ follows an ordered structure.|
58+
| **Main Function** | Both have main start section to run code. | Java uses "public static void Main()" C++ uses "int main()" to start.|
59+
| **First Line of Code** | Both need a special line including designated tools for code to start and run. | Java starts with "public class;". C++ starts with "#include <iostream>"|
60+
| **Printing Output** | Both Java and C++ use printing outputs to show if number is prime. | Java uses "System.out.print()". C++ uses "cout" but, for larger programs uses std::cout to avoid potential name conflicts.|

lesson_04/oliviajames/README.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
def is_prime(n):
2+
if n < 2:
3+
return False
4+
if n in (2, 3):
5+
return True
6+
if n % 2 == 0 or n % 3 == 0:
7+
return False
8+
9+
i = 5
10+
while i * i <= n:
11+
if n % i == 0 or n % (i + 2) == 0:
12+
return False
13+
i += 6
14+
return True
15+
16+
# Example usage
17+
num = int(input("Enter a number: "))
18+
print(f"{num} is prime: {is_prime(num)}")
19+
20+
21+
import java.util.Scanner;
22+
23+
public class PrimeChecker {
24+
public static boolean isPrime(int n) {
25+
if (n < 2) return false;
26+
if (n == 2 || n == 3) return true;
27+
if (n % 2 == 0 || n % 3 == 0) return false;
28+
29+
for (int i = 5; i * i <= n; i += 6) {
30+
if (n % i == 0 || n % (i + 2) == 0) return false;
31+
}
32+
return true;
33+
}
34+
35+
public static void main(String[] args) {
36+
Scanner scanner = new Scanner(System.in);
37+
System.out.print("Enter a number: ");
38+
int num = scanner.nextInt();
39+
scanner.close();
40+
41+
System.out.println(num + " is prime: " + isPrime(num));
42+
}
43+
}
44+
45+
46+
# Explanation
47+
After examining both languages I noticed that Python uses an is_prime (num) function that is used to dictate whether the number being input is prime or not. It uses specific clauses including numbers less than 1, even numbers greater than 2 , and numbers from 3 to the square root of said number for all statements to print false, otherwise it will print true if the number is equal to 2 as it is the smallest prime number and all others outside of said classes.
48+
49+
In Java it uses a class function primechecker and an isPrime(int num) to determine if a number is prime. Using if statements that will return false when numbers are less than 1, numbers that are even or greater than 2, and then uses a loop to divide from 2 to the square root of the number. If no divisor is found it will otherwise print true and if the number is equal to 2.
50+
51+
52+
53+
54+
# Differences
55+
In python, functions are defined using the def keyword, whereas in Java, public class is used as a keyword.
56+
Java uses “System.out.print” and python uses “print”
57+
Java uses a public static boolean while python uses def is_prime(num).
58+
59+
60+

lesson_05/JohnBey/README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Backend JavaScript
2+
3+
As a day competitive player, I want everything in the game to work as smoothly and seamlessly as possible, so that I may increase my rank fairly and without any interruptions.
4+
5+
6+
## Acceptance Criteria
7+
8+
Given the game properly reads my input in real-time when I press the shoot button, then the person on the other side takes damage and dies.
9+
10+
11+
# HTML/CSS
12+
13+
As a day to day user, I want the website to be easy to read, so that I can digest the information on it more thoroughly.
14+
15+
16+
## Acceptance Criteria
17+
18+
Given the information on the website is very easily understood when I decide to more thoroughly read it, then the time that I save when doing so will be cut in half and just overall be more accurate.
19+
20+
21+
# Python
22+
23+
As a person just getting into python, I want to create a python script that automatically webscrapes Amazon for the highest priced GPUs, so that I can buy them quickly and sell them to the highest bidder.
24+
25+
26+
## Acceptance Criteria
27+
28+
Given Python takes the price of a certain GPUs when I run the command, then the price will be put into my database and the item will be bought before anyone else.

lesson_05/NiaPReadME/NiaP_ReadMe.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
## Face Recognition
2+
3+
As a frequent phone user, I want to make face recognition more advanced so that it’s harder to be hacked.
4+
Response: iIn order to do that, an added feature for fingers and hands would be implemented.
5+
6+
## Driver Communication
7+
8+
As a driver, I want the ability to communicate with other drivers safely and fast.
9+
Response: Cars being equipped with electronic display and voice command software.
10+
11+
## Automatic Dress Chamber
12+
13+
As a person who spends a longtime getting ready in the mornings, I want the ability to speed up the process in order to apply my free time elsewhere.
14+
15+
Response: A wardrobe chamber equipped with technology to choose an outfit, step into the chamber which will automatically dress the user within 5 minutes.

lesson_05/ananatawamcintyre/README.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# User Stories and Responses for Reddit
2+
3+
**Background:** Reddit is a website, mobile app, and social media platform that allows users to interact and comment within multiple communities and make photo-video-text content. Reddit utilizes upvotes, downvotes, and a point system, called karma, which is displayed on every profile. If your karma is low or negative (in the 100s or 1000s for example) it signifies to the reddit world that you are either a brand new user, don't use reddit often, or are an internet troll. If your karma is high (10,000+) it signifies that you have made viral, popular posts or comments in the past and, most likely, are a decent redditor. New users, or users with low karma, cannot comment or make posts on Reddit until their account is at least (1) day old.
4+
5+
---
6+
7+
8+
**User Story 1:**
9+
10+
As a brand new reddit user, I want the ability to make a comment or post so that I can participate in the community conversation.
11+
12+
**Response/Acceptance Criteria:**
13+
- The update will allow new users to comment and post within communities even when their account is less than a day old.
14+
- The system now incorporates a trigger word function that will auto-ban trolls when commenting or posting those words, but will allow new users with low karma to still make posts and comments.
15+
- The block against new or low karma users will be lifted from the website and mobile app, allowing anyone to interact on the website.
16+
17+
18+
**User Story 2:**
19+
20+
I am a moderator that would like to respond to ModMail as myself, not as a Moderator, so that I can form a personal connection with the sender.
21+
22+
**Response/Acceptance Criteria:**
23+
- When the moderator enters the ModMail to respond to a message, there will be an option to respond anonymously as a "Moderator" or as their personal account.
24+
- The system will allow the moderator to craft their own private, additional message to the messenger that other Moderators cannot see or have access to.
25+
- The Modmail update will provide a checkbox that allows the Moderator to send an automatic friend request and inbox inquiry to the messenger so that the two people can form their own relationship.
26+
27+
28+
29+
**User Story 3:**
30+
31+
I am non-frequent user that would like to have full access to the website so that I can participate in discussions quickly.
32+
33+
**Response/Acceptance Criteria:**
34+
35+
- The software will allow users to comment as a "Guest" on reddit without needing to sign up to the website.
36+
- The new update will allow Guest users to not only make their own posts, but also give them the opportunity to sign up and make their account official after making said post.
37+
- The website will now give the Guest user an option to add their cellphone or email address so that they get notified if anyone responds to their post.
38+
39+
---

lesson_05/evanphilakhong/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# User Stories
2+
3+
1. As a **bodybuilder**, I want to **track my calories**, so that I know if I'm in a **calorie defiecit or surplus**.
4+
5+
2. As a **runner**, I want to **track distance ran** and **time ran**, so I can find my **running pace**.
6+
7+
3. As a **Race Engineer**, I want to collect **Telemetry System Data**, so I can find an **ideal setup** for the car.

lesson_05/mercedesmathews/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# User stories for a music platform when walking and running
2+
3+
- As a runner, I want an app to track how fast i'm running, so that it can play music that matches my pace.
4+
- As a spotify listener, I want the app to link with my spotify, so that it can play music from my own playlists.
5+
- As a user, I want to add my music preferences, so that the app can generate music based off of them.

0 commit comments

Comments
 (0)