Initialer Import der Synology Scripts
This commit is contained in:
Executable
BIN
Binary file not shown.
Executable
+17
@@ -0,0 +1,17 @@
|
||||
# EditorConfig is awesome: http://EditorConfig.org
|
||||
|
||||
root = true
|
||||
|
||||
[*]
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
end_of_line = lf
|
||||
|
||||
[*.md]
|
||||
trim_trailing_whitespace = false
|
||||
|
||||
[Makefile]
|
||||
indent_style = tab
|
||||
trim_trailing_whitespace = false
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
# Set the default behavior for all files.
|
||||
* text=auto eol=lf
|
||||
|
||||
# Normalized and converts to native line endings on checkout.
|
||||
*.py text
|
||||
*.pyx text
|
||||
Executable
+139
@@ -0,0 +1,139 @@
|
||||
################################
|
||||
########### FILES ############
|
||||
################################
|
||||
*.exe
|
||||
|
||||
################################
|
||||
########### FOLDERS ############
|
||||
################################
|
||||
build/
|
||||
html/
|
||||
.benchmarks/
|
||||
reports/
|
||||
lectures/
|
||||
logs/
|
||||
models/
|
||||
ressources/
|
||||
.ruff_cache
|
||||
data/*.h5
|
||||
venv/
|
||||
.venv/
|
||||
|
||||
################################
|
||||
########### PYTHON #############
|
||||
################################
|
||||
|
||||
# Byte-compiled / optimized / DLL files
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
*$py.class
|
||||
|
||||
# C extensions
|
||||
*.so
|
||||
|
||||
# Distribution / packaging
|
||||
.Python
|
||||
build/
|
||||
develop-eggs/
|
||||
dist/
|
||||
downloads/
|
||||
eggs/
|
||||
.eggs/
|
||||
lib/
|
||||
lib64/
|
||||
parts/
|
||||
sdist/
|
||||
var/
|
||||
wheels/
|
||||
*.egg-info/
|
||||
.installed.cfg
|
||||
*.egg
|
||||
MANIFEST
|
||||
|
||||
# PyInstaller
|
||||
# Usually these files are written by a python script from a template
|
||||
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
||||
*.manifest
|
||||
*.spec
|
||||
|
||||
# Installer logs
|
||||
pip-log.txt
|
||||
pip-delete-this-directory.txt
|
||||
|
||||
# Unit test / coverage reports
|
||||
htmlcov/
|
||||
.tox/
|
||||
.coverage
|
||||
.coverage.*
|
||||
.cache
|
||||
nosetests.xml
|
||||
coverage.xml
|
||||
*.cover
|
||||
.hypothesis/
|
||||
.pytest_cache/
|
||||
|
||||
# Translations
|
||||
*.mo
|
||||
*.pot
|
||||
|
||||
# Django stuff:
|
||||
*.log
|
||||
local_settings.py
|
||||
db.sqlite3
|
||||
|
||||
# Flask stuff:
|
||||
instance/
|
||||
.webassets-cache
|
||||
|
||||
# Scrapy stuff:
|
||||
.scrapy
|
||||
|
||||
# Sphinx documentation
|
||||
docs/build/
|
||||
|
||||
# PyBuilder
|
||||
target/
|
||||
|
||||
# Jupyter Notebook
|
||||
.ipynb_checkpoints
|
||||
|
||||
# pyenv
|
||||
.python-version
|
||||
|
||||
# celery beat schedule file
|
||||
celerybeat-schedule
|
||||
|
||||
# SageMath parsed files
|
||||
*.sage.py
|
||||
|
||||
# Environments
|
||||
.env
|
||||
.venv
|
||||
env/
|
||||
venv/
|
||||
ENV/
|
||||
env.bak/
|
||||
venv.bak/
|
||||
|
||||
# Spyder project settings
|
||||
.spyderproject
|
||||
.spyproject
|
||||
|
||||
# Rope project settings
|
||||
.ropeproject
|
||||
|
||||
# mkdocs documentation
|
||||
/site
|
||||
|
||||
# mypy
|
||||
.mypy_cache/
|
||||
.mypy_cache*
|
||||
|
||||
*.isorted
|
||||
|
||||
################################
|
||||
########### VS CODE ############
|
||||
################################
|
||||
.vscode/settings.json
|
||||
*.code-workspace
|
||||
.history
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
default_language_version:
|
||||
python: python3
|
||||
repos:
|
||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||
rev: v4.6.0
|
||||
hooks:
|
||||
- id: check-ast
|
||||
- id: check-builtin-literals
|
||||
- id: check-merge-conflict
|
||||
- id: check-yaml
|
||||
- id: check-toml
|
||||
|
||||
- repo: https://github.com/nbQA-dev/nbQA
|
||||
rev: 1.8.5
|
||||
hooks:
|
||||
- id: nbqa-isort
|
||||
|
||||
- repo: https://github.com/PyCQA/isort
|
||||
rev: 5.13.2
|
||||
hooks:
|
||||
- id: isort
|
||||
|
||||
- repo: https://github.com/astral-sh/ruff-pre-commit
|
||||
rev: v0.4.10
|
||||
hooks:
|
||||
- id: ruff-format
|
||||
types_or: [python, pyi, jupyter]
|
||||
|
||||
- repo: https://github.com/astral-sh/ruff-pre-commit
|
||||
rev: 'v0.4.10'
|
||||
hooks:
|
||||
- id: ruff
|
||||
types_or: [python, pyi, jupyter]
|
||||
args: [ --fix, --exit-non-zero-on-fix ]
|
||||
|
||||
- repo: https://github.com/pre-commit/mirrors-mypy
|
||||
rev: v1.10.0
|
||||
hooks:
|
||||
- id: mypy
|
||||
language: system
|
||||
pass_filenames: false
|
||||
args: ['.']
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
+23
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "PyDebug: Current File",
|
||||
"type": "debugpy",
|
||||
"request": "launch",
|
||||
"program": "${file}",
|
||||
"console": "integratedTerminal",
|
||||
"args": [],
|
||||
"justMyCode": true
|
||||
},
|
||||
{
|
||||
"name": "PyDebug: Main File",
|
||||
"type": "debugpy",
|
||||
"request": "launch",
|
||||
"program": "${workspaceFolder}/main.py",
|
||||
"console": "integratedTerminal",
|
||||
"args": [],
|
||||
"justMyCode": true
|
||||
}
|
||||
]
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"version": "2.0.0",
|
||||
"tasks": [
|
||||
{
|
||||
"label": "Python: Current File",
|
||||
"type": "shell",
|
||||
"command": "${command:python.interpreterPath} ${file}",
|
||||
"args": [],
|
||||
"group": "build"
|
||||
},
|
||||
{
|
||||
"label": "Python: Main File",
|
||||
"type": "shell",
|
||||
"command": "${command:python.interpreterPath} ${workspaceFolder}/main.py",
|
||||
"args": [],
|
||||
"group": "build"
|
||||
}
|
||||
]
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,3 @@
|
||||
print("Hello World!")
|
||||
# Notizen
|
||||
# print ist die einfache Prompt ausgabe!
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
@@ -0,0 +1,19 @@
|
||||
# Var name is left, value is right
|
||||
|
||||
price_per_item = 0.5
|
||||
amount = 10
|
||||
|
||||
order_price = price_per_item * amount # mult
|
||||
print(order_price)
|
||||
|
||||
shipping_cost = 3.0
|
||||
|
||||
total_cost = order_price + shipping_cost # add
|
||||
print(total_cost)
|
||||
|
||||
voucher = 2.0
|
||||
total_cost = total_cost - voucher # sub
|
||||
print(total_cost)
|
||||
|
||||
brothers_cost = total_cost / 2 # div
|
||||
print(brothers_cost)
|
||||
@@ -0,0 +1,28 @@
|
||||
var = 10
|
||||
|
||||
var += 2
|
||||
print(var)
|
||||
var = var + 2
|
||||
print(var)
|
||||
|
||||
var -= 2
|
||||
print(var)
|
||||
var = var - 2
|
||||
print(var)
|
||||
|
||||
var *= 2
|
||||
print(var)
|
||||
var = var * 2
|
||||
print(var)
|
||||
|
||||
var /= 2
|
||||
print(var)
|
||||
var = var / 2
|
||||
print(var)
|
||||
|
||||
|
||||
var2 = 13
|
||||
var3 = 3
|
||||
|
||||
var4 = var2 // var3 # // int div # / floating div
|
||||
print(var4)
|
||||
@@ -0,0 +1,30 @@
|
||||
students = {"Ben": 1, "Jan": 2, "Peter": 1, "Melissa": 4}
|
||||
print(students)
|
||||
|
||||
# Read element
|
||||
student1 = students["Ben"]
|
||||
print(student1)
|
||||
|
||||
# Write element
|
||||
students["Ben"] = 6
|
||||
print(students)
|
||||
|
||||
# Add element
|
||||
students["Julia"] = 1
|
||||
print(students)
|
||||
|
||||
# Remove element
|
||||
students.pop("Julia")
|
||||
print(students)
|
||||
|
||||
# Keys
|
||||
for student_name in students:
|
||||
print(student_name)
|
||||
|
||||
# Values
|
||||
for student_grade in students.values():
|
||||
print(student_grade)
|
||||
|
||||
# Keys and Values
|
||||
for key, value in students.items():
|
||||
print(key, value)
|
||||
@@ -0,0 +1,31 @@
|
||||
"""Exercise 1:
|
||||
1.)
|
||||
Write code that chekcs the integer **number**
|
||||
The number is greater than 10 or less than 0:
|
||||
if True: print "True" in the console
|
||||
if not True: print "False" in the console
|
||||
|
||||
2.)
|
||||
Write code that takes two floats x, y and computes:
|
||||
- x*x + x*y + y*y
|
||||
"""
|
||||
|
||||
# exercise1
|
||||
number = 8
|
||||
|
||||
# exercise2
|
||||
|
||||
x = 3.0
|
||||
y = 2.0
|
||||
|
||||
|
||||
|
||||
# SULUTION
|
||||
|
||||
if number < 0 or number > 10:
|
||||
print("TRUE")
|
||||
else:
|
||||
print("FALSE")
|
||||
|
||||
result = x*x + x*y + y*y
|
||||
print(result)
|
||||
@@ -0,0 +1,35 @@
|
||||
"""Exercise 2:
|
||||
1.)
|
||||
Write code that uses a list of integer and one integer number "a".
|
||||
There you should print the index where the number is present in the list.
|
||||
|
||||
2.)
|
||||
Write code that takes two integers (x, y) computes the following:
|
||||
Sum up all integer numbers from x (inclusive) to y (non-inclusive)
|
||||
with a step width of 2.
|
||||
"""
|
||||
|
||||
# exercise1
|
||||
lst = [1, 2, 3]
|
||||
a = 3
|
||||
|
||||
|
||||
# exercise2
|
||||
x = 2
|
||||
y = 10
|
||||
|
||||
|
||||
|
||||
# solution 1
|
||||
|
||||
if a in lst:
|
||||
print(lst.index(a))
|
||||
|
||||
|
||||
# solutionen 2
|
||||
|
||||
result = 0
|
||||
|
||||
for i in range(y, x, 2):
|
||||
result += 1
|
||||
print(result)
|
||||
@@ -0,0 +1,24 @@
|
||||
"""Exercise 3:
|
||||
1.)
|
||||
Write a function that takes a dictionary as an input.
|
||||
The function then iterates over all values and counts
|
||||
how many "Students" are in the dictionary.
|
||||
(See the dict "d" below)
|
||||
2.)
|
||||
Write a function that iterates over all key, value pairs
|
||||
of the dictionary "d" and only print the name of the students.
|
||||
"""
|
||||
|
||||
|
||||
def exercise1(dct):
|
||||
pass
|
||||
|
||||
|
||||
def exercise2(dct):
|
||||
pass
|
||||
|
||||
|
||||
d = {"Oskar": "Student", "Jan": "Instructor", "Thomas": "Student"}
|
||||
print(exercise1(d))
|
||||
|
||||
exercise2(d)
|
||||
@@ -0,0 +1,15 @@
|
||||
grades = [1, 2, 1, 4]
|
||||
|
||||
for grade in grades:
|
||||
print(grade)
|
||||
|
||||
print("")
|
||||
|
||||
for idx in range(len(grades)):
|
||||
print(grades[idx])
|
||||
|
||||
print("")
|
||||
|
||||
# range(start, stop, step)
|
||||
for idx in range(0, 10, 2):
|
||||
print(idx)
|
||||
@@ -0,0 +1,14 @@
|
||||
def list_max(input_list):
|
||||
max_value = input_list[0]
|
||||
|
||||
for i in range(1, len(input_list)):
|
||||
if input_list[i] > max_value:
|
||||
max_value = input_list[i]
|
||||
|
||||
print(max_value)
|
||||
|
||||
|
||||
list1 = [-2, 1, 2, -10, 22, -10]
|
||||
list_max(list1)
|
||||
list2 = [-20, 123, 112, -10, 22, -120]
|
||||
list_max(list2)
|
||||
@@ -0,0 +1,20 @@
|
||||
def test(param1, param2="hello", param3="byebye"):
|
||||
print("Test function: ", param1, " - ", param2, " - ", param3)
|
||||
|
||||
|
||||
test("hello", param2="byebye", param3="end")
|
||||
|
||||
|
||||
def list_max(input_list):
|
||||
max_value = input_list[0]
|
||||
|
||||
for i in range(1, len(input_list)):
|
||||
if input_list[i] > max_value:
|
||||
max_value = input_list[i]
|
||||
|
||||
return max_value
|
||||
|
||||
|
||||
list1 = [-2, 1, 2, -10, 22, -10]
|
||||
list1_max = list_max(list1)
|
||||
print(list1_max)
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
grades = [1, 2, 1]
|
||||
|
||||
print(grades)
|
||||
|
||||
grades.append(4)
|
||||
|
||||
print(grades)
|
||||
|
||||
grades.pop()
|
||||
|
||||
print(grades)
|
||||
|
||||
print("Ben's grade: ", grades[0])
|
||||
print("Jan's grade: ", grades[1])
|
||||
print("Peter's grade: ", grades[2])
|
||||
|
||||
grades[0] = 3
|
||||
|
||||
print(grades)
|
||||
|
||||
grades.pop(1)
|
||||
|
||||
print(grades)
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
# == (Equal)
|
||||
# < (Less than)
|
||||
# > (Greater than)
|
||||
# != (Not equal)
|
||||
# <= (Less or equal than)
|
||||
# >= (Greater or equal than)
|
||||
|
||||
my_bank_account = 130.0
|
||||
|
||||
i_am_broke = my_bank_account <= 0.0
|
||||
|
||||
if i_am_broke:
|
||||
print("I am broke!")
|
||||
else:
|
||||
print("I am not broke!")
|
||||
|
||||
gpu_price = 800.0
|
||||
my_bank_account = my_bank_account - gpu_price
|
||||
|
||||
i_am_broke = my_bank_account <= 0.0
|
||||
|
||||
if i_am_broke:
|
||||
print("I am broke!")
|
||||
else:
|
||||
print("I am not broke!")
|
||||
|
||||
my_age = 28
|
||||
|
||||
if my_age < 18:
|
||||
print("You are a child!")
|
||||
elif my_age < 67:
|
||||
print("You are an adult!")
|
||||
else:
|
||||
print("You are a pensioneer!")
|
||||
@@ -0,0 +1,28 @@
|
||||
# or := logische oder
|
||||
# and := logische und
|
||||
# not := logische verneinung
|
||||
|
||||
my_age = 28
|
||||
|
||||
if my_age < 3:
|
||||
print("You are a baby")
|
||||
elif my_age < 12:
|
||||
print("You are a teenager")
|
||||
elif my_age < 18:
|
||||
print("You are a child")
|
||||
elif my_age < 67:
|
||||
print("You are an adult!")
|
||||
else:
|
||||
print("You are a pensioneer!")
|
||||
|
||||
my_bank_account = 900.0
|
||||
|
||||
if (my_bank_account < 0.0) or (my_bank_account > 1000.0):
|
||||
print("If")
|
||||
else:
|
||||
print("Else")
|
||||
|
||||
if (my_bank_account > 0.0) and (my_bank_account < 1000.0):
|
||||
print("If")
|
||||
else:
|
||||
print("Else")
|
||||
@@ -0,0 +1,23 @@
|
||||
my_name_is_jan = True
|
||||
my_name_is_ben = False
|
||||
|
||||
|
||||
print(not my_name_is_jan)
|
||||
print(not my_name_is_ben)
|
||||
|
||||
my_var = 10
|
||||
|
||||
if my_var < 100 and my_var > 0: # (0, 100)
|
||||
print("yes")
|
||||
else:
|
||||
print("no")
|
||||
|
||||
if not (my_var < 100 and my_var > 0): # (-inf, 0] or [100, inf)
|
||||
print("yes")
|
||||
else:
|
||||
print("no")
|
||||
|
||||
if my_var >= 100 or my_var <= 0: # (-inf, 0] or [100, inf)
|
||||
print("yes")
|
||||
else:
|
||||
print("no")
|
||||
@@ -0,0 +1,27 @@
|
||||
"""Exercise 1:
|
||||
1.)
|
||||
Write code that chekcs the integer **number**
|
||||
The number is greater than 10 or less than 0:
|
||||
if True: print "True" in the console
|
||||
if not True: print "False" in the console
|
||||
|
||||
2.)
|
||||
Write code that takes two floats x, y and computes:
|
||||
- x*x + x*y + y*y
|
||||
"""
|
||||
|
||||
# exercise1
|
||||
number = 8
|
||||
|
||||
if number > 10 or number < 0:
|
||||
print("True")
|
||||
else:
|
||||
print("False")
|
||||
|
||||
# exercise2
|
||||
|
||||
x = 3.0
|
||||
y = 2.0
|
||||
|
||||
result = x * x + x * y + y * y
|
||||
print(result)
|
||||
@@ -0,0 +1,26 @@
|
||||
"""Exercise 2:
|
||||
1.)
|
||||
Write code that uses a list of integer and one integer number "a".
|
||||
There you should print the index where the number is present in the list.
|
||||
|
||||
2.)
|
||||
Write code that takes two integers (x, y) computes the following:
|
||||
Sum up all integer numbers from x (inclusive) to y (non-inclusive)
|
||||
with a step width of 2.
|
||||
"""
|
||||
|
||||
# exercise1
|
||||
lst = [1, 2, 3]
|
||||
a = 3
|
||||
if a in lst:
|
||||
print(lst.index(a))
|
||||
|
||||
|
||||
# exercise2
|
||||
x = 2
|
||||
y = 10
|
||||
|
||||
result = 0
|
||||
for i in range(x, y, 2):
|
||||
result += i
|
||||
print(result)
|
||||
@@ -0,0 +1,30 @@
|
||||
"""Exercise 3:
|
||||
1.)
|
||||
Write a function that takes a dictionary as an input.
|
||||
The function then iterates over all values and counts
|
||||
how many "Students" are in the dictionary.
|
||||
(See the dict "d" below)
|
||||
2.)
|
||||
Write a function that iterates over all key, value pairs
|
||||
of the dictionary "d" and only print the name of the students.
|
||||
"""
|
||||
|
||||
|
||||
def exercise1(dct):
|
||||
num_students = 0
|
||||
for val in dct.values():
|
||||
if val == "Student":
|
||||
num_students += 1
|
||||
return num_students
|
||||
|
||||
|
||||
def exercise2(dct):
|
||||
for key, val in dct.items():
|
||||
if val == "Student":
|
||||
print(key, "is a student")
|
||||
|
||||
|
||||
d = {"Oskar": "Student", "Jan": "Instructor", "Thomas": "Student"}
|
||||
print(exercise1(d))
|
||||
|
||||
exercise2(d)
|
||||
@@ -0,0 +1,30 @@
|
||||
name = "Jan Maximilan Schaffranek"
|
||||
|
||||
|
||||
result = name.find("an")
|
||||
|
||||
if result == -1:
|
||||
print("Not found")
|
||||
else:
|
||||
print("Found at index: ", result)
|
||||
|
||||
|
||||
name2 = name.replace("Jan", "Yann")
|
||||
print(name)
|
||||
print(name2)
|
||||
|
||||
|
||||
name3 = name.upper()
|
||||
print(name3)
|
||||
|
||||
|
||||
name4 = name.lower()
|
||||
print(name4)
|
||||
|
||||
|
||||
name5 = name.split(" ")
|
||||
print(name5)
|
||||
|
||||
|
||||
count = name.count("an")
|
||||
print(count)
|
||||
@@ -0,0 +1,11 @@
|
||||
# 1. var names cannot contain whitespaces
|
||||
# 2. var names cannot start with a number
|
||||
|
||||
my_age = 28 # int
|
||||
price_for_one_item = 0.5 # float
|
||||
my_name_is_jan = True # bool
|
||||
my_name_is_peter = False # bool
|
||||
my_name = "Jan Schaffranek" # str
|
||||
|
||||
print(my_name)
|
||||
print(my_age)
|
||||
@@ -0,0 +1,5 @@
|
||||
bank_account = 1000.0
|
||||
|
||||
while bank_account > 0.0:
|
||||
bank_account = bank_account - 100.0
|
||||
print(bank_account)
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
@@ -0,0 +1,10 @@
|
||||
from MyModule import list_max
|
||||
from MyModule import list_min
|
||||
|
||||
|
||||
list1 = [-2, 1, 2, -10, 22, -10]
|
||||
list_max(list1)
|
||||
list_min(list1)
|
||||
list2 = [-20, 123, 112, -10, 22, -120]
|
||||
list_max(list2)
|
||||
list_min(list2)
|
||||
@@ -0,0 +1,15 @@
|
||||
from MyModule import list_max
|
||||
from MyModule import list_min
|
||||
|
||||
|
||||
def main():
|
||||
list1 = [-2, 1, 2, -10, 22, -10]
|
||||
list_max(list1)
|
||||
list_min(list1)
|
||||
list2 = [-20, 123, 112, -10, 22, -120]
|
||||
list_max(list2)
|
||||
list_min(list2)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,23 @@
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
|
||||
grades_jan = [56, 64, 78, 100]
|
||||
grades_ben = [86, 94, 98, 90]
|
||||
|
||||
|
||||
plt.plot(range(len(grades_jan)), grades_jan, color="blue")
|
||||
plt.plot(range(len(grades_ben)), grades_ben, color="red")
|
||||
plt.xlabel("Courses")
|
||||
plt.ylabel("Grade (in %)")
|
||||
plt.legend(["Jan", "Ben"])
|
||||
plt.title("Jan vs. Ben")
|
||||
plt.show()
|
||||
|
||||
|
||||
plt.scatter(range(len(grades_jan)), grades_jan, c="blue")
|
||||
plt.scatter(range(len(grades_ben)), grades_ben, c="red")
|
||||
plt.xlabel("Courses")
|
||||
plt.ylabel("Grade (in %)")
|
||||
plt.legend(["Jan", "Ben"])
|
||||
plt.title("Jan vs. Ben")
|
||||
plt.show()
|
||||
@@ -0,0 +1,22 @@
|
||||
def list_max(input_list):
|
||||
max_value = input_list[0]
|
||||
|
||||
for i in range(1, len(input_list)):
|
||||
if input_list[i] > max_value:
|
||||
max_value = input_list[i]
|
||||
|
||||
print(max_value)
|
||||
|
||||
|
||||
def list_min(input_list):
|
||||
max_value = input_list[0]
|
||||
|
||||
for i in range(1, len(input_list)):
|
||||
if input_list[i] < max_value:
|
||||
max_value = input_list[i]
|
||||
|
||||
print(max_value)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
print("Hello from MyModule")
|
||||
@@ -0,0 +1,16 @@
|
||||
import numpy as np
|
||||
|
||||
|
||||
vec = np.array([1, 2, 3, 4, 5])
|
||||
print(np.max(vec))
|
||||
print(np.min(vec))
|
||||
print(np.median(vec))
|
||||
print(np.mean(vec))
|
||||
print(vec.shape)
|
||||
|
||||
matrix = np.array([[1, 2], [3, 4]])
|
||||
print(np.max(matrix))
|
||||
print(np.min(matrix))
|
||||
print(np.median(matrix))
|
||||
print(np.mean(matrix))
|
||||
print(matrix.shape)
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
@@ -0,0 +1,26 @@
|
||||
# C++, Java: this
|
||||
|
||||
|
||||
class Animal:
|
||||
def __init__(self, weight, height):
|
||||
self.weight = weight
|
||||
self.height = height
|
||||
|
||||
def jump(self):
|
||||
print("Jump!")
|
||||
|
||||
|
||||
def main():
|
||||
dog = Animal(10, 0.8)
|
||||
print(dog.height)
|
||||
print(dog.weight)
|
||||
dog.jump()
|
||||
|
||||
cat = Animal(3, 0.3)
|
||||
print(cat.height)
|
||||
print(cat.weight)
|
||||
cat.jump()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,10 @@
|
||||
dct = {"Jan": 27, "Peter": 33}
|
||||
lst = [1, 2, 3]
|
||||
|
||||
|
||||
try:
|
||||
print(lst[3])
|
||||
except KeyError as e:
|
||||
print(e)
|
||||
except IndexError as e:
|
||||
print(e)
|
||||
@@ -0,0 +1,30 @@
|
||||
"""Exercise 4:
|
||||
1.)
|
||||
Write a function that takes an integer number "n" as an input.
|
||||
The function returns a list with all power of twos (2^n)
|
||||
from 0 to n-1. Use a list comprehension.
|
||||
2.)
|
||||
Write a function that takes the resulting list from 1.) as
|
||||
an input. Iterate over all values of the list and print
|
||||
the current index and the current value in each iteration.
|
||||
"""
|
||||
|
||||
|
||||
def exercise1(n):
|
||||
pass
|
||||
|
||||
|
||||
def exercise2(lst):
|
||||
pass
|
||||
|
||||
|
||||
def main():
|
||||
n = 10
|
||||
lst = exercise1(n)
|
||||
print(lst)
|
||||
|
||||
exercise2(lst)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,30 @@
|
||||
"""Exercise 5:
|
||||
1.)
|
||||
Write a class Student that has the following member variables:
|
||||
- Name (String)
|
||||
- Lastname (String)
|
||||
- Age (Integer)
|
||||
- Id (Integer)
|
||||
2.)
|
||||
Write a method that prints the information about the student.
|
||||
E.g. Student('Jan', 'Schaffranek', 27, 1080133228459) will print:
|
||||
'Jan Schaffranek is 27 years old and has the id 1080133228459'
|
||||
"""
|
||||
|
||||
|
||||
class Student:
|
||||
pass
|
||||
|
||||
def print_student(self):
|
||||
pass
|
||||
|
||||
|
||||
def main():
|
||||
oskar = Student("Oskar", "Oskarson", 29, 1080132254623)
|
||||
oskar.print_student()
|
||||
jan = Student("Jan", "Schaffranek", 28, 1080133228459)
|
||||
jan.print_student()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,14 @@
|
||||
input_filepath = "C:/Users/Jan/OneDrive/_Coding/UdemyPythonIntro/Chapter4_Intermediate/test.txt" # noqa: E501
|
||||
output_filepath = "C:/Users/Jan/OneDrive/_Coding/UdemyPythonIntro/Chapter4_Intermediate/test_out.txt" # noqa: E501
|
||||
|
||||
|
||||
with open(input_filepath) as file:
|
||||
content = file.readlines()
|
||||
|
||||
|
||||
print(content)
|
||||
content.append("Tom Tomerson\n")
|
||||
|
||||
|
||||
with open(output_filepath, "w") as file:
|
||||
file.writelines(content)
|
||||
@@ -0,0 +1,38 @@
|
||||
class Animal:
|
||||
def __init__(self, weight, height):
|
||||
self.weight = weight
|
||||
self.height = height
|
||||
|
||||
def print_data(self):
|
||||
print("Height: ", self.height)
|
||||
print("Weight: ", self.weight)
|
||||
|
||||
|
||||
class Dog(Animal):
|
||||
def __init__(self, weight, height):
|
||||
super().__init__(weight, height)
|
||||
|
||||
def bark(self):
|
||||
print("Bark!")
|
||||
|
||||
|
||||
class Cat(Animal):
|
||||
def __init__(self, weight, height):
|
||||
super().__init__(weight, height)
|
||||
|
||||
def meow(self):
|
||||
print("Meow!")
|
||||
|
||||
|
||||
def main():
|
||||
dog = Dog(10, 0.8)
|
||||
dog.print_data()
|
||||
dog.bark()
|
||||
|
||||
cat = Cat(3, 0.3)
|
||||
cat.print_data()
|
||||
cat.meow()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,31 @@
|
||||
# break, continue, pass, None
|
||||
|
||||
l1 = [1, 2, 3, 4, 5]
|
||||
|
||||
for val in l1:
|
||||
if val > 3:
|
||||
break
|
||||
print(val)
|
||||
|
||||
|
||||
print("")
|
||||
|
||||
|
||||
for val in l1:
|
||||
if val % 2 == 0:
|
||||
continue
|
||||
print(val)
|
||||
|
||||
|
||||
def print_list(l1):
|
||||
pass
|
||||
|
||||
|
||||
print_list(l1)
|
||||
|
||||
|
||||
print("")
|
||||
|
||||
|
||||
val1 = None
|
||||
print(val1)
|
||||
@@ -0,0 +1,15 @@
|
||||
list_a = []
|
||||
|
||||
for _i in range(100):
|
||||
list_a.append(5)
|
||||
|
||||
print(list_a)
|
||||
|
||||
# List comp
|
||||
list_b = [5 for i in range(100)]
|
||||
|
||||
print(list_b)
|
||||
|
||||
list_c = [i**2 for i in range(100)]
|
||||
|
||||
print(list_c)
|
||||
@@ -0,0 +1,19 @@
|
||||
list_a = list(range(10))
|
||||
|
||||
print(list_a)
|
||||
|
||||
list_b = [list_a[i] for i in range(3)]
|
||||
|
||||
print(list_b)
|
||||
|
||||
# List Slicing
|
||||
|
||||
# Start, Stop, Step
|
||||
list_c = list_a[0:3:1]
|
||||
|
||||
print(list_c)
|
||||
|
||||
list_c[0] = -100
|
||||
|
||||
print(list_a)
|
||||
print(list_c)
|
||||
@@ -0,0 +1,16 @@
|
||||
num_rows = 3
|
||||
num_cols = 2
|
||||
|
||||
matrix = [
|
||||
[(i * num_cols + j) + 1 for j in range(num_cols)] for i in range(num_rows)
|
||||
]
|
||||
|
||||
print(matrix)
|
||||
|
||||
matrix2 = [[0 for j in range(num_cols)] for i in range(num_rows)]
|
||||
|
||||
print(matrix2)
|
||||
|
||||
matrix2[0][0] = 1
|
||||
|
||||
print(matrix2)
|
||||
@@ -0,0 +1,12 @@
|
||||
# (3,)
|
||||
vector = [1, 2, 3]
|
||||
|
||||
print(vector)
|
||||
|
||||
# (3, 2)
|
||||
matrix = [[1, 2], [3, 4], [5, 6]]
|
||||
|
||||
print(matrix)
|
||||
|
||||
print(matrix[0])
|
||||
print(matrix[1][0])
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user