I started another OpenCourseWare (free online course), MITx: 6.00.1x Introduction to Computer Science and Programming Using Python, provided by MIT and hosted on edX.

I am currently also learning C with CS50x. When I was trying out the Project Euler questions, I realised that C cannot compute very large numbers, while Python can do it very easily. Moreover, Python is also an important programming language, so I decided to learn it.

Overall, concepts of Python is similar to C, and I can pick up fast. This is because programming languages such as C and Python are Turing complete, that is every computable operation can be made using these languages.

I will store my codes at Github: https://github.com/shaunlgs/MITx-6.00.1x-OCW-2014.

**pset1.Test.py**

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
def fibonacci(x): if x == 0: return 1 elif x == 1: return 2 return fibonacci(x-1) + fibonacci(x-2) x = 0 number = fibonacci(x) sum = 0 while number < 4000000: number = fibonacci(x) if (number % 2 == 0): sum += number x += 1 print(sum) |

This program calculates the sum of all the fibonacci numbers under 4 million. Fibonacci numbers are numbers calculated by adding the sum of previous two fibonacci numbers. The sequence starts as follows: 1, 1, 2, 3, 5, 8… The computer can do this very fast because they can perform 1 billion operations per second.

**pset1.1.py**

1 2 3 4 5 6 7 8 |
def countVowel(x): vowel = 0 for i in x: if i == 'a' or i == 'e' or i == 'i' or i == 'o' or i == 'u': vowel += 1 print("Number of vowels: " + str(vowel)) s = 'azcbobobegghakl' countVowel(s) |

This is a simple script that counts and prints the number of vowels in string s.

**pset1.2.py**

1 2 3 4 5 6 7 8 |
s = 'obobcobooloafbobb' count = 0 for i in range(len(s)): if s[i] == 'b' and not i >= (len(s) - 2): if s[i + 1] == 'o': if s[i + 2] == 'b': count += 1 print(count) |

This counts the number of occurrences of the string ‘bob’ in string s.

**pset1.3.py**

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
s = 'kuutfgwv' string = "" count = 0 longestCount = 0 longestString = "" for i in range(len(s)): # if i at the first character, automatically add the character to string if i == 0: string += s[i] count += 1 # if the current character is more than or equals to (in alphabeticall order) the previous number elif s[i] >= s[i - 1]: string += s[i] count += 1 # if the current character is less than (in alphabeticall order) the previous number elif s[i] < s[i - 1]: if count > longestCount: longestCount = count longestString = string # reset count, then count is incremented by one for current character. count = 0 count = 1 # reset string, then current character is added to string. string = "" string += s[i] # if i is at the last character, and the current character is continuation of a series of alphabets in ascending order, # it has not been compared with longestCount yet. if i == len(s) - 1: if count > 1: if count > longestCount: longestCount = count longestString = string print("Longest substring in alphabetical order is: " + longestString) |

This script prints the longest substring in alphabetical order of string s.

Hi there,

I would like some advice if you do not mind.

I once took a coursera course “Interactive Programming in Python”, about 2 years ago. but i just work through first four weeks. and now I do not remember the syntax and details.

Do you think this Edx course is a good one to help me refresh my memory? Or is it too much introductory? Is it self-paced so that I finish it in a month by just doing assignments and review notes without watching all videos?

Just a note that I am familiar with programming (C# and Java).

Thanks in advance

Hey Moe, actually I did not finish 6.00.1x as I find it quite dry. It will introduce everything from syntax to building programs, you can try it. Python is fairly easy if you already know C#.