Game with QPython on Android Phone

During recent visit to my native village, sitting at my cousin’s shop and playing with his android phone discovered Qpython on Android play store.

Python on Android

QPython is a script engine running on Android devices like phone or tablet, It embeds the python interpreter, console, editor, SL4A library for android, which can make android device run python script or project.

Downloaded it promptly and just for trial wrote a small python game.

Reverse, a game I saw in old HP calculator, is a simple text based game. The user is presented with a sequence of numbers from 1 to 9, the aim of the user is to arrange the number in 123456789 sequence in as short moves as possible.

"""
Reverse:
The user is presented with a sequence of numbers from 1 to 9, the aim of 
the game is to arrange the numbers in 123456789 sequence 
in as short moves as possible.

@author Sukhbinder
"""
import random
x = range(1,10)
b = range(1,10)

def ch(n):
    global x
    x[:n] = x[n-10::-1]
    return None
def level(stage):
    global x
    for i in range(stage+3):
        j = random.randrange(1,10)
        ch(j)
    return None

ans=1
stage=1
while (ans == 1):
    turns=0
    level(stage)
    print "Level:",stage,"Min. Turns:",stage+3
    while (x != b):
        print b
        print x
        num= input('Enter num:')
        ch(num)
        turns +=1
    print "S O L V E D !"
    print x
    print "You took ",turns,"turns"
    stage +=1
    ans = input('Press 1 to Play Next Level: ')

Download Qpython from Play Store.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s