Welcome to Pythonic CS1: Build a Mobile App!¶
Welcome to Pythonic CS1: Build a Mobile App. In this course, you will learn and practise Python programming and computer science concepts by building a mobile app. You will learn how to conceptualize an idea into a real mobile app. The course covers a light-weight software development process, including requirment engineering, prototyping, coding and testing, and more.
This course assumes you a novice or no prior programming experience, by firstly introducing basics of programming in MIT App Inventor, a visual programming language which allows you to learn programming concepts with visual building blocks, and gradually move your learning pathway towards programming in Python.
Apart from learning concepts and practices on computer science and programming, this course would also equip you with the skills needed for setting up your own toolkit for development, including set up a Linux virtual machine with integrated development environment (IDE), GitHub the version control system, and Kivy the framework for building mobile apps in Python.
You Can Build an App to Impact the World¶
Welcome to the age that everyone can build an app to impact the world. Building an app has becoming very easy, fun, and very meaningful than ever.
One of the most meaningful app that you can build is a mobile learning app. By building a mobile learning app, you can not only learn the aspects of computer science and programming, but also help other people by contributing the education community. In other words, you can teach by learning and sharing!
Is it ever possible? In here we would introduce the story of Amol Bhave, a student from India who built his own MOOC class at his age of 17 that impressed MIT and featured in MIT News. He build his own class just right after he has learnt something and found there is no other course which can fulfill his desire to learn deeper. His class then became very successful with about 1,000 students participating in it.
We believe you can also do that. Let’s learn and build your own mobile learning app!
Understanding Requirements of the Mobile App¶
Welcome to this module. As in the previous module, we have learnt how an individual like you and me can build our own learning app that impacts the world and impress big players like MIT.
We believe you can also do that :) Before you get started, in this module we would like to discuss and analysis the requirements of the mobile learning app that you are going to build. Understanding requirements is an important poart software development process that helps you to conceptualize and build your app to successfully solve real problem and impact the world.
Excited? Let’s get started :)
How to Understand Requirements¶
Understanding requirements is the first and important steps to build our mobile app successfully. In fact, it is an essential stepping stone for every software project to be succesful.
At high level, we need to know the following factors to understands the requirements of an app:
- Who are the stakeholders of the app?
- How do their existing way of accomplishing their needs / goals / tasks?
- What are their “pain points”?
- What are their budget to solve their “pain points”, including how much time / cost can they afford to build and operate the solution?
Then, we may start making progress by:
- Analysing the requirements and propose our work
- Prototyping our app to get feedbacks from our stakeholders
- Building, testing, getting further feedbacks from our stakeholders and keep improving.
Let’s begin by understanding who are the stakeholders of our app and how do they work.
Who Are the Stakeholders of Our App and How Do They Work¶
Let’s begin by taking a look on how the following stakeholders use this course web site, as a course authoring and publishing workflow:
- Educators may update course material via GitHub.
- Once the educators has committed the changes to GitHub, GitHub will trigger a webhook to ReadTheDocs.
- ReadTheDocs would parsee the course material written in reStructuredText language, and convert them into HTML with navigation menu, themes, and cosmestics.
- Learners may visit the course home page to access the latest course content.
Next, we can compare and contrast the strengths and weaknesses of this solution.
Current Solution: Strengths, Weaknesses, and Opportunities¶
Strengths of Current Solution¶
- Git and GitHub provides a platform for teachers to concurrently author the content, and have all changes versioned.
- GitHub and ReadTheDocs works perfectly together to continously push the latest content available to the learners.
- GitHub and ReadTheDocs are free, such that there is no cost of hosting and no server to be maintained.
Weaknesses of Current Solution¶
- GitHub and ReadTheDocs can only host static content, which limits the interactivity of the course. As a programming class it is ideal to allow students editing and running programming quiz without leaving the course. Existing in-browser solutions are either lack of 3rd party libraries support, or requires running and maintaining expensive servers, which are not ideal to be plugged into the our current solution.
- The current solution is web-based, and is inheriently less responsive than mobile app.
Opportunities to Improve Current Soution¶
- Build a mobile learning app which synchronize static content from GitHub / ReadTheDocs, and run programming quizzes inside mobile device.
- With Python and Kivy is possible to build a Python programming environment like this Android app. As the program is executed inside an Android phone, we can preload the 3rd libraries required, and the program can be run natively in an Android phone without a need of any expensive server.
With these opportunies, let’s foucs on the requirements of our mobile learning app.
Requirements of Our Mobile Learning App¶
Let’s drill down in detail for the requirements:
- We are currently hosting our course homepage in GitHub. GitHub is a version control system that allows collaborators to contribute content and code concurrently in a common repository. GitHub allows static content like articles and videos to be hosted and navigated via ReadTheDocs web interface. A requirement of the Mobile Learning App is to download the latest content from GitHub and display it as clickable menu item accordingly. Each menu item has an ID and description.
- Each page of course content is presented sequently to learners. For article content, it is scrollable vertically. User can click on previous / next button for its corresponding previous / next screen of content. We do not have much Video content currently so let’s assume we are hosting only text content for now.
- For programming quiz, a text editor is presented with the starter code and the learner would complete the program. There is a “Run Test” button which check the correctness of the program by executing it locally in the Android phone.
- For the last page of the screen, the next button will bring the menu screen. Similarly, for the first page of the screen, the previous button will bring the menu screen.
Prototyping the Mobile App with MIT App Inventor¶
The objective of this module is to let student to rapidly prototype the Mobile Learning App with MIT App Inventor. App Inventor is a good way to let you to start learning programming quickly by visual blocks and event-driven programming paradigm.
App Inventor allows you to learn how to build prototype to capture and validate user requirements. This prototype is something that you can refer to later on when you implement a more complete version of the app by Python.
At this point, only certain visual components are in-scope for Prototype, with simple synchronization of course content from GitHub are implemented.
What Is And Why Prototyping¶
Prototpying is a way to build a partially completed / functional software product, aiming at getting user feedback as soon as possible, a well as addressing risk as early as possible.
By this nature, a successful protyping should be:
- Delivering something visual and presentable to end user, in order to gain their feedback. Ideally, the coreuser experience and interactivity should be in-scope as early as possible.
- Addressing key risks as early as possible. One possible way to achieve this is by focusing on build a functional code for the risky parts and leaving the less risky parts to be imcompleted / to be polished later.
- Becuase we are only choosing some key features and user experiences to be prototyped, it is possible that direction can be changed. Therefore, to reduce the cost of prototyping, the supporting tools must be easy and felxible enough.
As we can see in the next page, MIT App Inventor is a great tool for building functional and interactive Mobile App quickly. Before we start building a full feldged version of our mobile app, let’s get started by prototyping one quickly.
How to Build a Prototype with MIT App Inventor¶
MIT App Inventor is a visual UI and programming environment which allow us to build fully functional visual Android application in a short period of time.
What Values Does MIT App Inventor Bring into Our Prototype?¶
For our context of building our prototype, MIT App Inventors provides the following features which fits our need perfectly to build our prototype.
- Easy to setup: Visit here to start building the UI by drag-and-drop within the web browser.
- Instant feedback: Install AI2 Companion from Google Play store to try the app instantly while you build the protoype, therefore speeding up the feedback cycle.
- Connectivity to GitHub: One of the key feature of our mobile app is the ability ot sync up content instantly from GitHub, as well as ability to navigate among pages of these course contents as a graph of interconnected documents. App Inventor has built-in Web connectivity which allows us to download the course content as source file from GitHub and to extract contents / links from it accordingly. This way we can address the feasibility of synchronizing from GitHub as early as possible.
Designing UI with App Inventor Designer View¶

Let’s take a look at how you can build your first prototype UI with App Inventor. In App Inventor, you design your UI via a drag-and-drop UI builder namely Designer View. From the left of the screen we have dragged several Labels and Buttons with different format and position. You can design your UI very intuitively with a very shallow learning curve. Check out User Interface Components for details.
Building Logic with App Inventor Blocks View¶

Then you may define the workflow and UI behavior of our app in Blocks view. App Inventor allows you to build your program visually by buliding blocks. If you come with no programmng background and would need more walkthough you may check out this tutorial and continuue.
Playing Around the Working Prototype¶
To speed you up we have built a working prototype in this location. Once you have opened it and launched it in your Android phone, you would see the following screen:

This screen is generated by parsing and extracting infromation from the course source file hosted in GitHub. User may click on the Next button to move to the next page. Alternatively, he / she can click on the Module button to show the module list like below.

Questions / Exercise for You¶
Please try the following exercises to faciliate your learning:
- Try testing the app by clicking the Next button in the mobile app, and check if the corresponding Next page is shown. As a cross-check you can refer to this course web site. The Next button in the mobile app and the course web site should be the same.
- Open the blocks view for the mobile app, can you locate the logic for deciding which page is the next page?
- Based on what you have observed by testing and readind the code, in your own words, can you describe the algorithm of deciding which page is the next page?
- Visit the Tree Traversal Wikipedia Page. Do you think our logic for deciding the next page is better to be described as Breath-first or Depth-first? Is the logic traversing by pre-order, in-order, or post-order?
- As a Minimum Viable Product, we have chosen not to implement logic for displaying image as well as support for Prev button. As a programming exercise, can you help implementing them? You may start from this location for the starter code and remix it on your own.
What You Have Learned from the Prototype¶
Well done! By here you have built your first mobile app prototype which is functional and have validated it against the basic requirements. You have also learnt the unbderlying coding and the CS concepts that powered this mobile app.
In the next module, you will start realizing the prototype you have built in here by writing your first Python mobile app. Stay tuned :)
Building the Mobile App with Python and Kivy¶
In last module you have learnt how to build a prototype by App Inventor. In this module, you will start learning how to build our mobile app in Python.
In this module, you will learn how to download and setup a Virtual Box Ubuntu Linux image and proceed to the Kivy Mobile App SDK and PyCharm Community IDE installation. You may also learn how to use Git and GitHub to get the starter code for the mobile app and work on it.
We will guide you to complete these activities step-by-step. Let’s get started :)
Setting up Your Development Environment¶
Let’s get the hands dirty by doing some setup. We will explain what you have done later. Just feel free to try it out for now :)
Download and Install Virtual Box and Ubuntu Linux¶
- Download and install Virtual Box.
- Download and add Ubuntu 64 Bit Virtual Box image into your Virtual Box. Latest version is recommended. Please refer to the web site for user name and password.
Install Kivy, Git, and PIP¶
- Start the Ubuntu. Input the username and password obtained in the last step to login. Right click desktop and choose open terminal.
- In the terminal, run the following command:
sudo apt-get upgrade
sudo apt-get install python-kivy
sudo apt-get install git
sudo apt-get install python-pip
Intall Pycharm IDE¶
- In your Ubuntu. Open Firefox. And download Pycharm Commnity Edition for Linux
- By default, it would be saved at ~/Downloads.
- Open terminal again. Type the following:
cd ~/Downloads
tar xvzf pycharm*.tar.gz
rm pycharm*.tar.gz
mv pycharm* ~/pycharm
Running PyCharm¶
- Open terminal.
- Run Pycharm in terminal by:
~/pycharm/bin/pycharm.sh
If PyCharm asked for Key binding / mappings, choose Eclipse for the sake of this course.
In the next section. You will learn about what you have just setup.
Working with Pycharm IDE, Git, and Kivy¶
What is Pycharm¶
Pycharm is a Python Integrated Development Environemnt which streamlines your development, testing, debugging, and version control experience. Altnhough you can watch this Pycharm IDE Video Tutorial to see how Pycharm can help you, let’s again get the hand dirty by working out the following tutorial :)
Pycharm IDE: Look and Feel¶

Your usual PyCharm setup would look like this. In short, you have a list of files in your project on the left hand side, and opened files on the right hand side. You may create / edit Python code and auto-code completion would happen like other IDEs. Alternatively, you can press CTRL-SPACE to force auto-code completion dialog to be shown if it doesn’t.
Sometimes, you may typed some code which cause compilation error. For insance, you are using a class but forget to import it into your source. Then you may try pressing ALT-ENTER and Pycharm would attempt fixing this for you.
Sometimes, you would like to override a function which has been defined in the base class. You may press ALT-INSERT to help you choosing the function which you want to override. Pycharm will then fill in the function signature for you.
Let’s Play Around PyCharm, Git / GitHub, and Kivy Together!¶
If you still remmeber, in the previous setup page you have not only installed PyCharm IDE, but also Git and Kivy. Let’s also play around them a bit to know how things are working together.
Step 1: Forking a Project into Your GitHub Account¶
To get started using Git and GitHub. You need a GitHub account.
- Create a GitHub account if you do not have one.
- Visit Kivy Crash Course and press the Fork button.

Step 2: Clone the Forked Project into Your Machine via PyCharm IDE¶

Now you have forked a project into your GitHub account. Next step is to clone this project into your local machine. To do this:
- Follow the steps as mentioned in here. Locate the kivycrashcourse repo to be cloned into your machine.
- If it is successful, you should be seeing a screen like the following in step 3.
Step 3: Running Your first Kivy App¶

At this point your have setup yout PyCharm environemnt together with the Kivy Crash Course. While you may watch the video for the full crash course, you may run your own copy of Kivy app. Here is how to do it:
- Open after.py like the screen above.
- Press ALT-SHIFT-F10 to run the program. Note at the 1st attempt PyCharm may be processing in background such that you cannot run the app until it has finish. You can find out PyCharm’s progress by looking at the lower right corner of the screen. Be patient and run again after it has finished.
- If you can see a new window like below, that means you have setup the things you need to start building app in PyCharm and Kivy. Well done!

Building the Mobile Learning App in Python and Kivy¶
Let’s back to to our focus on building a mobile learning app. Recapping what we have prototyped, we are building a mobile learning app which allows contributor to create / modify content via Git / GitHub. And the content can be sycnrhonized automatically to ReadTheDocs as well as our mobile learning app. Let’s learn it by doing it.
Step 1: Fork the Starter Code into Your GitHub Account¶
- Please fork from this URL. Please refer to the previous sections if you are not sure how to do it.
Step 2: Clone to PyCharm¶
- Like what we did previously. Please refer to the previous document for details.
Step 3: Switch to 0.1.0 Branch¶
Please type the following. We will explain why we need to do that in the next module :)
git checkout release/0.1.0
Step 4: Run the Starter Code¶
- By locating main.py and run it. You should see a screen like this:

Let’s discuss this screen in details in the next section.
Understanding Events in the Mobile Learning App¶

The mobile learning app fetch the course content from GitHub and present it to the user. Navigation menu including Home, Up, and Next are working the similar way like our Prototype. Unlike the prototype, as Kivy label supports ref and other markups, we can embed the menu directly into the document such that it looks more natural.
Whenever user clics on either the navigation menu or the menu, Kivy would send an event as a function call to our Python code. To understand what does that mean, let’s try adding breakpoints into our program.
In general, breakpoint can be added by clicking the line number which you want your program to be paused when it reaches that line. Let’s trying adding breakpoints like the screen below:

Then press ALT-SHIFT-F9 to start debugging the app. You will see the breakpoint will stop at on_home() function. You can inspect memory, and carry on execution by pressing F6 for next statement, F5 to getting into a function, F7 to getting out from a function, F8 to continue.
Questions / Exercise for You¶
- Which function will be triggered when you click on a ref? Can you add a watch to look at the variable “value”?
- Which function will be triggered when you click on the Home button? How about the Up button and the Next button?
- Open course.kv. Based on the experience from the first 2 points, can you locate how does event bindings are defined in Kivy Language?
- Additional reading: Kivy Events and Properties
Next Steps¶
Well done. Now you have learnt a lot how to get started in PyCharm to develop our mobile learning app. In the next modules, you will learn how to add additional functionalities into our app. You will start writing some Python code to make the app to be even better. Stay tuned :)
Adding functionalities into the Mobile Learning App¶
So far, we have built basic functionality of the mobile learning app. In this module, we would focus on adding new functionalitiies into the app. We would like to add support for
- Demostration: External Hpyerlink Support
- Exercise: Image
- Next Module: Programming Editor
How to Add a new Feature to the Mobile Learning App¶
In this module, we would like to demostrate on how to add a new feature to the mobile learning app. Imagine the following scenario and goals:
- You and me are assigned to develop new features for the mobile learning app.
- I am developing a new feature to support external hyperlink. I will show you how I do it.
- You are developing a new feature to support images. You are developing it while I am also developing my feature concurently.
- Once your changes and my changes are ready, we will create a new release, namely 0.2.0.
- If you remember, we are having our last release as 0.1.0. So here we would like to make sure our changes will only be visible right after 0.1.0 and will be releasd in 0.2.0.
Here we would like to outline what we should do to achieve the goals above:
- Create a git feature branch from git master.
- Create 1 more test cases for the new feature we are adding. Build our feature to pass the test case.
- Integrating changes into master
- Create a release branch from master when my change and your chnages are ready.
Let’s walk though them step-by-step.
How to Create a Feature Branch in Git¶
Steps¶
Let’s demostrate the first step by creating a new feature branch from master. First I will type the following from my terminal
cd <<your git clone folder>>
git checkout master
git pull
git checkout -b feature/hyperlink
The command above will:
- Get the latest code from master
- Create a new feature branch from master, namely feature/hyperlink.
I can verify I am in my feature branch by typing:
git branch
It will highlight my current branch.
Why a Feature Branch¶
The followings are reasons why we make a feature branch from master:
- It allows me to develop my feature without impacting the others.
- It allows me to select a right moment, where my changes are ready and tested, to be integrated into master with other people changes to collectively make a new release.
Discussions¶
- Note the arrangement above is just one possible way of branching. As our project is simple we choose simple model.
- You may watch this video for some other advanced branching models.
How to Add a Unit Test¶
What is and Why Unit Test¶
Unit test and unit testing are important concepts and activities that help us to write high quality code with productivity. Let’s highlight the folowing advantages:
- It allows part of our program to be test independently from ther others, hence helping us to focus on what we are testing.
- Unit testing can be automated, hence giving us a ability of testing our program automatically.
- It allows us to accumulate a suite of test cases. Imagine if I develop my feature with its corresponding test cases and you also do the same. Collectively we can test the different features of the program automatically.
Understanding Requirements¶
Let’s demostrate how to add a Unit to test the feature I am building, i.e. support of external hyperlink. Let’s understand the requirements:

As you can see above, hyperlinks are not displayed properly in the screen. We would like to add support for hyperlink such that:
- We would read the page line-by-line, and replace all `link description <link>`_ patterns such that they are instead become [ref=link]link description[/ref]. For example, the above link should be presented as [ref=https://en.wikipedia.org/wiki/Unit_testing]unit testing[/ref].
- There can be 1 or more hyperlink within single line. Each of them should be handled accordingly.
- Once clicked, a web browser should be launched to display the corresponding web page.
Let’s add a Unit Test for parsing and formatting the hyperlink as required above. We will leave launching a web browser to be done in the next module.
Adding Unit Test with Pycharm¶
- Add a method format_hyperlink(self, line) inside CourseApp class. For now, let’s simply add return line as its implementation.
- Add a file test_CourseApp.py. It should look like this. Press ALT-SHIFT-10 to run it.

As you can see. Pycharm will show you how many test cases are you passing / failing. In this case, as we haven’t implement anything yet in our format_hyperlink(self, line) function, it is expected that we have failing cases. Here we are demostrating one important feature on how unit test can be used to drive our development effort that:
- Before startng writing code, write test which fail first.
- Make change to pass tests.
- Repeat until you have passed all tests.
In later modules, you will see how we make use of unit testing to not just improve the correctness of our code, but also improve the quality of our code. We collectively call this effort a Test-driven Development (TDD) methdology. For now, let’s focus on writing code to passes all of our test cases first.
Implementing the Function to Pass the Tests¶
Let’s try implementing the function like the following:
def format_hyperlink(self, line):
return re.sub('`(.*) <([^>]*)>`_', r'[ref=\2]\1[/ref]', line)
And run the test again. This time we have passed 2 cases, but leaving 1 case failing:

Now let’s fix our code to be the following:
def format_hyperlink(self, line):
return re.sub('`([^`]*) <([^>]*)>`_', r'[ref=\2]\1[/ref]', line)
And run the test again. This time we have passed all tests. Cool!

Discussion¶
- In the implementation above, we are using Regular Expression module to help us extracting information from a pattern and replacing the matching pattern with the re-formatted information that was extracted previously. You may check out this video for a tutorial.
- Once you have finished, in your own word, can you explain what does teh regular expression do which passes all the tests?
- Then, in your own word, can you explain why the first attempt does not work for more than 1 hyperlink?
Next¶
Next, let’s integrate my change back to master.
Merging the New Feature to Master Branch¶
So now we are ready to push our change to master. I would type the following commands in my terminal, then creating a pull request in GitHub.
cd <my git folder>
git add .
git commit -am "Hyperlink Feature"
git checkout master
git pull
git checkout feature/hyperlink
git merge master
git push origin feature/hyperlink
Creating and Merging Pull Request¶
Pull request allows your teammates to review our change before it is merged into the master. Here are some links for background understanding on how does it work:
Next¶
Let’s make a new release 0.2.0 as a next step.
Making Another Release¶
Let’s make a new release. This can be done by the following.
cd <my git folder>
git checkut master
git pull
git checkout -b release/0.2.0
git push origin release/0.2.0
Making a release has the following advantages:
- At the end of each module for this course, we have create a new release branch. This way, students can refer to where they are as a snapshot to compare what has been changed from 1 module to the other.
- Similarly, for our Mobile Learning App as a software product, we also make release for each set of feature(s) we have added, such that we can fallback to previous version if there is any issue.
Exercise: Adding Support for Images¶
As a exercise, let’s add a feature to support images. For simplicity, we can simply extract the URL of the image and open it like we have done for hyperlink. Please do the following simialr to what we have done for hyperlink
- Create a feature branch feature/image
- Write a function format_image(self, line). When you can see ‘.. image : hyperlink.png’ in the line, return [ref=https://github.com/pythonicbridge/mobileapp.course/raw/master/docs/hyperlink.png]hyperlink.png: Click to view[/ref]
- Build a Unit Test to test the feature.
- Integrate the new function into the main.py.
- Commit your change locally.
Final Project¶
By this module, you should have built a fully functional Mobile Learning App, which maintains its course content dynamically from GitHub, such that it is generic and flexible. Well done!
Also, we would like to discuss the possibility to extend the Mobile Learning App by, for instance, the possibility to include a programming quiz module as future work. Due to the time constraint we will leave this as a final project for the students as planned :)
Optionally, we would like to show how to compile the Kivy app into a standalone APK Package that can be uploaded to Google Play store.
Let’s begin :)
Final Project: Implement a Programming Quiz in Our Mobile Learning App¶
Recall the steps we need to implement a new feature to our app:
- Understand our requirements.
- Implement the user interface.
- Write a test case.
- Implement the test case to pass the test.
- Integrate our change.
We will follow the steps exactly to implement the programming quiz feature. Due to the time constraints, for now we will disucss the high level design and leave the actual implementation as an exercise for the students.
Final Project: Requirements¶
Requirements¶
As usual we will read the RST file for their instruction. For simplicity, assume we have the following RST content:
.. code:: python
# PROGRAMMING QUIZ
import unittest2
def say_hello(something):
return something
class ProgrammingQuiz(unittest2.TestCase):
def test1(self):
self.assertEqual('Hello world', say_hello('world'))
# END OF PROGRAMMING QUIZ
When we intrepret the code directive, followed by # PROGRAMMING QUIZ comment, our application should be:
- Replace the whole code block as a ref, similar to what we did for hyperlink.
- We should also store everything found in this block into a CodeInput box such that it allows student to start editing the source code to complete the programming quiz.
- We should also provide buttons for students to (1) start over, (2) execute the code by running the unittest.main() and present the result, (3) go back to the page which triggers the programming test.
- We expect to have a seperate screen for programming quiz. You may check out this video on how to add another screen via Screen Manager in Kivy framework.
- We should have a way to (1) execute the program, (2) output of test cases, either passing or failing. For (1), we can look at this function. For (2) we can look at this article and this documentation.
Technical Requirements¶
- After you have implemented your change, if you copy your main.py into your mobile phone, you will found that the mobile app cannot be run. It is due to that CodeInput box requires Pygments for its syntax highlighting function, but Pygments is missing in Kivy launcher. To handle this, you may either (1), Fallback to Text Input (by adding a import fallback handler), (2) or add Pygments dependency and build via Buildozer as mentioned in the next page.
- (Optional) Ideally, we should provide a way to store and retrieve the programing quiz history such that students can track and revise later. Ideally, we should be able to leverage GitHub Gist for storage. This way, student and write their code on-the-go in cell phone, and carry on coding in front of desktop computer by checking out the Gist. Support of this feature is not hard but it involves a bit of integration effort. Cosider this as the final challenges :)
Starter Code / Test Cases¶
There is no starter code / start test cases for this time. You may refer to previous module on how to start :)
Final Project: Sample Programming Quiz¶
Sample Programming Quiz¶
If you implement the things correctly, the following code block will become a link the a programming quiz when your mobile app visit this page:
# PROGRAMMING QUIZ
import unittest2
def say_hello(something):
return something
class ProgrammingQuiz(unittest2.TestCase):
def test_say_hello(self):
self.assertEqual('Hello world', say_hello('world'))
# END OF PROGRAMMING QUIZ
And the screen would look something like this:

Reference Implementation¶
Due to the time constraint, we do not provide a reference implementation for this one (as planned). We might consider implementing one if time is still allowed. Stay tuned :)
Optional: How to build an App Which is Ready for Deployment into Google Play Store¶
So far we have been using Kivy Launcher to run our main.py file without any compliation. It works great for development. But if we want to deploy the app as a standalone program into Google Play Store, we need a way to build an APK Package. APK Package is a package that contains the following information:
- The compiled binary files and libraries required for the app.
- A manifest file describing the attributes for the app, such as orientation, permission needed, etc.
Kivy has a mechanism called buildozer that help us creating this package. Let’s see how does it work.
Step 1: Install Buildozer¶
sudo pip install buildozer
sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get install build-essential ccache git libncurses5:i386 libstdc++6:i386 libgtk2.0-0:i386 libpangox-1.0-0:i386 libpangoxft-1.0-0:i386 libidn11:i386 python2.7 python2.7-dev openjdk-8-jdk unzip zlib1g-dev zlib1g:i386
Step 2: Setup Buildozer for Our Mobile App¶
cd <your app folder>
buildozer init
vi buildozer.spec
This will open the buildozer.spec file. You may change permission / libraries needed in here. Click here for details.
Step 3: Run Buildozer¶
buildozer -v android debug
This will start the compilation. The first run will take long as it will download Android SDK and Android NDK. The subsquent run will be much faster.
Once the complication is done you should be able to see an apk file in <your app dir>/bin folder. You may use upload this file into your Google Drive and download it into your phone. Click on the APK file to install. If you ask for permission, grant it and it should complete the installation.
Step 4: Upload to Google Play Store (optional)¶
Click here for details. This step is optional as you need to pay google momey to do it :)