|
|
(9 intermediate revisions by the same user not shown) |
Line 2: |
Line 2: |
|
| |
|
| Set the grades according to the points given to the exercises. | | Set the grades according to the points given to the exercises. |
| | |
| | I encountered some problems while trying to add a long file: Internal server error. Thus, there is many parts. |
|
| |
|
| == Theory == | | == Theory == |
|
| |
|
| Save the database as a csv file and read it. Choose the exercises and run the python script. | | Save the database as a csv file and read it. Choose the exercises and run the python script. See the script at |
| | |
| <syntaxhighlight lang="python">
| |
| #Python3
| |
| | |
| import csv
| |
| import math
| |
| import glob
| |
| import numpy as np
| |
| | |
| def getExeNames(titles):
| |
| ti = []
| |
| for title in titles[1:]:
| |
| ti.append(title)
| |
| return ti
| |
| | |
| def getRow(row):
| |
| r = [row[0]]
| |
| | |
| points = []
| |
| for i,p in enumerate( row[1:] ):
| |
| #Convert the numbers separated by space into a array of integers
| |
| #Fetch the max value of and return those.
| |
| #print( p )
| |
| #print( [(i) for i in p.strip().split(' ')] )
| |
| values = [int('0'+i) for i in p.strip().split(' ')]
| |
| #print( values );
| |
| r.append( max( values ))
| |
| | |
| return r
| |
| | |
| </syntaxhighlight>
| |
| | |
| | |
| == Part 2 ==
| |
| | |
| <syntaxhighlight>
| |
| def removeFieldName(a, name):
| |
| #https://stackoverflow.com/questions/15575878/how-do-you-remove-a-column-from-a-structured-numpy-array
| |
| names = list(a.dtype.names)
| |
| if name in names:
| |
| names.remove(name)
| |
| b = a[names]
| |
| return b
| |
| | |
| def leaveFields(a, ns):
| |
| names = list(a.dtype.names)
| |
| | |
| #Find the corresponding names of fields that stay
| |
| fields = []
| |
| for n in ns:
| |
| res = [i for i in names if n in i]
| |
| fields.append( res[0] )
| |
| | |
| #Find the difference and drop those---except the one named "Name"
| |
| #https://www.w3resource.com/python-exercises/list/python-data-type-list-exercise-19.php
| |
| diff1 = list( set(names) - set(fields) )
| |
| diff2 = list( set(fields) - set(names) )
| |
| diff = diff1 + diff2
| |
| diff.remove("Name")
| |
| for n in diff:
| |
| a = removeFieldName(a, n)
| |
| | |
| return a
| |
| </syntaxhighlight>
| |
| | |
| == Part 3 ==
| |
| | |
| <syntaxhighlight lang='python'>
| |
| il = []
| |
| tul = []
| |
| kpl = []
| |
| | |
| if (0):
| |
| | |
| kpl.append( '1: Elävä solu ' )
| |
| fil.append( 'bg7_1.csv' )
| |
| tul.append( ['P1', 'P2', 'P3', 'S1', 'T1','YT1'] )
| |
| | |
| kpl.append( '4: Levät ja planktoneläimet ovat vesien runsaimpia eliöitä' )
| |
| fil.append( 'bg7_4.csv' )
| |
| tul.append( ['P1'] )
| |
| | |
| name = "name1"
| |
| name = "name2"
| |
| | |
| if (0):
| |
| | |
| kpl.append( '3: Metsätyypiy ja puulajit' )
| |
| fil.append( 'bg8_3.csv' )
| |
| tul.append( ['P1', 'P2'] )
| |
| | |
| name = "name6"
| |
| name = "name7"
| |
| | |
| | |
| if (1):
| |
| #9. luokka
| |
| kpl.append( '2: Solut -- elämän legopalikat' )
| |
| fil.append( 'bg9_2.csv' )
| |
| tul.append( ['P1', 'P2', 'S3'] )
| |
| | |
| kpl.append( '3: Kudokset' )
| |
| fil.append( 'bg9_3.csv' )
| |
| tul.append( ['P1'] )
| |
| | |
| name = "name11"
| |
| name = "name12"
| |
| | |
| </syntaxhighlight>
| |
| | |
| == Part 4 ==
| |
| | |
| <syntaxhighlight lang="python">
| |
| | |
| </syntaxhighlight>
| |
| | |
| == Part 5 ==
| |
| | |
| <syntaxhighlight lang="python">
| |
| | |
| </syntaxhighlight>
| |
| | |
| == Part 6 ==
| |
| | |
| <syntaxhighlight lang="python">
| |
|
| |
|
| </syntaxhighlight>
| | https://gist.github.com/markkuleino/bea1d81b41b233a8a3dbb2b6659a2222 |