Are rational numbers countable?

The original article was penned for a the magazine, Teacher, published by the Karnataka chapter of Bharat Gyan Vigyan Samiti. The intended audiences are a combination of high school math teachers and students of the age group 13-15, hence the lack of formal language and rigour. Suggestions and comments are welcome

What is a rational number? A number which can be expressed in the form $\frac{p}{q}$ ($p$ and $q$ being integers) is called a rational number. These numbers follow some interesting properties.

Firstly, between any two rational numbers, there is another rational number.

Try this as an exercise - choose two rational numbers which you feel are close by and try to list a few numbers in between them. You will see that you can grow your list forever. Say you pick $\frac{2}{5}$ and $\frac{3}{5}$ . Lets try to follow a pattern when listing numbers in between them. We know for certain that the average of two numbers in between them. So first, I pick their average $\frac{1}{2}$. Now I take the average of $\frac{2}{5}$ and $\frac{1}{2}$ - $\frac{9}{20}$. Now I take the average of $\frac{2}{5}$ and $\frac{9}{20}$ - $\frac{13}{20}$. And so on. Following this technique, I will be able to keep on listing number, all which are between $\frac{2}{5}$ and $\frac{3}{5}$. We have just demonstrated that there are infinitely many numbers in between any two rational numbers.

Mathematicians call the set of all rational numbers as a densely ordered set because of this beautiful property.

Now let us introduce real numbers. Continue reading Are rational numbers countable?

Being into design related stuff since joining college, I've found it a necessity to maintain a decent font collection. In this post, I will share and explain the script which helped me to create my collection.

What my script does is download fonts directly off a top 20 list of fonts from dafont.com, for each sub-category available there.

The website has a very organized way to let users download fonts. First, there are categories like Fancy, Foreign Look, Techno, Gothic etc. Under each of these categories, there are sub-categories. Each subcategory has an ID which will help our purpose.

You can just change the ID range in the script to download fonts of different category.

The Script

#! /usr/bin/python

# Version: 0.3
# Author: Pranav Ashok
# Author-email: iam@pranavashok.com
# Author-homepage: http://pranavashok.com/blog

from BeautifulSoup import BeautifulSoup
import re
import os
import commands
import string

for cat in range(101, 119): #ID Range 101-119
url = 'http://www.dafont.com/theme.php?cat=%d&nb_ppp=20' % cat
contents = commands.getoutput("curl -s '"+url+"'")

soup = BeautifulSoup(contents)
directory = soup.find('title').contents
wholeTag = soup.findAll('a', {"class" : "dl"})
directory[0] = string.rstrip(directory[0], " | dafont.com")
fontCat, useless, subCat = directory[0].partition(" > ")

w.write('mkdir \"%s\"\n' % fontCat)
w.write('cd \"%s\"\n' % fontCat)

w.write('mkdir \"%s\"\n' % subCat)
w.write('cd \"%s\"\n' % subCat)
fileName, fileExt = os.path.splitext(name)
fileName = string.lstrip(fileName, "?f=")
w.write('wget -c -O \"%s.zip\" \"%s\" \n' % (fileName, link['href']))
w.write('cd ..\n')
w.write('cd ..\n')
w.close()

I recently became addicted to TED Videos. This inspired me to create a simple python script which helps one download TED Talks in bulk. Here is the main part of the script. Scroll down for download link and usage instructions.

#! /usr/bin/python

# Version: 0.4
# Author: Pranav Ashok
# Author-email: iam@pranavashok.com
# Author-homepage: http://pranavashok.com/blog

from BeautifulSoup import BeautifulSoup
from urllib2 import urlopen
import re
import os
import sys

f = open(sys.argv[1], 'r')

fileName, fileExt = os.path.splitext(name)
outputFile = fileName+".mp4"

# wholeTag['href'] gives the value of the href attribute

w.close()
exit()

Start Using Linux - Basic Terminal Commands

This is a compilation of some terminal commands I've found useful.

Before starting, I'd like to emphasize on a few things:
- You might want to understand the filesystem hierarchy in linux before you start.
- When you start terminal, your default working directory is /home/user-name
- If you want to get more info on any command, just type '
command-name --help' without the quotes in terminal.
- In this post, when I say 'type' something in terminal, it means 'execute it' by typing it and pressing enter.
- Whenever you want to end a looping command, for example, ping in terminal - press Ctrl + C.

Continue reading Start Using Linux - Basic Terminal Commands

Creating a WordPress Sandbox - Installing WordPress Locally

Here's a video I created an hour ago. Basically, it guides you in creating a wordpress sandbox to test your themes/plugins and other features of wordpress.

1. WAMPServer 2 from http://www.wampserver.com/dl.php) and;
2. WordPress from http://wordpress.org/latest.zip)

I'm planning to create more tutorial videos. Please give your suggestions, if any.

Batch Script to Generate File/Folder Listing

I was chatting with a friend who had a huge music collection and I wanted to know what all he had. This provoked me to make a batch script which would do the job. I did some research online and found out some basics of batch scripts. This is the final thing which I ended up with.

@echo Directory listing will be created at c:\dirList.txt
@dir %1 /S > c:\dirList.txt
@pause