Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add glossaries for coding insights #2708

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@ Types of change:
- [Python Data Analysis - Creating Your First Notebook - Add missing identifiers](https://github.com/enkidevs/curriculum/pull/2713)
- [Python - Calling Functions - Improve readability](https://github.com/enkidevs/curriculum/pull/2705)

### Added
- [Python & Javascript - Glossary - Add glossary on for, while, if and function creation](https://github.com/enkidevs/curriculum/pull/2708)

## May 12th 2021

### Fixed
Expand Down
12 changes: 12 additions & 0 deletions glossary/javascript/js-for-loop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# For

A `for` loop is used when you want to execute a piece of code a specified number of times.


```javascript
// Create variable i, set the condition to "as long as i is less than 3", increase i by 1 after every loop cycle
for (let i = 0; i < 3; i++) {
// Code that is executed on every cycle
console.log("The current value of i is", i, ".");
}
```
14 changes: 14 additions & 0 deletions glossary/javascript/js-function-creation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Function

Functions are pieces of code designed for a particular task.

Functions are executed by performing a function call.

```javascript
function addition(x, y) {
return x + y; // Returns the sum of x and y
}

// Function called with values for x and y
addition(11, 3);
```
19 changes: 19 additions & 0 deletions glossary/javascript/js-if-else.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# If & if-else

An `if` is a conditional statement that executes a piece of code if the condition is `true`.

An `else` statement is used after the `if` and it executes the code if the `if` condition evaluates to `false`.

`if-else` statements can be chained.

```javascript
let number = 3;

if (number > 3) {
console.log(number, "is greater than 3");
} else if (number < 3) {
console.log(number, "is smaller than 3");
} else {
console.log(number, "is equal to 3");
}
```
16 changes: 16 additions & 0 deletions glossary/javascript/js-while-loop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# While

A `while` loop is used when you want to execute a piece of code repeatedly.

```javascript
let number = 0;

// while (condition) is true
while (number < 5) {
// Increase number by 1
number++;

// Output current value of number
console.log(number);
}
```
19 changes: 19 additions & 0 deletions glossary/python/python-for-in-range.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# For & range()

You can use `range()` with a `for..in` loop to cycle through a specified range.

```python
# For every number in the range 1 to 6 (1 included, 6 excluded)
for number in range(1, 6):
# number to the power of number
print(number ** number)
```

Which gives the output:
```plain-text
1
4
27
256
3125
```
21 changes: 21 additions & 0 deletions glossary/python/python-for-in.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# For...in

A `for...in` loop is used when you want to iterate over a list, tuple, dictionary, and so on.

```python
numbers = [1, 3, 2, 5, 9, 4, 7]

for num in numbers:
print(num)
```

The output looks like this:
```plain-text
1
3
2
5
9
4
7
```
13 changes: 13 additions & 0 deletions glossary/python/python-function-creation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Function

Functions are pieces of code designed for a particular task.

Functions are executed by performing a function call.

```python
def addition(x, y):
return x + y # Returns the sum of x and y

# Function called with values for x and y
addition(11, 3)
```
18 changes: 18 additions & 0 deletions glossary/python/python-if-elif.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# If else

An `if` is a conditional statement that executes a piece of code if the condition is `true`.

An `else` statement is used after the `if` and it executes the code if the `if` condition evaluates to `false`.

`if-else` statements can be chained.

```python
number = 3

if (number > 3):
print("number is greater than", number)
elif (number < 3):
print("number is smaller than", number)
else:
print("number is equal to", number)
```
19 changes: 19 additions & 0 deletions glossary/python/python-while-loop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# While

A `while` loop is used when you want to execute a piece of code repeatedly.

```python
# Ask user for input
number = int(input("Enter a number: "))

product = 2
counter = 1

while counter <= number:
# Multiply product by itself
product *= product
# Increase counter
counter = counter+1

print("The product is", product)
```