Initialer Import der Synology Scripts
This commit is contained in:
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)
|
||||
Reference in New Issue
Block a user