Tag Archives: Python

Python Challenge Level 1

A couple of days back, I tried started solving questions from Python Challenge. In all there are 33 levels. I’ve completed the first few levels and I plan to blog about them. This is one is about how I solved the first level. Pull up a terminal and type, “python”. You get an interactive shell. Just type 2**38 and you get  the answer.

savita@Amrita:~/python_challenge$ python
Python 2.7.3 (default, Aug  1 2012, 05:16:07)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 2**38

Now following what the hint suggests, change the URL. The original URL is : http://www.pythonchallenge.com/pc/def/0.html . I tried changing that to : http://www.pythonchallenge.com/pc/def/274877906944L.html . As a result, I got this message : “the L in unnecessary”.  So I removed the L from the URL, and bingo !!! I got to the next level. This is the simplest way of doing it. You could even resort to scripting the command in a file and then executing the file. There are also ways of doing it.

Another way of solving this level is :

>>>pow(2, 38)

You could start too 🙂


Python programming language

It’s Sunday and I didn’t know how to kill time. So I thought I’d post about Python programming language. Python is a very easy to learn programming language. Once you start learning it, you’ll fall in love with it. According to me, anyone trying to learn programming for the first time should start with Python as it cuts down on a lot of syntax that may be meaningless to the newbies. The language was written by Guido van Rossum. The logo for Python programming language (which was designed by Gudio van Rossum’s brother, Just van Rossum).

Python logo

Some things about Python that are noteworthy are :

  1. Python is an interpreted language. It interprets and executes the code scripted in files.
  2. It also has an interactive shell that executes arbitrary statements.
  3. Python code can be easily read and understood even by a person who’s absolutely blank about the language.
  4. It supports both structural programming and object-oriented programming.

Those who want to start learning Python could start off with Coding bat : http://codingbat.com/python . This website has a got a whole lot of questions which will strengthen your  basic knowledge of the language. For those who wish to delve deeper, Python challenge would be good (But this is just what I feel. It could be the other way around for some people). A couple of days back, I started doing Python challenge a couple of days back and am finding it interesting. I suggest that you learning Python too.