[CT4101]: Add Topic 2 Examples

This commit is contained in:
2024-09-29 06:45:09 +01:00
parent 90824b5e03
commit 7a1f9943fc
8 changed files with 586 additions and 0 deletions

View File

@ -0,0 +1,13 @@
independent variable, dependent variable
30, 70
40, 90
40, 100
50, 120
50, 130
50, 150
60, 160
70, 190
70, 200
80, 200
80, 220
80, 230
1 independent variable dependent variable
2 30 70
3 40 90
4 40 100
5 50 120
6 50 130
7 50 150
8 60 160
9 70 190
10 70 200
11 80 200
12 80 220
13 80 230

View File

@ -0,0 +1 @@
print("Hello world!")

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,9 @@
public class staticvsdynamic1 {
public static void main(String[] args) {
int x = 4; // compiles ok
x = 5; // compiles ok
x = 3.14159; // compiler error
x = "Hello world!"; // compiler error
y = "abc123"; // compiler error
}
}

View File

@ -0,0 +1,5 @@
x = 4 # no errors
x = 5 # no errors
x = 3.14159 # no errors
x = "Hello world!" # no errors
y = "abc123" # no errors

View File

@ -0,0 +1,5 @@
import numpy as np
a = np.array((1, 2))
b = np.array((3, 4))
dist = np.linalg.norm(a-b)
print("The distance is:", dist)

View File

@ -0,0 +1,6 @@
x = 4
print(type(x)) # prints "<class 'int'>" to the console
x = "Hello world!"
print(type(x)) # prints "<class 'str'>" to the console
x = 3.14159
print(type(x)) # prints "<class 'float'>" to the console