Skip to content
This repository was archived by the owner on Feb 27, 2026. It is now read-only.

Commit 0081b5e

Browse files
authored
Merge branch 'main' into edit-user-persona
2 parents 2c63cfb + 9b1798b commit 0081b5e

3 files changed

Lines changed: 153 additions & 2 deletions

File tree

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
---
2+
Title: 'Lists'
3+
Description: 'A List in C# is a dynamic data structure that stores multiple objects of a specified type.'
4+
Subjects:
5+
- 'Computer Science'
6+
- 'Code Foundations'
7+
- 'Developer Tools'
8+
Tags:
9+
- 'Data Structures'
10+
- 'Lists'
11+
CatalogContent:
12+
- 'learn-c-sharp'
13+
- 'paths/computer-science'
14+
---
15+
16+
A **`List`** in [C#](https://www.codecademy.com/resources/docs/c-sharp) is a dynamic [data structure](https://www.codecademy.com/resources/docs/general/data-structures) that stores multiple objects of a specified type. These objects can be accessed by their zero-based index. Unlike [arrays](https://www.codecademy.com/resources/docs/c-sharp/arrays). Lists can grow to accommodate a very large number of elements (up to about 2 billion), limited primarily by available system memory and the maximum value of an integer index."
17+
18+
## Syntax
19+
20+
> **Note:** Before creating a list, include the `System.Collections.Generic` namespace.
21+
22+
There are two common ways to create a `List` in C#:
23+
24+
```pseudo
25+
// Creating a List without any elements
26+
List<T> myList = new List<T>();
27+
```
28+
29+
Or alternatively:
30+
31+
```pseudo
32+
// Creating a List with three elements
33+
List<T> myList = new List<T> { element1, element2, element3 };
34+
```
35+
36+
**Parameters:**
37+
38+
- `T`: Represents any data type.
39+
- `element`: Any object or variable of type `T`.
40+
41+
## Example: Creating and Accessing a List
42+
43+
In this example, a list is created, numbers are added, and elements are accessed by their index:
44+
45+
```cs
46+
using System;
47+
using System.Collections.Generic;
48+
49+
class Program
50+
{
51+
static void Main()
52+
{
53+
// Create a list of integers
54+
List<int> numbers = new List<int>();
55+
56+
// Add elements to the list
57+
numbers.Add(10);
58+
numbers.Add(20);
59+
numbers.Add(30);
60+
61+
// Access elements by index
62+
Console.WriteLine(numbers[0]);
63+
Console.WriteLine(numbers[1]);
64+
Console.WriteLine(numbers[2]);
65+
}
66+
}
67+
```
68+
69+
The output of this code is:
70+
71+
```shell
72+
10
73+
20
74+
30
75+
```
76+
77+
## Codebyte Example: Printing elements in a List
78+
79+
This example creates a new `List` that stores three numbers. Since each element has an index, we can print each element in the `numbers` list by its index:
80+
81+
```codebyte/csharp
82+
using System;
83+
using System.Collections.Generic;
84+
85+
public class Test
86+
{
87+
public static void Main()
88+
{
89+
List<int> numbers = new List<int> { 2, 5, 10 };
90+
91+
Console.WriteLine(numbers[0]);
92+
Console.WriteLine(numbers[1]);
93+
Console.WriteLine(numbers[2]);
94+
}
95+
}
96+
```

content/java/concepts/strings/terms/equals/equals.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ public class MyClass {
3636

3737
// With string objects
3838
String myFavoriteLanguage = "Java";
39-
String codeNinjasFavoriteLangauge = "Java";
40-
System.out.println(myFavoriteLanguage.equals(codeNinjasFavoriteLangauge));
39+
String codeNinjasFavoriteLanguage = "Java";
40+
System.out.println(myFavoriteLanguage.equals(codeNinjasFavoriteLanguage));
4141
}
4242
}
4343
```
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
---
2+
Title: '.floor_divide()'
3+
Description: 'Computes element-wise division of tensors (or tensor and scalar) and applies floor rounding.'
4+
Subjects:
5+
- 'Computer Science'
6+
- 'Machine Learning'
7+
Tags:
8+
- 'Functions'
9+
- 'Machine Learning'
10+
- 'Python'
11+
- 'Tensor'
12+
CatalogContent:
13+
- 'intro-to-py-torch-and-neural-networks'
14+
- 'paths/computer-science'
15+
---
16+
17+
In PyTorch, the **`.floor_divide()`** function divides the `input` by other element-wise and rounds each quotient down to the nearest integer, returning the floored result as a [tensor](https://www.codecademy.com/resources/docs/pytorch/tensors). It supports broadcasting, type promotion, and both integer and floating-point operands. The operation can be expressed as:
18+
19+
$$\text{out}_i = \text{floor}(\frac{\text{input}_i}{\text{other}_i})$$
20+
21+
## Syntax
22+
23+
```pseudo
24+
torch.floor_divide(input, other, *, out=None) → Tensor
25+
```
26+
27+
**Parameters:**
28+
29+
- `input`: The input tensor(dividend).
30+
- `other`: Tensor or Number(divisor).
31+
- `out` (Optional): A tensor to store the output. If provided, the result is written to this tensor.
32+
33+
**Return value:**
34+
35+
It returns a new tensor of the same shape as the `input`, containing the result of element-wise division and rounds the result of the division down to the nearest integer.
36+
37+
## Example
38+
39+
In this example, we use `floor_divide()` to perform divison of two tensors `x` and `y` :
40+
41+
```py
42+
import torch
43+
44+
x = torch.tensor([4.0, 3.0])
45+
46+
y = torch.tensor([2.0, 2.0])
47+
48+
print(torch.floor_divide(x, y))
49+
```
50+
51+
The output of this code is:
52+
53+
```shell
54+
tensor([2., 1.])
55+
```

0 commit comments

Comments
 (0)