Tuesday, April 2, 2013

Tutorial: Python 3.3.0

If we need use Amazon EC2 to do the Big Data project, we have to know the Python programming language. The example we used in the class had been explained by Xinyu. Python runs on Windows, Linux/Unix, Max OS X, and has been ported to the Java and .Net virtual machines.

Python is free to use. Today I want to show you how to install Python software and the detailed tutorial.

1. Go to www.python.org


2.  Choose the right installer for your OS in the download page. I choose Python 3.3.0 Windows X86-64.


3.  Follow the steps to install it.
4. Choose IDLE in your programs to start programming.

5. If you want to program in files. You can choose file >> New window. And after the programming, you can click Run >>> Run the Module.


Now you have know how to install and use python. Next I want to show you some detailed tutorial for programming in Python. This is a YouTube playlist. The playlist address is https://www.youtube.com/watch?v=4Mf0h3HphEA&list=ECEA1FEF17E1E5C0DA You might need 10 hrs to learn that. It is very helpful.





2 comments:

  1. This is an interesting and helpful tutorial. I installed both in Windows and Ubuntu. I also found another website which is a learning material for Python, the website link is:

    http://cscircles.cemc.uwaterloo.ca/

    It teaches different python programming functions. And this lesson does not require any programming experience. It means that it will teach the reader what is variable, what error in programming is and what is function etc.

    I think this website is better than other websites. The best is that it provides "live exercise". The author provides a compiler for each exercise. When the reader completes an exercise, and click run program, the program will be compiled and ran. This process is as same as the process in real python editor.

    This compiler is also a grader. When you give the wrong answers, it will show the mistakes and tell the reader why it is wrong.

    Xinyu introduced Python 2.x in class. From this website introduced Python 3.3, I noticed, in Python 3.3, when print something, it should be written as:
    print ( )
    not
    print " "

    The reason is, "print" in 2.x is a state, while in 3.x is function.

    Hence, the wordsplitter example program is written as:

    #!/usr/bin/python
    import sys
    import re

    def main(argv):
    pattern = re.compile("[a-zA-Z][a-zA-Z0-9]*")
    for line in sys.stdin:
    for word in pattern.findall(line):
    print "LongValueSum:" + word.lower() + "\t" + "1"
    if __name__ == "__main__":
    main(sys.argv)

    Now in Python 3.x ti should be written as
    #!/usr/bin/python
    import sys
    import re

    def main(argv):
    pattern = re.compile("[a-zA-Z][a-zA-Z0-9]*")
    for line in sys.stdin:
    for word in pattern.findall(line):
    print ("LongValueSum:" + word.lower() + "\t" + "1")

    if __name__ == "__main__":
    main(sys.argv)

    ReplyDelete
    Replies
    1. That is correct. There are lots of changes in Python 3.3 compared with Python 2.x. In Python 2.x, there are some differences between the function "input" and "raw_input", but in Python 3.3.0, it combine the function "input" and "raw_input" to "input" only. Also the print ''' doesn't work in Python 3.3.0. If you find other differences, please reply this. Thanks.

      Delete