>>> from sensors import velocitat_port >>> s='24.2: 45.1: 17.3: 134\n24.9: 50.3: 17.1: 146\n30.4: 60.2: 15.3: 175\n32.5: 61.2: 15.1: 182\n33.1: 61.6: 15 : 183\n33.4: 61.7: 15: 182\n33.6: 61.9: 13.4: 206\n33.6: 61.91: 11.8: 224\n33.69: 61.94: 11.5: 228' >>> with open('dades_vaixell.txt', 'w') as f: ... n = f.write(s) >>> velocitat_port('dades_vaixell.txt', 0.51) 15.0 >>> velocitat_port('dades_vaixell.txt', 1) 15.1 >>> velocitat_port('dades_vaixell.txt', 3) 15.3 >>> velocitat_port('dades_vaixell.txt', 0.1) 13.4 >>> velocitat_port('dades_vaixell.txt', 0.001) -1.0 >>> s2='44.2: 45.1: 17.3: 134\n42.9: 50.3: 17.1: 146\n38.4: 60.2: 15.3: 175\n32.5: 61.2: 15.1: 182\n30.1: 61.6: 15 : 183\n27.4: 61.7: 15: 182\n24.6: 61.9: 13.4: 206\n22.6: 61.91: 11.8: 224\n19.69: 61.94: 11.5: 228\n16.2: 45.1: 17.3: 134\n14.9: 50.3: 17.1: 146\n10.4: 60.2: 15.3: 175\n8.5: 61.2: 15.1: 182\n7.1: 61.6: 15 : 183\n6.4: 61.7: 15: 182\n6.6: 61.9: 13.4: 206\n6.56: 61.91: 10.8: 224\n6.49: 61.92: 9.5: 228' >>> with open('dades_vaixell2.txt', 'w') as f: ... n = f.write(s2) >>> velocitat_port('dades_vaixell2.txt', 0.51) 15.0 >>> velocitat_port('dades_vaixell2.txt', 5) 15.1 >>> velocitat_port('dades_vaixell2.txt', 10) 17.3 >>> velocitat_port('dades_vaixell2.txt', 0.1) 13.4 >>> velocitat_port('dades_vaixell2.txt', 0.001) -1.0