latptop
authorNilsForssen <forssennils@gmail.com>
Tue, 1 Feb 2022 09:16:08 +0000 (10:16 +0100)
committerNilsForssen <forssennils@gmail.com>
Tue, 1 Feb 2022 09:16:08 +0000 (10:16 +0100)
29 files changed:
Laboration1/del1.txt [deleted file]
Laboration1/pythonskript.py [deleted file]
Laboration1/uppgift_1.py [deleted file]
Laboration1/uppgift_1.txt [deleted file]
Laboration1/uppgift_2.py [deleted file]
Laboration1/uppgift_2.txt [deleted file]
Laboration1/uppgift_3.py [deleted file]
Laboration1/uppgift_3.txt [deleted file]
__init__.py [new file with mode: 0644]
laboration1/__init__.py [new file with mode: 0644]
laboration1/__pycache__/myTest.cpython-38.pyc [new file with mode: 0644]
laboration1/del1.txt [new file with mode: 0644]
laboration1/myTest.py [new file with mode: 0644]
laboration1/pythonskript.py [new file with mode: 0644]
laboration1/uppgift_1.py [new file with mode: 0644]
laboration1/uppgift_1.txt [new file with mode: 0644]
laboration1/uppgift_1_test.py [new file with mode: 0644]
laboration1/uppgift_2.py [new file with mode: 0644]
laboration1/uppgift_2.txt [new file with mode: 0644]
laboration1/uppgift_3.py [new file with mode: 0644]
laboration1/uppgift_3.txt [new file with mode: 0644]
laboration2/med.py [new file with mode: 0755]
laboration2/uppgift_1.py [new file with mode: 0644]
laboration2/uppgift_1.txt [new file with mode: 0644]
laboration2/uppgift_2.py [new file with mode: 0644]
laboration2/uppgift_2.txt [new file with mode: 0644]
laboration2/uppgift_3.py [new file with mode: 0644]
test.py [deleted file]
test2.py [deleted file]

diff --git a/Laboration1/del1.txt b/Laboration1/del1.txt
deleted file mode 100644 (file)
index d6f34cc..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-mkdir minKatalog
-cd /courses/TDDE44/kursmaterial/laboration1
-ls 
-cat virus.exe
-cp virus.exe /home/nilfo359/minKatalog
-mv virus.exe mitt_skript.sh
-sh mitt_skript.sh  ###eller### ls -la; chmod 'u+x' mitt_skript.sh; ./mitt_skript.sh
-code virus.exe
-###Lägg till:### 
-cd /home/nilfo359/
-ls
-###----------###
\ No newline at end of file
diff --git a/Laboration1/pythonskript.py b/Laboration1/pythonskript.py
deleted file mode 100644 (file)
index 60d4f93..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-#!/usr/bin/env python3
-
-# OM EXEKVERBARA TEXTFILER
-#
-# När en exekverbar textfil körs i terminalen tittar systemet (dvs skalet på den
-# _första_ raden i filen. Om den första raden börjar med tecknena #! kommer
-# resten av raden att användas som en sökväg till det program som ska användas
-# för att tolka resten av filen.
-#
-# När denna fil körs i terminalen kommer python3 att användas för att tolka
-# innehållet. För användaren som kör filen är det ingen skillnad på att köra ett
-# kompilerat program och ett skript.
-#
-# Den här filen heter pythonskript.py, men filnamnet har egenligen ingen
-# betydelse. Om man döper om denna fil till dota kommer samma sak att hända när
-# man kör den.
-#
-# Det enda som har någon betydelse är om användaren har rätt att exekvera filen,
-# och innehållet i filen.
-
-# Här importeras modulen sys som hjälper oss interagera med systemet
-import sys
-
-def demonstrate_sysargv():
-    print("I variabeln sys.argv hittar vi en lista vars första element är")
-    print("kommandot som skrevs. Efterföljande element i listan är alla")
-    print("argument som angavs. Se här:\n")
-    print(sys.argv)
-    print("\nProva att köra detta kommando igen och skicka med några argument")
-    print("också!")
-
-# UPPGIFT!
-#
-# Er uppgift är att ta bort ordet pass i funktionen nedan och skriva Pythonkod
-# som skriver ut det första argumentet som skickades till detta skript.
-#
-# När ni gjort det, ändra på anropet längst ner i denna fil så att funktionen
-# say_hello() körs istället.
-def say_hello():
-    print(sys.argv[1])
-
-# Här är anropet till den funktion som ska användas när detta skript körs.
-# När ni skrivit klart funktionen say_hello(), ändra anropet nedan så
-# att den körs istället!
-say_hello()
-
diff --git a/Laboration1/uppgift_1.py b/Laboration1/uppgift_1.py
deleted file mode 100644 (file)
index 31334f1..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-# Uppgift 1
-
-import math
-
-def return_five():
-    return "five"
-
-def print_five():
-    print("five")
-
-def add_strings():
-    return "hej" + "san"
-
-def use_the_var():
-    value = 5
-    return value * 5
-
-def use_the_arg(a_string):
-    print(a_string)
-    return a_string
-
-def to_string(a_value):
-    return str(a_value)
-
-def to_integer(a_value):
-    return int(a_value)
-
-def to_float(a_value):
-    return float(a_value)
-
-def to_any_type(a_value, a_type):
-    return a_type(a_value)
-
-def print_type(a_value):
-    print(type(a_value))
-
-def subtract(value1, value2):
-    return value1 - value2
-
-def split_bill(amount, number_of_people):
-    print(amount / number_of_people)
-    return amount / number_of_people
-
-def round_up(value):
-    return math.ceil(value)
-
-def round_down(value):
-    return math.floor(value)
-
-def fahrenheit_to_celsius(temperature):
-    return (temperature - 32) * (5/9)
-
-def celsius_to_fahrenheit(temperature):
-    return (temperature * (9/5) + 32)
-
-def pythagoras(x, y):
-    return (x**2 + y**2)**(1/2)
-
-if __name__ == "__main__":
-    pass
\ No newline at end of file
diff --git a/Laboration1/uppgift_1.txt b/Laboration1/uppgift_1.txt
deleted file mode 100644 (file)
index 8d9bff4..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-UEsDBBQAAAAIAJuAM1QWfLPzhAEAACEEAAAaABwAbmlsZm8zNTktcHl1cHBnMV8xL29yaWcucHlV
-VAkAA5Yo6GGWKOhhdXgLAAEEehxpWQQA4fUFjVPNjtsgEL77KZD3gr3ZRkmVw66Ux+h5NInHNpUN
-CHC6fvsdB5KaNCvVF8T3NzCDX8QvazvVBrErCjVa44IYMfRF0VArHIXJaWjVhWT1UQj+IiTKBSuj
-yjqlQya6IjJqqijCpgEfGO/8Y1RPv0vxKkqPOiVOniD0BBd0N/EFh4nEURzW1gjWDGY2dJ3EVC07
-0R1ch9zAmBFM2rL4Gp8flrk7cTdwNHXknjti3QdHOxgMz/U5dXegniHMlm7Mhs+97HMzZppqPZ+M
-WDclI5LFT6fg8BzkFd1tYqf3ebHIibdEJqcdVICTGgaJo5l02Ag9jSdyYFqwZOyQV48isf1Xld3r
-O1V6p8w2MFn5pJ/La/5xJjXIdU+iozF/9LceHoRxman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BQADlijoYXV4CwABBHocaVkEAOH1BVBLAQIeAxQAAAAIAJuAM1RJu0MTeQAA
-AJQAAAAbABgAAAAAAAEAAACkgf4CAABuaWxmbzM1OS1weXVwcGcxXzEvaW5mby50eHRVVAUAA5Yo
-6GF1eAsAAQR6HGlZBADh9QVQSwUGAAAAAAMAAwArAQAAzAMAAAAA
\ No newline at end of file
diff --git a/Laboration1/uppgift_2.py b/Laboration1/uppgift_2.py
deleted file mode 100644 (file)
index c000985..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-# Uppgift 2
-
-import random
-
-def second_in_list(values):
-    return values[1]
-
-def last_in_list(values):
-    return values[-1]
-
-def second_last_in_list(values):
-    return values[-2]
-
-def n_in_list(values, n):
-    return values[n]
-
-def three_first_in_list(values):
-    return values[:3] # return (values[0], values[1], values[2])
-
-def three_last_in_list(values):
-    return values[-3:]
-
-def but_five_last_in_list(values):
-    return values[:-5]
-
-def every_other_in_list(values):
-    return values[::2]
-
-def two_around_n_in_list(values, n):
-    return values[n-2:n+3]
-
-def new_list_with_n(values, n):
-    return [*values, n]
-
-def append_n_to_list(values, a_value):
-    values.append(a_value)
-    return values
-
-def insert_4_on_pos_3(values):
-    values.insert(3, 4)
-    return values
-
-def extend_vals_to_list(values1, values2):
-    values1.extend(values2)
-    return values1
-
-def remove_from_third_in_list(values):
-    del values[2:]
-    return values
-
-def concatenate_lists(values1, values2):
-    return [*values1, *values2]
-
-def select_random(values):
-    return random.choice(values)
-    
\ No newline at end of file
diff --git a/Laboration1/uppgift_2.txt b/Laboration1/uppgift_2.txt
deleted file mode 100644 (file)
index 3423621..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-UEsDBBQAAAAIALuAM1S5y9gqSwEAAEEEAAAaABwAbmlsZm8zNTktcHl1cHBnMV8yL29yaWcucHlV
-VAkAA9Io6GHSKOhhdXgLAAEEehxpWQQA4fUFjVPbboMwDH3nKyL1hW5tNaB94T/2VCErAzMiQYIS
-025/v4wkbL0gBQkpss85PrHj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gMUAAAACAC7gDNUucvYKksBAABBBAAAGgAYAAAAAAABAAAApIEAAAAAbmlsZm8zNTkt
-cHl1cHBnMV8yL29yaWcucHlVVAUAA9Io6GF1eAsAAQR6HGlZBADh9QVQSwECHgMUAAAACAC7gDNU
-iGiPTMcAAAAKAgAAJAAYAAAAAAABAAAApIGfAQAAbmlsZm8zNTktcHl1cHBnMV8yL3B5dXBwZ3Rl
-c3QxXzIubG9nVVQFAAPSKOhhdXgLAAEEehxpWQQA4fUFUEsBAh4DFAAAAAgAu4AzVNlGFWd5AAAA
-lAAAABsAGAAAAAAAAQAAAKSBxAIAAG5pbGZvMzU5LXB5dXBwZzFfMi9pbmZvLnR4dFVUBQAD0ijo
-YXV4CwABBHocaVkEAOH1BVBLBQYAAAAAAwADACsBAACSAwAAAAA=
\ No newline at end of file
diff --git a/Laboration1/uppgift_3.py b/Laboration1/uppgift_3.py
deleted file mode 100644 (file)
index eb58156..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-# Uppgift 3
-
-import random
-
-def concatenate_strings(string1, string2):
-    return string1 + string2
-
-def use_the_linebreak():
-    print("rad 1\nrad 2")
-    return "rad 1\nrad 2"
-
-def generate_pokemon_name(prefixes, suffixes):
-    return random.choice(prefixes) + random.choice(suffixes)
-
-def first_word(s):
-    return s.split()[0]
-
-def join_list(values):
-    return ":".join(values)
-
-def remove_spaces(s):
-    return s.rstrip()
-
-def get_characters(s, pos, num_of_chars):
-    return s[pos:pos+num_of_chars]
-
-
-print(get_characters("Ett ytterligare exempel", 4, 11))
-
diff --git a/Laboration1/uppgift_3.txt b/Laboration1/uppgift_3.txt
deleted file mode 100644 (file)
index 52c3252..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-UEsDBBQAAAAIAOGAM1TnqvMgHAEAADUCAAAaABwAbmlsZm8zNTktcHl1cHBnMV8zL29yaWcucHlV
-VAkAAxYp6GEWKehhdXgLAAEEehxpWQQA4fUFZVDBTsMwDL33K6xySbVqooPT7nwCp4GikLpdW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vb3JpZy5weVVUBQADFino
-YXV4CwABBHocaVkEAOH1BVBLAQIeAxQAAAAIAOGAM1RYYA5QpQAAACkBAAAkABgAAAAAAAEAAACk
-gXABAABuaWxmbzM1OS1weXVwcGcxXzMvcHl1cHBndGVzdDFfMy5sb2dVVAUAAxYp6GF1eAsAAQR6
-HGlZBADh9QVQSwECHgMUAAAACADhgDNUhn3gNngAAACUAAAAGwAYAAAAAAABAAAApIFzAgAAbmls
-Zm8zNTktcHl1cHBnMV8zL2luZm8udHh0VVQFAAMWKehhdXgLAAEEehxpWQQA4fUFUEsFBgAAAAAD
-AAMAKwEAAEADAAAAAA==
\ No newline at end of file
diff --git a/__init__.py b/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/laboration1/__init__.py b/laboration1/__init__.py
new file mode 100644 (file)
index 0000000..4c0ec1f
--- /dev/null
@@ -0,0 +1 @@
+from .myTest import *
diff --git a/laboration1/__pycache__/myTest.cpython-38.pyc b/laboration1/__pycache__/myTest.cpython-38.pyc
new file mode 100644 (file)
index 0000000..3ce8080
Binary files /dev/null and b/laboration1/__pycache__/myTest.cpython-38.pyc differ
diff --git a/laboration1/del1.txt b/laboration1/del1.txt
new file mode 100644 (file)
index 0000000..7fb2ca7
--- /dev/null
@@ -0,0 +1,13 @@
+mkdir minKatalog
+cd /courses/TDDE44/kursmaterial/laboration1
+ls 
+cat virus.exe
+cp virus.exe /home/nilfo359/minKatalog
+mv virus.exe mitt_skript.sh
+sh mitt_skript.sh  ###eller### ls -la; chmod 'u+x' mitt_skript.sh; ./mitt_skript.sh
+code virus.exe
+
+###Lägg till:### 
+cd /home/nilfo359/
+ls
+###----------###
\ No newline at end of file
diff --git a/laboration1/myTest.py b/laboration1/myTest.py
new file mode 100644 (file)
index 0000000..31334f1
--- /dev/null
@@ -0,0 +1,60 @@
+# Uppgift 1
+
+import math
+
+def return_five():
+    return "five"
+
+def print_five():
+    print("five")
+
+def add_strings():
+    return "hej" + "san"
+
+def use_the_var():
+    value = 5
+    return value * 5
+
+def use_the_arg(a_string):
+    print(a_string)
+    return a_string
+
+def to_string(a_value):
+    return str(a_value)
+
+def to_integer(a_value):
+    return int(a_value)
+
+def to_float(a_value):
+    return float(a_value)
+
+def to_any_type(a_value, a_type):
+    return a_type(a_value)
+
+def print_type(a_value):
+    print(type(a_value))
+
+def subtract(value1, value2):
+    return value1 - value2
+
+def split_bill(amount, number_of_people):
+    print(amount / number_of_people)
+    return amount / number_of_people
+
+def round_up(value):
+    return math.ceil(value)
+
+def round_down(value):
+    return math.floor(value)
+
+def fahrenheit_to_celsius(temperature):
+    return (temperature - 32) * (5/9)
+
+def celsius_to_fahrenheit(temperature):
+    return (temperature * (9/5) + 32)
+
+def pythagoras(x, y):
+    return (x**2 + y**2)**(1/2)
+
+if __name__ == "__main__":
+    pass
\ No newline at end of file
diff --git a/laboration1/pythonskript.py b/laboration1/pythonskript.py
new file mode 100644 (file)
index 0000000..60d4f93
--- /dev/null
@@ -0,0 +1,46 @@
+#!/usr/bin/env python3
+
+# OM EXEKVERBARA TEXTFILER
+#
+# När en exekverbar textfil körs i terminalen tittar systemet (dvs skalet på den
+# _första_ raden i filen. Om den första raden börjar med tecknena #! kommer
+# resten av raden att användas som en sökväg till det program som ska användas
+# för att tolka resten av filen.
+#
+# När denna fil körs i terminalen kommer python3 att användas för att tolka
+# innehållet. För användaren som kör filen är det ingen skillnad på att köra ett
+# kompilerat program och ett skript.
+#
+# Den här filen heter pythonskript.py, men filnamnet har egenligen ingen
+# betydelse. Om man döper om denna fil till dota kommer samma sak att hända när
+# man kör den.
+#
+# Det enda som har någon betydelse är om användaren har rätt att exekvera filen,
+# och innehållet i filen.
+
+# Här importeras modulen sys som hjälper oss interagera med systemet
+import sys
+
+def demonstrate_sysargv():
+    print("I variabeln sys.argv hittar vi en lista vars första element är")
+    print("kommandot som skrevs. Efterföljande element i listan är alla")
+    print("argument som angavs. Se här:\n")
+    print(sys.argv)
+    print("\nProva att köra detta kommando igen och skicka med några argument")
+    print("också!")
+
+# UPPGIFT!
+#
+# Er uppgift är att ta bort ordet pass i funktionen nedan och skriva Pythonkod
+# som skriver ut det första argumentet som skickades till detta skript.
+#
+# När ni gjort det, ändra på anropet längst ner i denna fil så att funktionen
+# say_hello() körs istället.
+def say_hello():
+    print(sys.argv[1])
+
+# Här är anropet till den funktion som ska användas när detta skript körs.
+# När ni skrivit klart funktionen say_hello(), ändra anropet nedan så
+# att den körs istället!
+say_hello()
+
diff --git a/laboration1/uppgift_1.py b/laboration1/uppgift_1.py
new file mode 100644 (file)
index 0000000..31334f1
--- /dev/null
@@ -0,0 +1,60 @@
+# Uppgift 1
+
+import math
+
+def return_five():
+    return "five"
+
+def print_five():
+    print("five")
+
+def add_strings():
+    return "hej" + "san"
+
+def use_the_var():
+    value = 5
+    return value * 5
+
+def use_the_arg(a_string):
+    print(a_string)
+    return a_string
+
+def to_string(a_value):
+    return str(a_value)
+
+def to_integer(a_value):
+    return int(a_value)
+
+def to_float(a_value):
+    return float(a_value)
+
+def to_any_type(a_value, a_type):
+    return a_type(a_value)
+
+def print_type(a_value):
+    print(type(a_value))
+
+def subtract(value1, value2):
+    return value1 - value2
+
+def split_bill(amount, number_of_people):
+    print(amount / number_of_people)
+    return amount / number_of_people
+
+def round_up(value):
+    return math.ceil(value)
+
+def round_down(value):
+    return math.floor(value)
+
+def fahrenheit_to_celsius(temperature):
+    return (temperature - 32) * (5/9)
+
+def celsius_to_fahrenheit(temperature):
+    return (temperature * (9/5) + 32)
+
+def pythagoras(x, y):
+    return (x**2 + y**2)**(1/2)
+
+if __name__ == "__main__":
+    pass
\ No newline at end of file
diff --git a/laboration1/uppgift_1.txt b/laboration1/uppgift_1.txt
new file mode 100644 (file)
index 0000000..134f1b7
--- /dev/null
@@ -0,0 +1,23 @@
+UEsDBBQAAAAIAKFROVQWfLPzhAEAACEEAAAaABwAbmlsZm8zNTktcHl1cHBnMV8xL29yaWcucHlV
+VAkAAx2/72Edv+9hdXgLAAEEehxpWQQA4fUFj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M0WGwpKhEZeHtlVW3/yfPjyc7KTVorQCVNhLBYeMARTl4f9YaU9ga04sQ
+E0v6Mv3YP73kPMdwDvjKl9j2OMd1THLx5iiLDIF6642HyXQG2GpuG8sfpG6Clij8WZWvKuGA74pU
+7AZQSwECHgMUAAAACAChUTlUFnyz84QBAAAhBAAAGgAYAAAAAAABAAAApIEAAAAAbmlsZm8zNTkt
+cHl1cHBnMV8xL29yaWcucHlVVAUAAx2/72F1eAsAAQR6HGlZBADh9QVQSwECHgMUAAAACAChUTlU
+Hcra+cgAAAAWAgAAJAAYAAAAAAABAAAApIHYAQAAbmlsZm8zNTktcHl1cHBnMV8xL3B5dXBwZ3Rl
+c3QxXzEubG9nVVQFAAMdv+9hdXgLAAEEehxpWQQA4fUFUEsBAh4DFAAAAAgAoVE5VMHX75h4AAAA
+lAAAABsAGAAAAAAAAQAAAKSB/gIAAG5pbGZvMzU5LXB5dXBwZzFfMS9pbmZvLnR4dFVUBQADHb/v
+YXV4CwABBHocaVkEAOH1BVBLBQYAAAAAAwADACsBAADLAwAAAAA=
\ No newline at end of file
diff --git a/laboration1/uppgift_1_test.py b/laboration1/uppgift_1_test.py
new file mode 100644 (file)
index 0000000..d18bf3a
--- /dev/null
@@ -0,0 +1,14 @@
+# test2
+#from .myTest import (add_strings, celsius_to_fahrenheit, fahrenheit_to_celsius, math, print_five, print_type, pythagoras, return_five, round_down, round_up, split_bill, subtract, to_any_type, to_float, to_integer, to_string, use_the_arg, use_the_var)
+import myTest
+
+def insert_into_namespace(func_name, space=globals()):
+    exec("global {0}\n{0} = myTest.{0}".format(func_name))
+    #space[func_name] = func_name
+
+for defined in dir(myTest):
+    if not defined[0:2] == '__' and not defined == "math":
+        insert_into_namespace(defined)
+
+#for func in (add_strings, celsius_to_fahrenheit, fahrenheit_to_celsius, math, print_five, print_type, pythagoras, return_five, round_down, round_up, split_bill, subtract, to_any_type, to_float, to_integer, to_string, use_the_arg, use_the_var):
+#    type(func)
\ No newline at end of file
diff --git a/laboration1/uppgift_2.py b/laboration1/uppgift_2.py
new file mode 100644 (file)
index 0000000..c000985
--- /dev/null
@@ -0,0 +1,56 @@
+# Uppgift 2
+
+import random
+
+def second_in_list(values):
+    return values[1]
+
+def last_in_list(values):
+    return values[-1]
+
+def second_last_in_list(values):
+    return values[-2]
+
+def n_in_list(values, n):
+    return values[n]
+
+def three_first_in_list(values):
+    return values[:3] # return (values[0], values[1], values[2])
+
+def three_last_in_list(values):
+    return values[-3:]
+
+def but_five_last_in_list(values):
+    return values[:-5]
+
+def every_other_in_list(values):
+    return values[::2]
+
+def two_around_n_in_list(values, n):
+    return values[n-2:n+3]
+
+def new_list_with_n(values, n):
+    return [*values, n]
+
+def append_n_to_list(values, a_value):
+    values.append(a_value)
+    return values
+
+def insert_4_on_pos_3(values):
+    values.insert(3, 4)
+    return values
+
+def extend_vals_to_list(values1, values2):
+    values1.extend(values2)
+    return values1
+
+def remove_from_third_in_list(values):
+    del values[2:]
+    return values
+
+def concatenate_lists(values1, values2):
+    return [*values1, *values2]
+
+def select_random(values):
+    return random.choice(values)
+    
\ No newline at end of file
diff --git a/laboration1/uppgift_2.txt b/laboration1/uppgift_2.txt
new file mode 100644 (file)
index 0000000..c517ba5
--- /dev/null
@@ -0,0 +1,22 @@
+UEsDBBQAAAAIALVROVS5y9gqSwEAAEEEAAAaABwAbmlsZm8zNTktcHl1cHBnMV8yL29yaWcucHlV
+VAkAA0W/72FFv+9hdXgLAAEEehxpWQQA4fUFjVPbboMwDH3nKyL1hW5tNaB94T/2VCErAzMiQYIS
+025/v4wkbL0gBQkpss85PrHjDXsfx0/REsuTRAyj0sQ0l40akqTBlhmslWxASOiFofTC+wnNtkyY
+/TTSpCVzsXNWOUbPDcXg94HgS0Tzcs+Td+gdk08J0uOp04jQCh1XpywqtgkxDzy/Vbu/+y7HvNr+
+LxF9k6L01j4mssYu8dRyf/JUvKD+BkUd6ihiGdpHVwVcq8m2PrqT+7yUr0XoP15nElwFdSDXuOeX
+JeGJfBxxr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DFfMi5sb2dVVAUAA0W/72F1eAsAAQR6HGlZBADh9QVQSwECHgMUAAAACAC1UTlUH9eNtngAAACU
+AAAAGwAYAAAAAAABAAAApIHEAgAAbmlsZm8zNTktcHl1cHBnMV8yL2luZm8udHh0VVQFAANFv+9h
+dXgLAAEEehxpWQQA4fUFUEsFBgAAAAADAAMAKwEAAJEDAAAAAA==
\ No newline at end of file
diff --git a/laboration1/uppgift_3.py b/laboration1/uppgift_3.py
new file mode 100644 (file)
index 0000000..eb58156
--- /dev/null
@@ -0,0 +1,29 @@
+# Uppgift 3
+
+import random
+
+def concatenate_strings(string1, string2):
+    return string1 + string2
+
+def use_the_linebreak():
+    print("rad 1\nrad 2")
+    return "rad 1\nrad 2"
+
+def generate_pokemon_name(prefixes, suffixes):
+    return random.choice(prefixes) + random.choice(suffixes)
+
+def first_word(s):
+    return s.split()[0]
+
+def join_list(values):
+    return ":".join(values)
+
+def remove_spaces(s):
+    return s.rstrip()
+
+def get_characters(s, pos, num_of_chars):
+    return s[pos:pos+num_of_chars]
+
+
+print(get_characters("Ett ytterligare exempel", 4, 11))
+
diff --git a/laboration1/uppgift_3.txt b/laboration1/uppgift_3.txt
new file mode 100644 (file)
index 0000000..53f0d74
--- /dev/null
@@ -0,0 +1,21 @@
+UEsDBBQAAAAIAMhROVTnqvMgHAEAADUCAAAaABwAbmlsZm8zNTktcHl1cHBnMV8zL29yaWcucHlV
+VAkAA2i/72Fov+9hdXgLAAEEehxpWQQA4fUFZVDBTsMwDL33K6xySbVqooPT7nwCp4GikLpdWJtE
+jjvG3+MuG2wlUmIr7/n52Q/wGmPvOoanonBjDMRAxrdhLIoWO7DBW8Po5erE5HyfVI5NDTnZVNsC
+5BDyRP7y2cDqCmehKaHmPerBefwgNAd1KYtCYlWSaaF583PYlNWt4D2U1Xr0SLOnGA44Bq+9GVFF
+ws6dMImzqTtn99byYGu7D87+sSuxeo/8VudmnaPE+itQqxaCaZ3i4FhVu8f3zP0MzsuMidXRDNPS
+QLkt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XMCAABuaWxm
+bzM1OS1weXVwcGcxXzMvaW5mby50eHRVVAUAA2i/72F1eAsAAQR6HGlZBADh9QVQSwUGAAAAAAMA
+AwArAQAAPwMAAAAA
\ No newline at end of file
diff --git a/laboration2/med.py b/laboration2/med.py
new file mode 100755 (executable)
index 0000000..51c5837
--- /dev/null
@@ -0,0 +1,17 @@
+def minimum_edit_distance(s1,s2):
+    """Returnera minimum edit distance för strängarna s1 och s2)."""
+    # byt värde på s1 och s2 om s1 är den längre strängen
+    if len(s1) > len(s2):
+        s1, s2 = s2, s1
+    distances = range(len(s1) + 1)
+    for index2, char2 in enumerate(s2):
+        new_distances = [index2+1]
+        for index1, char1 in enumerate(s1):
+            if char1 == char2:
+                new_distances.append(distances[index1])
+            else:
+                new_distances.append(1 + min((distances[index1],
+                                              distances[index1+1],
+                                              new_distances[-1])))
+        distances = new_distances
+    return distances[-1]
diff --git a/laboration2/uppgift_1.py b/laboration2/uppgift_1.py
new file mode 100644 (file)
index 0000000..a4f7df3
--- /dev/null
@@ -0,0 +1,44 @@
+# Uppgift 1
+
+def greeting(name):
+    return "Hej " + name + ("!" if name[0] != "M" else ", visste du att M är min favoritbokstav!")
+
+def is_this_a_long_list(values):
+    return len(values) > 5
+
+def get_grade(score):
+    if score > 80: grade = "VG"
+    elif score >=50: grade = "G"
+    else: grade = "U"
+    return grade
+
+def days_in_month(name_of_month):
+    if name_of_month == "januari": days = 31
+    elif name_of_month == "februari": days = 28
+    elif name_of_month == "mars": days = 31
+    elif name_of_month == "april": days = 30
+    elif name_of_month == "maj": days = 31
+    elif name_of_month == "juni": days = 30
+    elif name_of_month == "juli": days = 31
+    elif name_of_month == "augusti": days = 31
+    elif name_of_month == "september": days = 30
+    elif name_of_month == "oktober": days = 31
+    elif name_of_month == "november": days = 30
+    elif name_of_month == "december": days = 31
+    else: days = None
+    return days
+
+def odd(value):
+    return value % 2
+
+def get_integer_description(value):
+    if value % 2 and value > 0: desc = 1
+    elif value % 2 and value < 0: desc = -1
+    elif not value % 2 and value > 0: desc = 2
+    elif not value % 2 and value < 0: desc = -2
+    else: desc = 0
+    return desc
+
+def appraisal_factor(rare, good_condition): 
+    return 1 + 0.25 * (rare or -1) + 0.5*(good_condition or -1)
+
diff --git a/laboration2/uppgift_1.txt b/laboration2/uppgift_1.txt
new file mode 100644 (file)
index 0000000..e1453d3
--- /dev/null
@@ -0,0 +1,24 @@
+UEsDBBQAAAAIAI1pOlR8MOY2xwEAAEMFAAAaABwAbmlsZm8zNTktcHl1cHBnMl8xL29yaWcucHlV
+VAkAA6k68WGpOvFhdXgLAAEEehxpWQQA4fUFlZTBbtQwEIbveYpZI6RsKSgbtFK1YnuFS7mVC0KW
+N56kThM7GjuReB/ehBfD62y7NkXbkEMi//7m9++RnTdwPwyNqh1sskxiDQ0hOqWbXIse17sM/EPo
+RtLAvmALDN7Bccp/crZioOow/F78gNUe2B0D7CwCu4ZJWesQ5AjCObiD378IeqWhFpMh5Q7m0Tox
+rdh6XlhZ7h78S/DO6IZ3yrp8Et2INk3RoX7S4Ra2p9ToeENCYm4rQ0+5fbYw9NxNsYMAgA/57TML
+89idif02Jp4Bi5F6z+IgQZ6Xl+Kn5Urz3mj3EDrHTT2PzlESGfberxV6FKTYLhj4FT5uzrle4jUe
+KOXLm0t8L8gu9RYDqS6Ci8vG7VLfdtRqqW07dot7IcZmtG4xbnFw2B+QlmYxj86k+EV/bab/spdY
+/c1vohN30r4ajfGJO8rzgTNSzpcgvRtBgrdQnm+F0g4bJC7RVqQGp4xOKn285yoQWp5Gt+Cvw7HG
+x4h2/i/0U4S+j7tk3KvW5et4Yl/GTZq1IumQ1+a9i2EgoazoeC0qZygnQXgNjTGSV0ZLdezEegdx
+9cb/1IoP5RauIOBgyO9oHdTtVZ7Wniaz7A9QSwMEFAAAAAgAjWk6VD0JczynAAAAKQEAACQAHABu
+aWxmbzM1OS1weXVwcGcyXzEvcHl1cHBndGVzdDJfMS5sb2dVVAkAA6k68WGpOvFhdXgLAAEEehxp
+WQQA4fUF41IGAgVv/6AgV+8QBZ/D04JDHBVCAwLcPd1CXIMUQLJcXCC+goKRnqGeoZWCqUJB/uEl
+eel6SMJG2IWNsQubYBc2xS5sZqVgaIBF3BxFnAvsj+BQX19HhQD/wy1+7lYKJqZ6ChrGpgpJqRmH
+t5UVa0LUuJQqHF5SpFBQlJqTmZuZB2SXKLj7u3gD9bgoFBxeqhBQWZKRn1daUJCemVYCskqRS0GB
+CwBQSwMEFAAAAAgAjWk6VGg1mCJ4AAAAlAAAABsAHABuaWxmbzM1OS1weXVwcGcyXzEvaW5mby50
+eHRVVAkAA6k68WGpOvFhdXgLAAEEehxpWQQA4fUFRcxNDoMgEEDhPaeYC9AyA1jkMgZxsKSoxJ+F
+t1dX3b6XfEPY2QOQIpIKJTWA2iN5suLYeL3XnEtatG1FyoUhfjn+eLj7UeuY097hq55iWfOY51Bg
+Gux2TKCVMvjpg4nGusTchkDErml7hc5h/2dlPR+JOnw/yINdUEsBAh4DFAAAAAgAjWk6VHww5jbH
+AQAAQwUAABoAGAAAAAAAAQAAAKSBAAAAAG5pbGZvMzU5LXB5dXBwZzJfMS9vcmlnLnB5VVQFAAOp
+OvFhdXgLAAEEehxpWQQA4fUFUEsBAh4DFAAAAAgAjWk6VD0JczynAAAAKQEAACQAGAAAAAAAAQAA
+AKSBGwIAAG5pbGZvMzU5LXB5dXBwZzJfMS9weXVwcGd0ZXN0Ml8xLmxvZ1VUBQADqTrxYXV4CwAB
+BHocaVkEAOH1BVBLAQIeAxQAAAAIAI1pOlRoNZgieAAAAJQAAAAbABgAAAAAAAEAAACkgSADAABu
+aWxmbzM1OS1weXVwcGcyXzEvaW5mby50eHRVVAUAA6k68WF1eAsAAQR6HGlZBADh9QVQSwUGAAAA
+AAMAAwArAQAA7QMAAAAA
\ No newline at end of file
diff --git a/laboration2/uppgift_2.py b/laboration2/uppgift_2.py
new file mode 100644 (file)
index 0000000..dd1507f
--- /dev/null
@@ -0,0 +1,131 @@
+# Uppgift 2
+
+def create_ten_list_while():
+    i = 0 
+    myList = []
+    while i < 11:
+        myList.append(i)
+        i += 1 
+    return myList
+
+def create_ten_list_for():
+    # Jag vill argumentera att list-comprehension använder sig av en for-loop
+    return [i for i in range(0, 11)]
+
+def create_zero_to_number_list_while(number):
+    i = 0 
+    myList = []
+    while i < number + 1:
+        myList.append(i)
+        i += 1 
+    return myList
+
+def create_zero_to_number_list_for(number):
+    return [i for i in range(0, number + 1)]
+
+def create_number_to_number_list_while(start_number, end_number):
+    i = start_number
+    myList = []
+    while i < end_number + 1:
+        myList.append(i)
+        i += 1 
+    return myList
+
+def create_number_to_number_list_for(start_number, end_number):
+    return [i for i in range(start_number, end_number + 1)]
+
+def get_max_while(integer_list):
+    myMax = integer_list[0]
+    i = 0 
+    while i < len(integer_list[1:]):
+        if integer_list[i + 1] > myMax: myMax = integer_list[i + 1]
+        i += 1
+    return myMax
+
+def get_max_for(integer_list):
+    myMax = integer_list[0]
+    for elm in integer_list[1:]:
+        if elm > myMax: myMax = elm
+    return myMax
+
+def get_min(integer_list):
+    myMin = integer_list[0]
+    for elm in integer_list[1:]:
+        if elm < myMin: myMin = elm
+    return myMin
+
+def word_in_list_while(words, word):
+    i = 0 
+    while i < len(words):
+        if words[i] == word: break
+        i += 1
+    else: return False
+    return True
+
+def word_in_list_for(words, word):
+    for elm in words:
+        if elm == word:
+            break
+    else: return False
+    return True
+
+def count_integers_while(value_list):
+    count = 0
+    i = 0 
+    while i < len(value_list):
+        if isinstance(value_list[i], int): count += 1
+        i += 1
+    return count
+
+def count_integers_for(value_list):
+    count = 0
+    for elm in value_list:
+        if isinstance(elm, int): count += 1
+    return count
+
+def average_while(values):
+    i = 0
+    tot = 0
+    while i < len(values):
+        tot += values[i]
+        i += 1
+    return tot/len(values)
+
+def average_for(values):
+    tot = 0 
+    for elm in values:
+        tot += elm
+    return tot/len(values)
+
+def population(pop_a, rate_a, pop_b, rate_b):
+    if pop_a == pop_b: return 0
+
+    lower_pop = pop_a if pop_a < pop_b else pop_b
+    higher_pop = pop_a if lower_pop is pop_b else pop_b
+    higher_rate = rate_a if rate_a > rate_b else rate_b
+    lower_rate = rate_a if higher_rate is rate_b else rate_b
+
+    if (lower_pop is pop_a and higher_rate is rate_b) or (lower_pop is pop_b and higher_rate is rate_a):
+        return -1 
+
+    years = 0
+    while lower_pop < higher_pop:
+        print(lower_pop)
+        print(higher_pop)
+        lower_pop += lower_pop*(higher_rate/100)
+        higher_pop += higher_pop*(lower_rate/100)
+        years += 1
+    
+    return years
+
+def birthday(n):
+    prod = 1
+    for i in range(0,n):
+        prod *= (365-i)/365
+    return 1 - prod
+
+def sum_of_ints(value_list):
+    tot = 0 
+    for elm in value_list:
+        if isinstance(elm, int): tot += elm
+    return tot
\ No newline at end of file
diff --git a/laboration2/uppgift_2.txt b/laboration2/uppgift_2.txt
new file mode 100644 (file)
index 0000000..3f08920
--- /dev/null
@@ -0,0 +1,31 @@
+UEsDBBQAAAAIAPVxOlRPedNKJQMAADoMAAAaABwAbmlsZm8zNTktcHl1cHBnMl8yL29yaWcucHlV
+VAkAA31J8WFcSfFhdXgLAAEEehxpWQQA4fUFrVbLctowFN3zFXcmGzuBBtpJFwxk2UWn3bUrhvEI
+LIymtuyRZRL6Pf2T/livHrZky5BkGjbocc695x5dCW7gZ1Vl7CDh42SS0gPsBSWSJpLyJGe1TJ6O
+LKdRvJwAfhisYQ56WJy/4TbON1s91zgErGCxMGCH+kCqivI0YnG3weBuDQsTSlDZCG6x4yoOpWg1
+3MBXksGJ5TkQkTUF5ZIKAkRKUNDZviwqQY+U16zkQPjp7x+eUgE1y4CcgHLAYLO8LCs/+YapZZTF
+OAjCMxrNp1hJvO3p+U1Fmcgy4U2xo8I3yKy8xSbDgDt4P7vG5CnneuKuFew0DQq3EUdLryUR0q5P
+0d80CczwIS/Y4vjvas14AcqcF+RftOsSz3cvozIpyLM1imGnZja1jV6cv5NntMHf2sy3wy5y9uSU
+9+JsFstt7Fxih34optRs4dEkWo7nM6CBoX0/kdWvSD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AABsAHABuaWxmbzM1OS1weXVwcGcyXzIvaW5mby50eHRVVAkAA31J
+8WF9SfFhdXgLAAEEehxpWQQA4fUFRcxBDoMgEEDRPafgArTMCBi4jEEYLCkqUVl4+8qq2/+TF/1F
+jnOUiEKCQMNBOdBOAWsnHc/ackn7oC1LuRAPHwpfik9vtS45XRO+6s32Iy9584WvUZ9t5cmPNKI0
+VhrtwcvZmyRVsJbUEMMMf1bUu0s44bsjHfsBUEsBAh4DFAAAAAgA9XE6VE9500olAwAAOgwAABoA
+GAAAAAAAAQAAAKSBAAAAAG5pbGZvMzU5LXB5dXBwZzJfMi9vcmlnLnB5VVQFAAN9SfFhdXgLAAEE
+ehxpWQQA4fUFUEsBAh4DFAAAAAgA9XE6VJ6zF9PPAAAANwIAACQAGAAAAAAAAQAAAKSBeQMAAG5p
+bGZvMzU5LXB5dXBwZzJfMi9weXVwcGd0ZXN0Ml8yLmxvZ1VUBQADfUnxYXV4CwABBHocaVkEAOH1
+BVBLAQIeAxQAAAAIAPVxOlRDWsGVeAAAAJQAAAAbABgAAAAAAAEAAACkgaYEAABuaWxmbzM1OS1w
+eXVwcGcyXzIvaW5mby50eHRVVAUAA31J8WF1eAsAAQR6HGlZBADh9QVQSwUGAAAAAAMAAwArAQAA
+cwUAAAAA
\ No newline at end of file
diff --git a/laboration2/uppgift_3.py b/laboration2/uppgift_3.py
new file mode 100644 (file)
index 0000000..a108221
--- /dev/null
@@ -0,0 +1,70 @@
+# Uppgift 3
+
+def replace_periods_with_newlines(string_value):
+    s = ""
+    for char in string_value:
+        if char == '.': s += '\n'
+        else: s += char
+    return s
+
+def replace_char_in_string(original_string, search_character, replacement):
+    s = ""
+    for char in original_string:
+        if char == search_character: s += replacement
+        else: s += char
+    return s
+
+def reverse_string_while(string_value):
+    i = len(string_value) - 1
+    s = ""
+    while i > -1:
+        s += string_value[i]
+    return s
+
+def reverse_string_for(string_value):
+    s = ""
+    for char in string_value:
+        s = char + s
+
+def get_five_first(value_list):
+    myList = []
+    for elm in value_list:
+        myList.append(elm)
+        if len(myList) == 5: break
+    return myList
+
+def get_nfirst(value_list, n):
+    myList = []
+    for elm in value_list:
+        myList.append(elm)
+        if len(myList) == n: break
+    return myList
+
+def get_all_less_than(values, cutoff):
+    return [elm for elm in values if elm < cutoff]
+
+def get_all_even(values):
+    return [elm for elm in values if not elm % 2]
+
+def get_all_divisible(values, divisor):
+    return [elm for elm in values if not elm % divisor]
+
+def multiply_for_each(values, multiplier):
+    for i, elm in enumerate(values):
+        values[i] = elm * multiplier
+    return values
+
+def insert_at_asc_place(values, new_value):
+    mid = len(values) // 2
+    newList = values.copy()
+    idx = mid
+    while True:
+        idx = idx - mid if new_value < newList[mid] else idx + mid
+        newList = newList[slice(0, mid, 1) if new_value < newList[mid] else slice(mid, len(values), 1)]
+        mid = len(newList) // 2
+        if mid == 0:
+            values.insert(idx, newList[0])
+            break
+    return values
+
+print(insert_at_asc_place([1,2,3,4,6,7], 2))
\ No newline at end of file
diff --git a/test.py b/test.py
deleted file mode 100644 (file)
index 6aa46c9..0000000
--- a/test.py
+++ /dev/null
@@ -1,23 +0,0 @@
-
-def binary_search(key: int, srt_list: list, carry=0):
-    length = len(srt_list)
-    idx = length // 2
-
-    if key > srt_list[idx]:
-        return binary_search(key, srt_list[idx:], carry=carry+idx)
-    elif key < srt_list[idx]:
-        return binary_search(key, srt_list[:idx], carry=carry)
-    else:
-        return carry + idx
-
-
-def this(keuy: int):
-
-    return keuy
-
-
-if __name__ == "__main__":
-    myList = [12, 45, 345, 345, 234, 13, 1, 5]
-    myList.sort()
-    print(myList)
-    print(binary_search(345, myList))
diff --git a/test2.py b/test2.py
deleted file mode 100644 (file)
index 471194c..0000000
--- a/test2.py
+++ /dev/null
@@ -1,3 +0,0 @@
-from uppgift_1 import subtract
-
-print(subtract(2,4))