QPython+SL4A:
import android
import time
import sys, select, os #for loop exit
#Initiate android-module
droid = android.Android()
#notify me
droid.makeToast("fetching GPS data")
print("start gps-sensor...")
droid.startLocating()
while True:
#exit loop hook
if sys.stdin in select.select([sys.stdin], [], [], 0)[0]:
line = input()
print("exit endless loop...")
break
#wait for location-event
event = droid.eventWaitFor('location',10000).result
if event['name'] == "location":
try:
#try to get gps location data
timestamp = repr(event['data']['gps']['time'])
longitude = repr(event['data']['gps']['longitude'])
latitude = repr(event['data']['gps']['latitude'])
altitude = repr(event['data']['gps']['altitude'])
speed = repr(event['data']['gps']['speed'])
accuracy = repr(event['data']['gps']['accuracy'])
loctype = "gps"
except KeyError:
#if no gps data, get the network location instead (inaccurate)
timestamp = repr(event['data']['network']['time'])
longitude = repr(event['data']['network']['longitude'])
latitude = repr(event['data']['network']['latitude'])
altitude = repr(event['data']['network']['altitude'])
speed = repr(event['data']['network']['speed'])
accuracy = repr(event['data']['network']['accuracy'])
loctype = "net"
data = loctype + ";" + timestamp + ";" + longitude + ";" + latitude + ";" + altitude + ";" + speed + ";" + accuracy
print(data) #logging
time.sleep(5) #wait for 5 seconds
print("stop gps-sensor...")
droid.stopLocating()
a = True
b = int(input())
while (a):
if b == 1:
print("Понедельник")
a = False
elif b == 2:
print("Вторник")
a = False
elif b == 3:
print("Среда")
a = False
elif b == 4:
print("Четверг")
a = False
elif b == 5:
print("Пятница")
a = False
elif b == 6:
print("Суббота")
a = False
elif b == 7:
print("Воскресенье")
a = False
else:
print("Такого дня недели нет")
b = int(input())
Осуществляется ввод, если b > не 1 - 7, то программа запрашивает число до тех пор, пока пользователь не введет нужное число.
begin
ArrRandom(30,-10,20).Println
end.
Тестовое решение:
-2 13 -5 10 17 -4 0 2 -5 3 -5 19 -3 17 -4 7 13 -10 -3 4 -2 1 12 16 13 -10 2 18 18 4