Tuesday, July 30, 2019

AS Computer Science 9608 October 2019 Pre - Release 22

It's time again for Cambridge AS Examination for October / November 2019 series and for all students preparing for  computer science 9608 subject, here is your pre - release material.

WHile pre-release material provides only a glimpse of the possible problems or tasks in the actual CIE paper, it is best to still answer this pre-release material for mastery and confidence. Answer all tasks using structured English, pseudocode, flowchart, and actual program using the language you are comfortable in like Python, Visual Basic or Delphi Pascal. All the best!



Saturday, March 23, 2019

Serial, Sequential and Random Access File Organization Using Python

Records in a file can be stored in different ways:

  • Serial - records are kept without defined /specific order.They are stored as they happened like how we store deposit/withdrawal transactions. We append them after each other.
  • Sequential - Unlike serial, sequential requires the use of key field (like an ID) and organize them using this ID. 
  • Random - Serial and sequential records may be searched from beginning until the record is found. This cant be possible if we need fast access (like ATM bank query or withdrawal). So, random file requires that we store and search a record in any address (usually defined by a hash function).
See the program code below in Python how records are stored and searched using serial organization in a text file:


Now, using random file organization, we can use binary file to implement random access where seek ( ) is used to locate an address and dump( )  is used to write into the binary file and load( ) to read from the binary file. Know that we can also use text files to implement random and sequential organization. We only use binary file as these are the common file formats used be executable files and other software.

Unlike text files where we use the file mode: w (write), r (read),a (append), binary files use the following file mode: wb (write binary), rb (read binary), rb+ (read and append), you may use other file modes  too.

Writing to binary file:

Reading from binary file:

Please note that unlike text files, binary file keep records in its internal representation, meaning, you may special characters in the file as you open it in a text editor like Notepad.

Now try these and explore.




Friday, March 15, 2019

Palindrome using Recursion in Python

Recursion is one that calls itself.  Any loop can be represented in recursion.

Take for instance the example I wrote to check whether a word is a palindrome or not.

Palindrome is  a word, number, phrase or other sequence of characters which reads the same backward as forward such as madam, racecar or the number 10801.

See how the two functions are implemented, one using ordinary loop and one using recursion.


You can try the code and see whether the words are palindrome or not.

Monday, February 18, 2019

Integrating all Database Modules Using Python

We have done all CRUD operations of inserting records, reading records from the tables, updating records and finally deleting the records if necessary.  Click on the links if you need to review these blog articles.

The modules are all useless if they are called separately and you check your XAMPP SQL database back and forth  to see if changes have indeed happened.

This is now where we create our user interface by having a menu.  Now you may want to create hierarchical menus like the example below.

You can modify this, so, you may just have one main menu only.


 The import commands above are to link your menu to the CRUD modules you have done previously. So, modify the names if your files are named  differently.

Once the menu is shown, the if . . else  condition executed. So, if I choose 1, the insertSalesPerson module found in the file named connectsqlinsertdynamic will be called. 

Remember, however, that once we are done with one module (example Insert), we make sure that our main menu will appear again until we choose to exit.

Now, it is your turn to create the menu interface to call all CRUD modules of insert, read, update and delete database records.

Updating and Deleting Records From the Database Using Python

I have previously created blog articles how to insert a record into our database and  how to read database records using Python. Now, it is time to update and / or delete records from our database.

When we update, we can ask our user for a record to update, search it in our database and once this record is found, we retrieve it for updating.

The sample Python program code below shows how we can update the age of a certain person using the fname(first name) as our search condition (see highlighted text below).

You can change the age as a user input to make your code more dynamic.


Now, if you need to delete a record, we follow the same process we did with updating but we change our SQL command to enforce record deletion.

In the Python program code below, we ask the user for a first name to locate and delete, once we found the record, the SQL Delete command shall be executed.

You may need to refresh your database table to see effect.


Now, it is your turn to practice these modules on your own database!

Monday, February 11, 2019

Reading From Database Using Python

After inserting the records into our database table, it is only expected that we should read from the table using our Python code.

Our database table EMPLOYEE looks like this:


You can display ALL the entries of your table below:


The fechall() will actually read all the records from your table. Using the loop, each of the record will be displayed.  The row[0], for instance, acts as the variable to hold the value of the first field(using our table above, First_Name), and row[1] will be be for our field Last_Name.

Don't forget that the Python code above is a function. If you don't have a main menu, then, simply call this module by typing, read( ), in your main code.

To search and display a specific record from the table, your Python code should be like this. You can double click to enlarge the photo.


Now, try this on other tables you have!

Wednesday, February 6, 2019

Database Programming using Python


I finally decided to go back to blogging to at least maximize the payment I made on the domain name and help out my students in their Python coding.

So, I have to start it by writing some codes to enable insertion of a record to a database I have made using XAMPP SQL.

For the sample database I created, see below:



You have to create this database and the tables before you create your front-end code using Python. Make sure though that you install the needed database connector for your OS and Python version. In my case, I'm using Python 3.4 using Windows 10.

Now for us to insert a record, you can try the Python code below.



Now the username and password of your database is dependent on whether you have set this during SQL installation.  If none, then leave these parameters blank.  I have used SCHOOL for my database

Dont forget that we have installed the db connector earlier, so, to connect our Python with XAMPP sql, then we need IMPORT MYSQL.CONNECTOR.

CURSOR( ) is used to allow Python  to execute SQL commands during database session. With this we can insert, select, update, delete records with our database

Now, dont forget your SQL to insert into the needed field names. If you forgot this, go back to your XAMPP and check your table structure to see the field names and their data types.

The INSERT record program above allows you dynamic session. So, you can prompt your user for any input and with these inputs, we store them to our database.

I have called this function using a menu. Once, you have created all other operations like VIEW, UPDATE, DELETE, then, we can all call them using our menu interface.

To see if your code is working, run it and make sure that you shift to your XAMPP to see if the new record is added. See below:


Now, it's your turn!

Saturday, November 25, 2017

Bina Bangsa School Teachers Support Charity Run Fest 2017

In the Philippines, I used to race competitively but I shall always be grateful that I have my Team Matutum teammates with me to race and have fun together.

So, I could only be happier that I am now in Indonesia teaching in a good school school with good people around. And, to do your passion for running with your  new running group, mine is the Solemates, I could only be grateful everyday.

Before the end of 2017, my fellow teachers were able to run in three different races, latest was the Charity Run for Cancer Patients where around 117 millions rupee were collected from the race. Having  a father stricken with cancer, the run is somehow personal and inspiring to me.

Teachers of Bina Bangsa School - PIK  post - race

Thirty teachers, both from primary and secondary departments,  from Bina Bangsa School - PIK joined other runners in 5KM and 10KM distances.

my fellow teachers - solemates running for cancer patients

With a worthy cause, we couldn't only be proud that we were able to support the run and have fun at the same time. We look forward then to more races in the future with worthy advocacy. 
winning 2nd placer from 10km female category

Now, did I mention that I won, 2nd place in the 10km female category? I was just lucky though!

So, congratulations to the organizers of Charity Run Fest 2017 and to Bina Bangsa School - PIK teachers for one good race, one good cause!


Thursday, March 30, 2017

Music: Help You Study for Exam

Final Examination is just around the corner and just recently I had to help some students with their ICT practical as they had their Final Exams in IT. I can't help but at least be worried with them as they cram for their exams.

The idea is to prepare in advance with all the resources, and support groups (teachers, family or studymates). But, you can do better if you have a timetable and strictly follow it and have quality study time.

photo source: https://sites.psu.edu


Equally important is the fact that you can use music to help you focus and concentrate.  University research in France, published in Learning and Individual Differences,  found out that students who listened to one-hour music while listening to classical music scored better in their quiz than students who don't.

They say that music can get you to heightened emotional state that makes you more receptive to information. Furthermore,  according to a research from Duke Cancer Institute, music can help lessen the anxiety.

Music help you relax; so, while preparing for your exam, listen to classical music and with crown xls1000 can help you enjoy the music as you focus on your exam.

It is only through hard work, quality reviews, and the right resources can help you get better marks.

References:

Studying for Finals? Let Classical Music Help You


What Travel Can Teach Teachers, Our Taman Mini Escapade

Travel can teach a lot of things to people but I wish to cite good stuffs if you are a teacher.

While on our school term break, my three (3) other teachers had decided to go to Taman Mini Indonesia Indah (TMII) or simply means "Beautiful Indonesia Mininiature Park."

Taman Mini Indonesia Indah is a culture - based recreational park where diverse culture of Indonesia depicted through  various sites where different houses, and other art collections are kept for tourists and locals.

at the site of Bali - inspired area of Taman Mini
At very minimal budget, we maximized the BusWay's TransJakarta big buses where only 3.50 IDR ($.26) was spent for almost 2 hours of travel from GreenBay Pluit Mall to Taman Mini.

We took the cable ride at 40 IDR where we were able to see the  various houses on panoramic scale. I had to get amazed by their beautiful lake where it resembles the different islands of Indonesia.

at Komodo Dragon Museum, Taman Mini, with fellow teachers.

Travel to different places make people, even teachers included to be more confident with their social and directional skills. Good thing though we had one teacher who had been  to Taman Mini several times.

Apart from this, you cant help but learn to adopt to the local language, appreciate their local food and their distinct culture.

So, what valued lesson can teachers acquire from travelling? I think the fact that you get to see diversity and appreciate its richness and uniqueness and how you can actually blend with this new environment can actually help teachers to be open minded especially if students come from different economic or social background.

So, next time you have the chance to travel, go out and explore. You may able to learn new things from it and only you and your students can highly benefit from the fresh experience.

AddThis