├── Classes ├── README.md └── product_inventory.py ├── Classic Algorithms ├── README.md └── collatz.py ├── Data Structures └── README.md ├── Databases └── README.md ├── Files └── README.md ├── Graphics and Multimedia └── README.md ├── Graphs └── README.md ├── LICENSE ├── Networking └── README.md ├── Numbers ├── README.md ├── alarm.py ├── binary_decimal.py ├── calc.py ├── change.py ├── credit_card_validator.py ├── distance.py ├── factorial.py ├── fibonacci.py ├── happy_numbers.py ├── next_prime.py ├── pi.py ├── prime.py ├── tax.py ├── tile.py └── unit.py ├── README.md ├── Security └── README.md ├── Text ├── README.md ├── caesar_cipher.py ├── count_vowels.py ├── count_words.py ├── palindrome.py ├── piglatin.py ├── reverse.py └── rss.py ├── Threading └── README.md └── Web ├── README.md ├── page_scraper.py └── time.py /Classes/README.md: -------------------------------------------------------------------------------- 1 | Classes 2 | --------- 3 | 4 | **Product Inventory Project** - Create an application which manages an inventory of products. Create a product class which has a price, id, and quantity on hand. Then create an *inventory* class which keeps track of various products and can sum up the inventory value. 5 | 6 | **Airline / Hotel Reservation System** - Create a reservation system which books airline seats or hotel rooms. It charges various rates for particular sections of the plane or hotel. Example, first class is going to cost more than coach. Hotel rooms have penthouse suites which cost more. Keep track of when rooms will be available and can be scheduled. 7 | 8 | **Bank Account Manager** - Create a class called Account which will be an abstract class for three other classes called CheckingAccount, SavingsAccount and BusinessAccount. Manage credits and debits from these accounts through an ATM style program. 9 | 10 | **Patient / Doctor Scheduler** - Create a patient class and a doctor class. Have a doctor that can handle multiple patients and setup a scheduling program where a doctor can only handle 16 patients during an 8 hr work day. 11 | 12 | **Recipe Creator and Manager** - Create a recipe class with ingredients and a put them in a recipe manager program that organizes them into categories like deserts, main courses or by ingredients like chicken, beef, soups, pies etc. 13 | 14 | **Image Gallery** - Create an image abstract class and then a class that inherits from it for each image type. Put them in a program which displays them in a gallery style format for viewing. 15 | 16 | **Shape Area and Perimeter Classes** - Create an abstract class called Shape and then inherit from it other shapes like diamond, rectangle, circle, triangle etc. Then have each class override the area and perimeter functionality to handle each shape type. 17 | 18 | **Flower Shop Ordering To Go** - Create a flower shop application which deals in flower objects and use those flower objects in a bouquet object which can then be sold. Keep track of the number of objects and when you may need to order more. 19 | 20 | **Family Tree Creator** - Create a class called Person which will have a name, when they were born and when (and if) they died. Allow the user to create these Person classes and put them into a family tree structure. Print out the tree to the screen. -------------------------------------------------------------------------------- /Classes/product_inventory.py: -------------------------------------------------------------------------------- 1 | """ 2 | Product Inventory Project - Create an application which manages 3 | an inventory of products. Create a product class which has a 4 | price, id, and quantity on hand. Then create an inventory class 5 | which keeps track of various products and can sum up the inventory 6 | value. 7 | """ 8 | 9 | class Product: 10 | 11 | def __init__(self, price, pid, qty): 12 | """ 13 | Class constructor that needs a price, a product id, 14 | and quantity. 15 | """ 16 | self.price = price 17 | self.pid = pid 18 | self.qty = qty 19 | 20 | def update_qty(self, qty, method='add'): 21 | """ 22 | Updates the quantity of produts. By default, adds the 23 | passed quantity. Pass method as 'subtract' to subtract 24 | the quantity. 25 | """ 26 | if method == 'add': 27 | self.qty += qty 28 | elif method == 'subtract': 29 | self.qty = max(0, self.qty - qty) 30 | 31 | def print_product(self): 32 | """ 33 | Prints a single product. 34 | """ 35 | print '%d\t%s\t%.02f each' % (self.pid, self.qty, self.price) 36 | 37 | class Inventory: 38 | 39 | def __init__(self): 40 | """ 41 | Initializes the class instance. 42 | """ 43 | self.products = [] # list to hold all products 44 | 45 | def add(self, product): 46 | """ 47 | Adds a passed Product to the list of products. 48 | """ 49 | self.products.append(product) 50 | 51 | def print_inventory(self): 52 | """ 53 | Prints the current inventory, and the total value 54 | of products. 55 | """ 56 | value = 0 57 | for product in self.products: 58 | print '%d\t%s\t%.02f each' % (product.pid, 59 | product.qty, 60 | product.price) 61 | value += (product.price * product.qty) 62 | print '\nTotal value: %.02f' % value 63 | 64 | if __name__ == '__main__': 65 | p1 = Product(1.4, 123, 5) 66 | p2 = Product(1, 3432, 100) 67 | p3 = Product(100.4, 2342, 99) 68 | 69 | 70 | i = Inventory() 71 | i.add(p1) 72 | i.add(p2) 73 | i.add(p3) 74 | i.print_inventory() 75 | 76 | p1.update_qty(10) 77 | i.print_inventory() 78 | 79 | p1.update_qty(10, method='subtract') 80 | i.print_inventory() 81 | -------------------------------------------------------------------------------- /Classic Algorithms/README.md: -------------------------------------------------------------------------------- 1 | Classic Algorithms 2 | ----------------- 3 | 4 | **Collatz Conjecture** - Start with a number *n > 1*. Find the number of steps it takes to reach one using the following process: If *n* is even, divide it by 2. If *n* is odd, multiply it by 3 and add 1. 5 | 6 | **Sorting** - Implement two types of sorting algorithms: Merge sort and bubble sort. 7 | 8 | **Closest pair problem** - The closest pair of points problem or closest pair problem is a problem of computational geometry: given *n* points in metric space, find a pair of points with the smallest distance between them. 9 | 10 | **Sieve of Eratosthenes** - The sieve of Eratosthenes is one of the most efficient ways to find all of the smaller primes (below 10 million or so). 11 | -------------------------------------------------------------------------------- /Classic Algorithms/collatz.py: -------------------------------------------------------------------------------- 1 | """ 2 | Collatz Conjecture - Start with a number n > 1. 3 | Find the number of steps it takes to reach one using 4 | the following process: If n is even, divide it by 2. 5 | If n is odd, multiply it by 3 and add 1. 6 | """ 7 | 8 | def main(): 9 | try: 10 | n = int(raw_input('Enter a number: ')) 11 | except ValueError: 12 | print 'Enter only an integer value, n > 1.' 13 | 14 | steps = 0 15 | 16 | print '\n%d' % n, 17 | 18 | while n > 1: 19 | if n % 2 == 0: 20 | n /= 2 21 | else: 22 | n = (n * 3) + 1 23 | steps += 1 24 | print ' -> %d' % n, 25 | 26 | print '\n\n%d steps take to reach ONE.' % steps 27 | 28 | if __name__ == '__main__': 29 | main() 30 | -------------------------------------------------------------------------------- /Data Structures/README.md: -------------------------------------------------------------------------------- 1 | Data Structures 2 | --------- 3 | 4 | **Inverted index** - An [Inverted Index](http://en.wikipedia.org/wiki/Inverted_index) is a data structure used to create full text search. Given a set of text files, implement a program to create an inverted index. Also create a user interface to do a search using that inverted index which returns a list of files that contain the query term / terms. The search index can be in memory. -------------------------------------------------------------------------------- /Databases/README.md: -------------------------------------------------------------------------------- 1 | Databases 2 | --------- 3 | 4 | **SQL Query Analyzer** - A utility application which a user can enter a query and have it run against a local database and look for ways to make it more efficient. 5 | 6 | **Remote SQL Tool** - A utility that can execute queries on remote servers from your local computer across the Internet. It should take in a remote host, user name and password, run the query and return the results. 7 | 8 | **Report Generator** - Create a utility that generates a report based on some tables in a database. Generates a sales reports based on the order/order details tables or sums up the days current database activity. 9 | 10 | **Event Scheduler and Calendar** - Make an application which allows the user to enter a date and time of an event, event notes and then schedule those events on a calendar. The user can then browse the calendar or search the calendar for specific events. *Optional: Allow the application to create re-occurrence events that reoccur every day, week, month, year etc.* 11 | 12 | **Budget Tracker** - Write an application that keeps track of a household’s budget. The user can add expenses, income, and recurring costs to find out how much they are saving or losing over a period of time. *Optional: Allow the user to specify a date range and see the net flow of money in and out of the house budget for that time period.* 13 | 14 | **Address Book** - Keep track of various contacts, their numbers, emails and little notes about them like a Rolodex in the database. 15 | 16 | **TV Show Tracker** - Got a favorite show you don’t want to miss? Don’t have a PVR or want to be able to find the show to then PVR it later? Make an application which can search various online TV Guide sites, locate the shows/times/channels and add them to a database application. The database/website then can send you email reminders that a show is about to start and which channel it will be on. 17 | 18 | **Travel Planner System** - Make a system that allows users to put together their own little travel itinerary and keep track of the airline / hotel arrangements, points of interest, budget and schedule. -------------------------------------------------------------------------------- /Files/README.md: -------------------------------------------------------------------------------- 1 | Files 2 | --------- 3 | 4 | **Quiz Maker** - Make an application which takes various questions form a file, picked randomly, and puts together a quiz for students. Each quiz can be different and then reads a key to grade the quizzes. 5 | 6 | **File Explorer** - Create your own simple windows explorer program. Add feature(s) you always thought are missing from MS Windows Explorer or Mac Finder. 7 | 8 | **Sort Excel/CSV File Utility** - Reads a file of records, sorts them, and then writes them back to the file. Allow the user to choose various sort style and sorting based on a particular field. 9 | 10 | **Create Zip File Maker** - The user enters various files from different directories and the program zips them up into a zip file. *Optional: Apply actual compression to the files. Start with Huffman Algorithm.* 11 | 12 | **PDF Generator** - An application which can read in a text file, html file or some other file and generates a PDF file out of it. Great for a web based service where the user uploads the file and the program returns a PDF of the file. *Optional: Deploy on GAE or Heroku if possible.* 13 | 14 | **Mp3 Tagger** - Modify and add ID3v1 tags to MP3 files. See if you can also add in the album art into the MP3 file’s header as well as other ID3v2 tags. 15 | 16 | **Code Snippet Manager** - Another utility program that allows coders to put in functions, classes or other tidbits to save for use later. Organized by the type of snippet or language the coder can quickly look up code. *Optional: For extra practice try adding syntax highlighting based on the language.* -------------------------------------------------------------------------------- /Graphics and Multimedia/README.md: -------------------------------------------------------------------------------- 1 | Graphics and Multimedia 2 | --------- 3 | 4 | **Slide Show** - Make an application that shows various pictures in a slide show format. *Optional: Try adding various effects like fade in/out, star wipe and window blinds transitions.* 5 | 6 | **Stream Video from Online** - Try to create your own online streaming video player. 7 | 8 | **Mp3 Player** - A simple program for playing your favorite music files. Add features you though are missing from your favorite music player. 9 | 10 | **Watermarking Application** - Have some pictures you want copyright protected? Add your own logo or text lightly across the background so that no one can simply steal your graphics off your site. Make a program that will add this watermark to the picture. *Optional: Use threading to process multiple images simultaneously.* 11 | 12 | **Turtle Graphics** - This is a common project where you create a floor of 20 x 20 squares. Using various commands you tell a turtle to draw a line on the floor. You have move forward, left or right, lift or drop pen etc. Do a search online for "Turtle Graphics" for more information. *Optional: Allow the program to read in the list of commands from a file.* -------------------------------------------------------------------------------- /Graphs/README.md: -------------------------------------------------------------------------------- 1 | Graphs 2 | ------ 3 | 4 | **Graph from links** - Create a program that will create a graph or network from a series of links. 5 | 6 | **Eulerian Path** - Create a program which will take as an input a graph and output either a Eulerian path or a Eulerian cycle, or state that it is not possible. A Eulerian Path starts at one node and traverses every edge of a graph through every node and finishes at another node. A Eulerian cycle is a eulerian Path that starts and finishes at the same node. 7 | 8 | **Connected Graph** - Create a program which takes a graph as an input and outputs whether every node is connected or not. 9 | 10 | **Dijkstra’s Algorithm** - Create a program that finds the shortest path through a graph using its edges. 11 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Karan Goel 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Networking/README.md: -------------------------------------------------------------------------------- 1 | Networking 2 | --------- 3 | 4 | **FTP Program** - A file transfer program which can transfer files back and forth from a remote web sever. 5 | 6 | **Bandwidth Monitor** - A small utility program that tracks how much data you have uploaded and downloaded from the net during the course of your current online session. See if you can find out what periods of the day you use more and less and generate a report or graph that shows it. 7 | 8 | **Port Scanner** - Enter an IP address and a port range where the program will then attempt to find open ports on the given computer by connecting to each of them. On any successful connections mark the port as open. 9 | 10 | **Mail Checker (POP3 / IMAP)** - The user enters various account information include web server and IP, protocol type (POP3 or IMAP) and the application will check for email at a given interval. 11 | 12 | **Country from IP Lookup** - Enter an IP address and find the country that IP is registered in. *Optional: Find the Ip automatically.* 13 | 14 | **Whois Search Tool** - Enter an IP or host address and have it look it up through whois and return the results to you. 15 | 16 | **Site Checker with Time Scheduling** - An application that attempts to connect to a website or server every so many minutes or a given time and check if it is up. If it is down, it will notify you by email or by posting a notice on screen. -------------------------------------------------------------------------------- /Numbers/README.md: -------------------------------------------------------------------------------- 1 | Numbers 2 | --------- 3 | 4 | **Find PI to the Nth Digit** - Enter a number and have the program generate PI up to that many decimal places. Keep a limit to how far the program will go. 5 | 6 | **Fibonacci Sequence** - Enter a number and have the program generate the Fibonacci sequence to that number or to the Nth number. 7 | 8 | **Prime Factorization** - Have the user enter a number and find all Prime Factors (if there are any) and display them. 9 | 10 | **Next Prime Number** - Have the program find prime numbers until the user chooses to stop asking for the next one. 11 | 12 | **Find Cost of Tile to Cover W x H Floor** - Calculate the total cost of tile it would take to cover a floor plan of width and height, using a cost entered by the user. 13 | 14 | **Mortgage Calculator** - Calculate the monthly payments of a fixed term mortgage over given Nth terms at a given interest rate. Also figure out how long it will take the user to pay back the loan. 15 | 16 | **Change Return Program** - The user enters a cost and then the amount of money given. The program will figure out the change and the number of quarters, dimes, nickels, pennies needed for the change. 17 | 18 | **Binary to Decimal and Back Converter** - Develop a converter to convert a decimal number to binary or a binary number to its decimal equivalent. 19 | 20 | **Calculator** - A simple calculator to do basic operators. Make it a scientific calculator for added complexity. 21 | 22 | **Unit Converter (temp, currency, volume, mass and more)** - Converts various units between one another. The user enters the type of unit being entered, the type of unit they want to convert to and then the value. The program will then make the conversion. 23 | 24 | **Alarm Clock** - A simple clock where it plays a sound after X number of minutes/seconds or at a particular time. 25 | 26 | **Distance Between Two Cities** - Calculates the distance between two cities and allows the user to specify a unit of distance. This program may require finding coordinates for the cities like latitude and longitude. 27 | 28 | **Credit Card Validator** - Takes in a credit card number from a common credit card vendor (Visa, MasterCard, American Express, Discoverer) and validates it to make sure that it is a valid number (look into how credit cards use a checksum). 29 | 30 | **Tax Calculator** - Asks the user to enter a cost and either a country or state tax. It then returns the tax plus the total cost with tax. 31 | 32 | **Dijkstra’s Algorithm** - Create a program that finds the shortest path through a graph using its edges. 33 | 34 | **Factorial Finder** - The Factorial of a positive integer, n, is defined as the product of the sequence n, n-1, n-2, ...1 and the factorial of zero, 0, is defined as being 1. Solve this using both loops and recursion. 35 | 36 | **Complex Number Algebra** - Show addition, multiplication, negation, and inversion of complex numbers in separate functions. (Subtraction and division operations can be made with pairs of these operations.) Print the results for each operation tested. 37 | 38 | **Happy Numbers** - A happy number is defined by the following process. Starting with any positive integer, replace the number by the sum of the squares of its digits, and repeat the process until the number equals 1 (where it will stay), or it loops endlessly in a cycle which does not include 1. Those numbers for which this process ends in 1 are happy numbers, while those that do not end in 1 are unhappy numbers. Display an example of your output here. Find first 8 happy numbers. 39 | 40 | **Number Names** - Show how to spell out a number in English. You can use a preexisting implementation or roll your own, but you should support inputs up to at least one million (or the maximum value of your language's default bounded integer type, if that's less). *Optional: Support for inputs other than positive integers (like zero, negative integers, and floating-point numbers).* 41 | 42 | **Coin Flip Simulation** - Write some code that simulates flipping a single coin however many times the user decides. The code should record the outcomes and count the number of tails and heads. 43 | -------------------------------------------------------------------------------- /Numbers/alarm.py: -------------------------------------------------------------------------------- 1 | """ 2 | Alarm Clock - A simple clock where it plays a sound after 3 | X number of minutes/seconds or at a particular time. 4 | 5 | Dependencies: 6 | pyglet 7 | pip install pyglet 8 | """ 9 | 10 | import time 11 | import winsound 12 | import pyglet 13 | 14 | def play(hh, mm): 15 | not_alarmed = 1 16 | 17 | while(not_alarmed): 18 | cur_time = list(time.localtime()) # get the time right now 19 | hour = cur_time[3] # find the hour 20 | minute = cur_time[4] # and the minute 21 | if hour == hh and minute == mm: 22 | song = pyglet.media.load('bin/sound.wav') 23 | song.play() # play the sound 24 | pyglet.app.run() 25 | not_alarmed = 0 # stop the loop 26 | 27 | if __name__ == '__main__': 28 | 29 | print """ 30 | 1. Play sound after X minutes 31 | 2. Play sound at an exact time 32 | """ 33 | choice = input('What do you want to do? ') 34 | 35 | if choice == 1: 36 | mins = input('How many minutes from now? ') 37 | hh_from_now = mins / 60 # if minutes > 60, this will adjust the hours 38 | mm_from_now = mins % 60 # and then the minutes 39 | cur_time = list(time.localtime()) # get the time right now 40 | hour = cur_time[3] # find the current hour 41 | minute = cur_time[4] # and the current minute 42 | hh = (hour + hh_from_now+(minute+mm_from_now)/60) % 24 # cycle through the clock if hh > 24 43 | mm = (minute + mm_from_now) % 60 # cycle through the clock if mm > 60 44 | play(hh, mm) 45 | elif choice == 2: 46 | hh = input('What hour do you want to wake up (0-23)? ') 47 | mm = input('What minute do you want to wake up (0-59)? ') 48 | play(hh, mm) 49 | 50 | -------------------------------------------------------------------------------- /Numbers/binary_decimal.py: -------------------------------------------------------------------------------- 1 | """ 2 | Binary to Decimal and Back Converter 3 | Develop a converter to convert a decimal number to binary 4 | or a binary number to its decimal equivalent. 5 | """ 6 | 7 | def binary_to_decimal(binary): 8 | """ 9 | Converts a binary number into a decimal number. 10 | """ 11 | decimal = 0 12 | index = 0 13 | while binary > 0: 14 | last = binary % 10 15 | binary = binary / 10 16 | decimal += (last * (2 ** index)) 17 | index += 1 18 | return decimal 19 | 20 | def decimal_to_binary(decimal): 21 | """ 22 | Converts a decimal number into a binary number. 23 | """ 24 | binary = "" 25 | remainders = [] 26 | while decimal > 0: 27 | remainders.append(str(decimal % 2)) 28 | decimal /= 2 29 | remainders.reverse() 30 | binary = "".join(remainders) 31 | return 0 if binary == "" else binary 32 | 33 | if __name__ == '__main__': 34 | print """ 35 | 1. Binary to Decimal 36 | 2. Decimal to Binary\n 37 | """ 38 | 39 | choice = input("Make a choice: ") 40 | 41 | if choice == 1: 42 | binary = input("Binary to convert: ") 43 | print "The binary number %d in decimal is %d" % \ 44 | (binary, binary_to_decimal(binary)) 45 | elif choice == 2: 46 | decimal = input("Decimal to convert: ") 47 | print "The decimal number %d in binary is %s" % \ 48 | (decimal, decimal_to_binary(decimal)) 49 | else: 50 | print "Invalid choice" 51 | -------------------------------------------------------------------------------- /Numbers/calc.py: -------------------------------------------------------------------------------- 1 | """ 2 | Calculator - A simple calculator to do basic operators. 3 | """ 4 | 5 | if __name__ == '__main__': 6 | try: 7 | num1 = int(raw_input("Number 1: ")) 8 | num2 = int(raw_input("Number 2: ")) 9 | except: 10 | print 'Invalid input' 11 | else: 12 | op = raw_input("Operation (+, -, /, *): ") 13 | if op not in '+-/*': 14 | print "Invalid operator" 15 | else: 16 | print "%d %s %d = %d" % \ 17 | (num1, op, num2, eval(str(num1) + op + str(num2))) 18 | -------------------------------------------------------------------------------- /Numbers/change.py: -------------------------------------------------------------------------------- 1 | # Change Return Program - The user enters a cost and 2 | # then the amount of money given. The program will figure 3 | # out the change and the number of quarters, dimes, nickels, 4 | # pennies needed for the change. 5 | 6 | if __name__ == '__main__': 7 | cost = input("What's the cost in dollars? ") 8 | given = input("What's the amount of dollars given? ") 9 | 10 | change = given - cost 11 | 12 | print "\n" 13 | if change < 0: 14 | print "Please ask for $%.2f more from the customer." % (-change) # double negation 15 | else: 16 | print "The change is $%.2f." % change 17 | 18 | q = 0 # 0.25 19 | d = 0 # 0.10 20 | n = 0 # 0.05 21 | p = 0 # 0.01 22 | 23 | change = int(change * 100) # let's talk about cents 24 | 25 | if change >= 25: 26 | q = int(change / 25) 27 | change = change % 25 28 | if change >= 10: 29 | d = int(change / 10) 30 | change = change % 10 31 | if change >= 5: 32 | n = int(change / 5) 33 | change = change % 5 34 | if change >= 1: 35 | p = change # rest all change is in pennies 36 | 37 | print "Give the following change to the customer:" 38 | print "Quarters: %d\tDimes: %d\tNickels: %d\tPennies: %d" \ 39 | % (q, d, n, p) 40 | -------------------------------------------------------------------------------- /Numbers/credit_card_validator.py: -------------------------------------------------------------------------------- 1 | """ 2 | Credit Card Validator - Takes in a credit card number from a 3 | common credit card vendor (Visa, MasterCard, American Express, 4 | Discoverer) and validates it to make sure that it is a valid 5 | number (look into how credit cards use a checksum). 6 | 7 | This program works with *most* credit card numbers. 8 | 9 | Uses Luhn Algorithm (http://en.wikipedia.org/wiki/Luhn_algorithm). 10 | 11 | 1. From the rightmost digit, which is the check digit, moving 12 | left, double the value of every second digit; if product of this 13 | doubling operation is greater than 9 (e.g., 7 * 2 = 14), then 14 | sum the digits of the products (e.g., 10: 1 + 0 = 1, 14: 1 + 4 = 5). 15 | 16 | 2. Add together doubled digits with the undoubled digits from the 17 | original number. 18 | 19 | 3. If the total modulo 10 is equal to 0 (if the total ends in zero) 20 | then the number is valid according to the Luhn formula; else it is 21 | not valid. 22 | """ 23 | 24 | if __name__ == '__main__': 25 | number = raw_input('Enter the credit card number of check: ').replace(' ', '') 26 | #if not number.isdigit(): 27 | # raise Exception('Invalid credit card number. Make sure it\'s all digits (with optional spaces in between).' 28 | 29 | digits = [int(char) for char in number] 30 | 31 | # double alternate digits (step 1) 32 | doubled = [(digit * 2) if (i % 2 == 0) else digit \ 33 | for (i, digit) in enumerate(digits)] # i <3 python 34 | # sum digits of number > 10 (step 2) 35 | summed = [num if num < 10 else sum([int(dig) for dig in str(num)]) \ 36 | for num in doubled] # i <3 python ** 2 37 | # step 3 38 | if sum(summed) % 10 == 0: 39 | print 'The number is valid' 40 | else: 41 | print 'The number is invalid' 42 | -------------------------------------------------------------------------------- /Numbers/distance.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | """ 4 | Distance Between Two Cities - Calculates the distance between 5 | two cities and allows the user to specify a unit of distance. 6 | This program may require finding coordinates for the cities 7 | like latitude and longitude. 8 | 9 | Uses the Haversine formula 10 | (http://www.movable-type.co.uk/scripts/latlong.html) 11 | 12 | Dependencies: 13 | geopy 14 | pip install geopy 15 | """ 16 | 17 | from geopy import geocoders # to find lat/lon for the city 18 | import math 19 | 20 | R = 6373 # km 21 | 22 | city1 = raw_input('Enter city 1: ') 23 | city2 = raw_input('Enter city 2: ') 24 | unit = raw_input('Enter unit of distance (Enter "K" for KM or "M" for MI): ').lower() 25 | 26 | if unit in 'km': 27 | 28 | g = geocoders.GoogleV3() 29 | 30 | try: 31 | city1, (lat1, lon1) = g.geocode(city1) 32 | city2, (lat2, lon2) = g.geocode(city2) 33 | except: 34 | raise Exception('Unable to locate the citites. Check the city names.') 35 | 36 | # convert decimal locations to radians 37 | lat1 = math.radians(lat1) 38 | lon1 = math.radians(lon1) 39 | lat2 = math.radians(lat2) 40 | lon2 = math.radians(lon2) 41 | 42 | # start haversne formula 43 | dlon = lon2 - lon1 44 | dlat = lat2 - lat1 45 | a = (math.sin(dlat/2) ** 2) + math.cos(lat1) * math.cos(lat2) * \ 46 | (math.sin(dlon/2) ** 2) 47 | c = 2 * math.atan2(math.sqrt(a), math.sqrt(1 - a)) 48 | d = R * c 49 | 50 | if unit == 'k': 51 | print 'Distance between %s and %s is %.04f km' % (city1, city2, d) 52 | else: 53 | print 'Distance between %s and %s is %.04f mi' % (city1, city2, d / 1.60934) 54 | else: 55 | print 'Invalid unit input!' 56 | -------------------------------------------------------------------------------- /Numbers/factorial.py: -------------------------------------------------------------------------------- 1 | """ 2 | Factorial Finder - The Factorial of a positive integer, n, 3 | is defined as the product of the sequence n, n-1, n-2, ...1 4 | and the factorial of zero, 0, is defined as being 1. Solve 5 | this using both loops and recursion. 6 | """ 7 | 8 | def fact_loop(n): 9 | """ 10 | Returns the factorial of a given positive, non-zero integer 11 | using loops. 12 | """ 13 | fact = 1 14 | while n > 0: 15 | fact *= n 16 | n -= 1 17 | return fact 18 | 19 | def fact_recursion(n): 20 | """ 21 | Returns the factorial of a given positive, non-zero integer 22 | using recursion. 23 | """ 24 | return 1 if n == 0 else n * fact_recursion(n - 1) # if user as ternary operator 25 | 26 | if __name__ == '__main__': 27 | n = input('Enter a positive number: ') 28 | 29 | if n >= 0: 30 | print 'Factorial of %d by loops is %d' % (n, fact_loop(n)) 31 | print 'Factorial of %d by recursion is %d' % (n, fact_recursion(n)) 32 | else: 33 | print 'Not a valid number' 34 | -------------------------------------------------------------------------------- /Numbers/fibonacci.py: -------------------------------------------------------------------------------- 1 | # -*- coding: cp1252 -*- 2 | # Fibonacci Sequence - Enter a number and have the 3 | # program generate the Fibonacci sequence to that number 4 | # or to the Nth number 5 | 6 | n = int(raw_input('How many numbers do you need? ')) 7 | series = [1] 8 | 9 | while len(series) < n: 10 | if len(series) == 1: 11 | series.append(1) 12 | else: 13 | series.append(series[-1] + series[-2]) 14 | 15 | print series 16 | -------------------------------------------------------------------------------- /Numbers/happy_numbers.py: -------------------------------------------------------------------------------- 1 | """ 2 | Happy Numbers - A happy number is defined by the 3 | following process. Starting with any positive integer, 4 | replace the number by the sum of the squares of its 5 | digits, and repeat the process until the number equals 6 | 1 (where it will stay), or it loops endlessly in a 7 | cycle which does not include 1. Those numbers for which 8 | this process ends in 1 are happy numbers, while those 9 | that do not end in 1 are unhappy numbers. Take an input 10 | number from user, and find first 8 happy numbers from 11 | that input. 12 | """ 13 | 14 | NUMBERS_REQUIRED = 8 # number of happy numbers required 15 | 16 | def is_happy_number(num): 17 | seen = [] 18 | while True: 19 | sum_digits = sum(int(digit) ** 2 for digit in str(num)) 20 | if sum_digits == 1: 21 | return True 22 | elif sum_digits in seen: 23 | return False 24 | else: 25 | num = sum_digits 26 | seen.append(num) 27 | 28 | if __name__ == '__main__': 29 | 30 | happies = [] # list of happy numbers found 31 | 32 | num = input('Start at: ') 33 | 34 | while len(happies) != NUMBERS_REQUIRED: 35 | if is_happy_number(num): 36 | happies.append(num) 37 | num += 1 38 | 39 | print happies 40 | 41 | -------------------------------------------------------------------------------- /Numbers/next_prime.py: -------------------------------------------------------------------------------- 1 | # Next Prime Number - Have the program find prime 2 | # numbers until the user chooses to stop asking for 3 | # the next one. 4 | 5 | def next_prime(current): 6 | next_prime = current + 1 # start checking for primes 1 number after the current one 7 | i = 2 8 | while next_prime > i: # check with numbers up to next_prime - 1 9 | if next_prime % i == 0: # if number is divisible 10 | next_prime += 1 # ready to check the next number 11 | i = 2 # reset i to check divisibility again from 2 12 | else: 13 | i += 1 # increment the divisor 14 | return next_prime 15 | 16 | if __name__ == '__main__': 17 | current_prime = 2 18 | while True: 19 | response = raw_input('Do you want the next prime? (Y/N) ') 20 | 21 | if response.lower().startswith('y'): 22 | print current_prime 23 | current_prime = next_prime(current_prime) 24 | else: 25 | break 26 | -------------------------------------------------------------------------------- /Numbers/pi.py: -------------------------------------------------------------------------------- 1 | # Find PI to the Nth Digit 2 | 3 | from math import * 4 | 5 | digits = raw_input('Enter number of digits to round PI to: ') 6 | 7 | # print ('{0:.%df}' % min(20, int(digits))).format(math.pi) # nested string formatting 8 | 9 | # calculate pi using Machin-like Formula 10 | print ('{0:.%df}' % min(30, int(digits))).format(4 * (4 * atan(1.0/5.0) - atan(1.0/239.0))) 11 | -------------------------------------------------------------------------------- /Numbers/prime.py: -------------------------------------------------------------------------------- 1 | # Prime Factorization - Have the user enter a number 2 | # and find all Prime Factors (if there are any) and 3 | # display them. 4 | 5 | 6 | def is_a_prime(x): 7 | for i in range(2, x): 8 | if x % i == 0: 9 | return False 10 | return True 11 | 12 | # standard boilerplate 13 | if __name__ == '__main__': 14 | n = int(raw_input('Enter the number to find prime factors of: ')) 15 | 16 | factors = [] 17 | 18 | for i in range(2, n + 1): 19 | while n % i == 0: # Thanks @madsulrik 20 | if is_a_prime(i): 21 | factors.append(i) 22 | n /= i 23 | print factors 24 | -------------------------------------------------------------------------------- /Numbers/tax.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | TAXES = { 4 | 'WA': 9.5, 5 | 'CA': 7.5, 6 | 'FL': 10.8, 7 | 'OH': 7.8 8 | } 9 | 10 | state = raw_input('What\'s your state (WA / CA / FL / OH)?: ') 11 | cost = float(raw_input('And the cost?: ')) 12 | 13 | tax = TAXES[state] / 100 * cost 14 | 15 | print 'Cost: %.02f\nTax: %.02f\n----------\nTotal: %.02f' % (cost, tax, cost + tax) -------------------------------------------------------------------------------- /Numbers/tile.py: -------------------------------------------------------------------------------- 1 | # Find Cost of Tile to Cover W x H Floor - Calculate 2 | # the total cost of tile it would take to cover a floor 3 | # plan of width and height, using a cost entered by the user. 4 | 5 | # Use input as the input can be integer and float 6 | cost = input("What's the cost per sq. feet? ") 7 | width = input("What's the width of the floor? ") 8 | height = input("What's the height of the floor? ") 9 | 10 | print "The total cost is $%.2f for %.2f square feet" \ 11 | % (width * height * cost, width * height) 12 | -------------------------------------------------------------------------------- /Numbers/unit.py: -------------------------------------------------------------------------------- 1 | """ 2 | Unit Converter (temp, currency, volume, mass and more) - Converts 3 | various units between one another. The user enters the type of unit 4 | being entered, the type of unit they want to convert to and then 5 | the value. The program will then make the conversion. 6 | """ 7 | 8 | from __future__ import division 9 | from urllib2 import urlopen 10 | import json 11 | 12 | # 1 (std unit) = these many units 13 | MULTIPLIERS_TO_STD = { 14 | 'length': { 15 | 'cm': 0.01, 16 | 'm': 1, # std unit 17 | 'km': 1000, 18 | 'mi': 1609.34, 19 | 'ft': 0.3048 20 | }, 21 | 'temp': { 22 | 'C': 1, # std unit 23 | 'F': 33.8 24 | } 25 | } 26 | 27 | # These many units = 1 (std unit) 28 | MULTIPLIERS_FROM_STD = { 29 | 'length': { 30 | 'cm': 100, 31 | 'm': 1, # std unit 32 | 'km': 0.001, 33 | 'mi': 0.000621371, 34 | 'ft': 3.28084 35 | }, 36 | 'temp': { 37 | 'C': 1, # std unit 38 | 'F': -17.2222 39 | } 40 | } 41 | 42 | 43 | def get_user_input(choice): 44 | units = ', '.join(MULTIPLIERS_TO_STD[choice].keys()) 45 | source_unit = raw_input('\nEnter source unit (%s): ' % units) 46 | source_val = float(raw_input('How many %s\'s? ' % source_unit)) 47 | convert_to = raw_input('Convert to? (%s): ' % units) 48 | return source_unit, source_val, convert_to 49 | 50 | def get_currency(source_unit, source_val, convert_to): 51 | url = 'http://rate-exchange.appspot.com/currency?from=%s&to=%s&q=%s' % ( 52 | source_unit, convert_to, str(source_val)) 53 | content = urlopen(url).read() 54 | return json.loads(content)['v'] 55 | 56 | def main(): 57 | print """Unit Converter 58 | 1. Length 59 | 2. Temperature 60 | 3. Currency""" 61 | 62 | choice = int(raw_input('What do you want to convert: ')) 63 | 64 | if choice == 1: 65 | source_unit, source_val, convert_to = get_user_input('length') 66 | print '%f%s = %f%s' % (source_val, source_unit, 67 | source_val * \ 68 | MULTIPLIERS_TO_STD['length'][source_unit] * \ 69 | MULTIPLIERS_FROM_STD['length'][convert_to], \ 70 | convert_to) 71 | elif choice == 2: 72 | source_unit, source_val, convert_to = get_user_input('temp') 73 | if (source_unit, convert_to) == ('F', 'C'): # F -> C 74 | value = (source_val - 32) * (5/9) 75 | elif (source_unit, convert_to) == ('C', 'F'): # C -> F 76 | value = (source_val * (9/5)) + 32 77 | else: 78 | value = source_val 79 | print '%f%s = %f%s' % (source_val, source_unit, 80 | value, convert_to) 81 | 82 | elif choice == 3: 83 | source_unit = raw_input('\nEnter source currency (eg USD, INR etc): ') 84 | source_val = float(raw_input('How many %s\'s? ' % source_unit)) 85 | convert_to = raw_input('Convert to? (eg USD, INR etc): ') 86 | print '%f%s = %f%s' % (source_val, source_unit, 87 | get_currency(source_unit, source_val, convert_to), 88 | convert_to) 89 | 90 | if __name__ == '__main__': 91 | main() 92 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Mega Project List 2 | ======== 3 | 4 | A list of practical projects that anyone can solve in any programming language (See [solutions](https://github.com/thekarangoel/Projects-Solutions)). These projects are divided in multiple categories, and each category has it's own folder. 5 | 6 | #### [RECOGNITION](https://github.com/thekarangoel/Projects/tree/master/RECOGNITION) 7 | 8 | Ever since this repo was created, it has been in the top list on GH. Be it the daily or weekly list! This repo is in the top 5 on GitHub on [July 14 2013](https://raw.github.com/thekarangoel/Projects/master/RECOGNITION/top5-2013-07-14.png). (And again on [July 22, 2013](https://raw.github.com/thekarangoel/Projects/master/RECOGNITION/top5-2013-07-22%2013_10_30.png), and again on [July 23, 2013](https://raw.github.com/thekarangoel/Projects/master/RECOGNITION/top5-2013-07-23.png).) And on [weekly](https://raw.github.com/thekarangoel/Projects/master/RECOGNITION/top5-weekly-2013-07-22.png) [list](https://github.com/thekarangoel/Projects/blob/master/RECOGNITION/top5-weekly-2013-07-23.png) during the week of July 2013. In the last week of July, *Projects* was in the monthly top list on GH. 9 | 10 | ![July 25, 2013](https://raw.github.com/thekarangoel/Projects/master/RECOGNITION/top5-monthly-2013-07-25.png) 11 | 12 | =============================== 13 | 14 | ### [CONTRIBUTING](https://github.com/thekarangoel/Projects/blob/master/CONTRIBUTING.md) 15 | 16 | See ways of [contributing](https://github.com/thekarangoel/Projects/blob/master/CONTRIBUTING.md) to this repo. You can contribute solutions (will be published in this [repo](https://github.com/thekarangoel/Projects-Solutions)) to existing problems, add new projects or remove existing ones. Make sure you follow all instructions properly. 17 | 18 | ================================ 19 | 20 | ### [Solutions](https://github.com/thekarangoel/Projects-Solutions) 21 | 22 | You can find implementations of these projects in many other languages by other users in this [repo](https://github.com/thekarangoel/Projects-Solutions). 23 | 24 | ================================ 25 | 26 | ### Donations 27 | 28 | If *Projects* has helped you in any way, and you'd like to help the developer, please consider donating. 29 | 30 | **- BTC: [19dLDL4ax7xRmMiGDAbkizh6WA6Yei2zP5](http://i.imgur.com/bAQgKLN.png)** 31 | 32 | **- Gittip: [https://www.gittip.com/karan/](https://www.gittip.com/karan/)** 33 | 34 | **- Flattr: [https://flattr.com/profile/thekarangoel](https://flattr.com/profile/thekarangoel)** 35 | 36 | ================================ 37 | 38 | Some details about this repo: 39 | 40 | * I will use Python to solve these. Why? Because I want to learn the language quickly. 41 | * I have no interest in making games, so I'm excluding those from the list below. 42 | * I'm not interested in networking, so I *might* skip all (or some) of them. 43 | * The projects will not be made in the order posted. 44 | * I may not be able to complete all of them. 45 | * My method of solving them may not be the best. If you do not like my algorithm(s), please add a comment for the file/commit or open an issue, and I'll try to improve. 46 | 47 | I will link to each project that I complete. Some will be in this same repo, some bigger ones will have dedicated repos. 48 | 49 | To get started, fork this repo, delete this README and rename [*README-scratch.md*](https://github.com/thekarangoel/Projects/blob/master/README-scratch.md) to *README.md*. 50 | 51 | =============================== 52 | 53 | Numbers 54 | --------- 55 | 56 | [**Find PI to the Nth Digit**](https://github.com/thekarangoel/Projects/blob/master/Numbers/pi.py) - Enter a number and have the program generate PI up to that many decimal places. Keep a limit to how far the program will go. 57 | 58 | [**Fibonacci Sequence**](https://github.com/thekarangoel/Projects/blob/master/Numbers/fibonacci.py) - Enter a number and have the program generate the Fibonacci sequence to that number or to the Nth number. 59 | 60 | [**Prime Factorization**](https://github.com/thekarangoel/Projects/blob/master/Numbers/prime.py) - Have the user enter a number and find all Prime Factors (if there are any) and display them. 61 | 62 | [**Next Prime Number**](https://github.com/thekarangoel/Projects/blob/master/Numbers/next_prime.py) - Have the program find prime numbers until the user chooses to stop asking for the next one. 63 | 64 | [**Find Cost of Tile to Cover W x H Floor**](https://github.com/thekarangoel/Projects/blob/master/Numbers/tile.py) - Calculate the total cost of tile it would take to cover a floor plan of width and height, using a cost entered by the user. 65 | 66 | **Mortgage Calculator** - Calculate the monthly payments of a fixed term mortgage over given Nth terms at a given interest rate. Also figure out how long it will take the user to pay back the loan. 67 | 68 | [**Change Return Program**](https://github.com/thekarangoel/Projects/blob/master/Numbers/change.py) - The user enters a cost and then the amount of money given. The program will figure out the change and the number of quarters, dimes, nickels, pennies needed for the change. 69 | 70 | [**Binary to Decimal and Back Converter**](https://github.com/thekarangoel/Projects/blob/master/Numbers/binary_decimal.py) - Develop a converter to convert a decimal number to binary or a binary number to its decimal equivalent. 71 | 72 | [**Calculator**](https://github.com/thekarangoel/Projects/blob/master/Numbers/calc.py) - A simple calculator to do basic operators. Make it a scientific calculator for added complexity. 73 | 74 | [**Unit Converter (temp, currency, volume, mass and more)**](https://github.com/thekarangoel/Projects/blob/master/Numbers/unit.py) - Converts various units between one another. The user enters the type of unit being entered, the type of unit they want to convert to and then the value. The program will then make the conversion. 75 | 76 | [**Alarm Clock**](https://github.com/thekarangoel/Projects/blob/master/Numbers/alarm.py) - A simple clock where it plays a sound after X number of minutes/seconds or at a particular time. 77 | 78 | [**Distance Between Two Cities**](https://github.com/thekarangoel/Projects/blob/master/Numbers/distance.py) - Calculates the distance between two cities and allows the user to specify a unit of distance. This program may require finding coordinates for the cities like latitude and longitude. 79 | 80 | [**Credit Card Validator**](https://github.com/thekarangoel/Projects/blob/master/Numbers/credit_card_validator.py) - Takes in a credit card number from a common credit card vendor (Visa, MasterCard, American Express, Discoverer) and validates it to make sure that it is a valid number (look into how credit cards use a checksum). 81 | 82 | [**Tax Calculator**](https://github.com/karan/Projects/blob/master/Numbers/tax.py) - Asks the user to enter a cost and either a country or state tax. It then returns the tax plus the total cost with tax. 83 | 84 | [**Factorial Finder**](https://github.com/thekarangoel/Projects/blob/master/Numbers/factorial.py) - The Factorial of a positive integer, n, is defined as the product of the sequence n, n-1, n-2, ...1 and the factorial of zero, 0, is defined as being 1. Solve this using both loops and recursion. 85 | 86 | **Complex Number Algebra** - Show addition, multiplication, negation, and inversion of complex numbers in separate functions. (Subtraction and division operations can be made with pairs of these operations.) Print the results for each operation tested. 87 | 88 | [**Happy Numbers**](https://github.com/thekarangoel/Projects/blob/master/Numbers/happy_numbers.py) - A happy number is defined by the following process. Starting with any positive integer, replace the number by the sum of the squares of its digits, and repeat the process until the number equals 1 (where it will stay), or it loops endlessly in a cycle which does not include 1. Those numbers for which this process ends in 1 are happy numbers, while those that do not end in 1 are unhappy numbers. Take an input number from user, and find first 8 happy numbers from that input. 89 | 90 | **Number Names** - Show how to spell out a number in English. You can use a preexisting implementation or roll your own, but you should support inputs up to at least one million (or the maximum value of your language's default bounded integer type, if that's less). *Optional: Support for inputs other than positive integers (like zero, negative integers, and floating-point numbers).* 91 | 92 | **Coin Flip Simulation** - Write some code that simulates flipping a single coin however many times the user decides. The code should record the outcomes and count the number of tails and heads. 93 | 94 | Classic Algorithms 95 | ----------------- 96 | 97 | [**Collatz Conjecture**](https://github.com/thekarangoel/Projects/blob/master/Classic%20Algorithms/collatz.py) - Start with a number *n > 1*. Find the number of steps it takes to reach one using the following process: If *n* is even, divide it by 2. If *n* is odd, multiply it by 3 and add 1. 98 | 99 | **Sorting** - Implement two types of sorting algorithms: Merge sort and bubble sort. 100 | 101 | **Closest pair problem** - The closest pair of points problem or closest pair problem is a problem of computational geometry: given *n* points in metric space, find a pair of points with the smallest distance between them. 102 | 103 | **Sieve of Eratosthenes** - The sieve of Eratosthenes is one of the most efficient ways to find all of the smaller primes (below 10 million or so). 104 | 105 | Graphs 106 | --------- 107 | 108 | **Graph from links** - Create a program that will create a graph or network from a series of links. 109 | 110 | **Eulerian Path** - Create a program which will take as an input a graph and output either a Eulerian path or a Eulerian cycle, or state that it is not possible. A Eulerian Path starts at one node and traverses every edge of a graph through every node and finishes at another node. A Eulerian cycle is a eulerian Path that starts and finishes at the same node. 111 | 112 | **Connected Graph** - Create a program which takes a graph as an input and outputs whether every node is connected or not. 113 | 114 | **Dijkstra’s Algorithm** - Create a program that finds the shortest path through a graph using its edges. 115 | 116 | Data Structures 117 | --------- 118 | 119 | **Inverted index** - An [Inverted Index](http://en.wikipedia.org/wiki/Inverted_index) is a data structure used to create full text search. Given a set of text files, implement a program to create an inverted index. Also create a user interface to do a search using that inverted index which returns a list of files that contain the query term / terms. The search index can be in memory. 120 | 121 | Text 122 | --------- 123 | 124 | [**Reverse a String**](https://github.com/thekarangoel/Projects/blob/master/Text/reverse.py) - Enter a string and the program will reverse it and print it out. 125 | 126 | [**Pig Latin**](https://github.com/thekarangoel/Projects/blob/master/Text/piglatin.py) - Pig Latin is a game of alterations played on the English language game. To create the Pig Latin form of an English word the initial consonant sound is transposed to the end of the word and an ay is affixed (Ex.: "banana" would yield anana-bay). Read Wikipedia for more information on rules. 127 | 128 | [**Count Vowels**](https://github.com/thekarangoel/Projects/blob/master/Text/count_vowels.py) - Enter a string and the program counts the number of vowels in the text. For added complexity have it report a sum of each vowel found. 129 | 130 | [**Check if Palindrome**](https://github.com/thekarangoel/Projects/blob/master/Text/palindrome.py) - Checks if the string entered by the user is a palindrome. That is that it reads the same forwards as backwards like “racecar” 131 | 132 | [**Count Words in a String**](https://github.com/thekarangoel/Projects/blob/master/Text/count_words.py) - Counts the number of individual words in a string and display the top 5/10 most used words. 133 | 134 | **Text Editor** - Notepad style application that can open, edit, and save text documents. *Optional: Add syntax highlighting and other features.* 135 | 136 | [**RSS Feed Creator**](https://github.com/thekarangoel/Projects/blob/master/Text/rss.py) - Given a link to RSS/Atom Feed, get all posts and display them. 137 | 138 | **Post it Notes Program** - A program where you can add text reminders and post them. *Optional: You can have the program also add popup reminders.* 139 | 140 | **Quote Tracker (market symbols etc)** - A program which can go out and check the current value of stocks for a list of symbols entered by the user. The user can set how often the stocks are checked. For CLI, show whether the stock has moved up or down. *Optional: If GUI, the program can show green up and red down arrows to show which direction the stock value has moved.* 141 | 142 | **Guestbook / Journal** - A simple application that allows people to add comments or write journal entries. It can allow comments or not and timestamps for all entries. Could also be made into a shout box. *Optional: Deploy it on Google App Engine or Heroku or any other PaaS (if possible, of course).* 143 | 144 | **Fortune Teller (Horoscope)** - A program that checks your horoscope on various astrology sites and puts them together for you each day. 145 | 146 | **Vigenere / Vernam / Ceasar Ciphers** - Functions for encrypting and decrypting data messages. Then send them to a friend. 147 | 148 | **Random Gift Suggestions** - Enter various gifts for certain people when you think of them. When its time to give them a gift (xmas, birthday, anniversary) it will randomly pick one. *Optional: Suggest places you can get it (link to Amazon page?).* 149 | 150 | **Markdown to HTML Converter** - Converts Markdown formatted text into HTML files. Implement basic tags like `p`, `strong`, `em` etc. *Optional: Implement all tags from [Markdown Syntax Docs](http://daringfireball.net/projects/markdown/syntax).* 151 | 152 | **Regex Query Tool** - A tool that allows the user to enter a text string and then in a separate control enter a regex pattern. It will run the regular expression against the source text and return any matches or flag errors in the regular expression. 153 | 154 | Networking 155 | --------- 156 | 157 | **FTP Program** - A file transfer program which can transfer files back and forth from a remote web sever. 158 | 159 | **Bandwidth Monitor** - A small utility program that tracks how much data you have uploaded and downloaded from the net during the course of your current online session. See if you can find out what periods of the day you use more and less and generate a report or graph that shows it. 160 | 161 | **Port Scanner** - Enter an IP address and a port range where the program will then attempt to find open ports on the given computer by connecting to each of them. On any successful connections mark the port as open. 162 | 163 | **Mail Checker (POP3 / IMAP)** - The user enters various account information include web server and IP, protocol type (POP3 or IMAP) and the application will check for email at a given interval. 164 | 165 | **Country from IP Lookup** - Enter an IP address and find the country that IP is registered in. *Optional: Find the Ip automatically.* 166 | 167 | **Whois Search Tool** - Enter an IP or host address and have it look it up through whois and return the results to you. 168 | 169 | **Site Checker with Time Scheduling** - An application that attempts to connect to a website or server every so many minutes or a given time and check if it is up. If it is down, it will notify you by email or by posting a notice on screen. 170 | 171 | Classes 172 | --------- 173 | 174 | [**Product Inventory Project**](https://github.com/thekarangoel/Projects/blob/master/Classes/product_inventory.py) - Create an application which manages an inventory of products. Create a product class which has a price, id, and quantity on hand. Then create an *inventory* class which keeps track of various products and can sum up the inventory value. 175 | 176 | **Airline / Hotel Reservation System** - Create a reservation system which books airline seats or hotel rooms. It charges various rates for particular sections of the plane or hotel. Example, first class is going to cost more than coach. Hotel rooms have penthouse suites which cost more. Keep track of when rooms will be available and can be scheduled. 177 | 178 | **Bank Account Manager** - Create a class called Account which will be an abstract class for three other classes called CheckingAccount, SavingsAccount and BusinessAccount. Manage credits and debits from these accounts through an ATM style program. 179 | 180 | **Patient / Doctor Scheduler** - Create a patient class and a doctor class. Have a doctor that can handle multiple patients and setup a scheduling program where a doctor can only handle 16 patients during an 8 hr work day. 181 | 182 | **Recipe Creator and Manager** - Create a recipe class with ingredients and a put them in a recipe manager program that organizes them into categories like deserts, main courses or by ingredients like chicken, beef, soups, pies etc. 183 | 184 | **Image Gallery** - Create an image abstract class and then a class that inherits from it for each image type. Put them in a program which displays them in a gallery style format for viewing. 185 | 186 | **Shape Area and Perimeter Classes** - Create an abstract class called Shape and then inherit from it other shapes like diamond, rectangle, circle, triangle etc. Then have each class override the area and perimeter functionality to handle each shape type. 187 | 188 | **Flower Shop Ordering To Go** - Create a flower shop application which deals in flower objects and use those flower objects in a bouquet object which can then be sold. Keep track of the number of objects and when you may need to order more. 189 | 190 | **Family Tree Creator** - Create a class called Person which will have a name, when they were born and when (and if) they died. Allow the user to create these Person classes and put them into a family tree structure. Print out the tree to the screen. 191 | 192 | Threading 193 | --------- 194 | 195 | **Create A Progress Bar for Downloads** - Create a progress bar for applications that can keep track of a download in progress. The progress bar will be on a separate thread and will communicate with the main thread using delegates. 196 | 197 | **Bulk Thumbnail Creator** - Picture processing can take a bit of time for some transformations. Especially if the image is large. Create an image program which can take hundreds of images and converts them to a specified size in the background thread while you do other things. For added complexity, have one thread handling re-sizing, have another bulk renaming of thumbnails etc. 198 | 199 | Web 200 | --------- 201 | 202 | [**Page Scraper**](https://github.com/thekarangoel/Projects/blob/master/Web/page_scraper.py) - Create an application which connects to a site and pulls out all links, or images, and saves them to a list. *Optional: Organize the indexed content and don’t allow duplicates. Have it put the results into an easily searchable index file.* 203 | 204 | **Web Browser with Tabs** - Create a small web browser that allows you to navigate the web and contains tabs which can be used to navigate to multiple web pages at once. For simplicity don’t worry about executing Javascript or other client side code. 205 | 206 | **Online White Board** - Create an application which allows you to draw pictures, write notes and use various colors to flesh out ideas for projects. *Optional: Add feature to invite friends to collaborate on a white board online.* 207 | 208 | [**Get Atomic Time from Internet Clock**](https://github.com/thekarangoel/Projects/blob/master/Web/time.py) - This program will get the true atomic time from an atomic time clock on the Internet. Use any one of the atomic clocks returned by a simple Google search. 209 | 210 | [**Fetch Current Weather**](https://github.com/thekarangoel/GAE-weather) - Get the current weather for a given zip/postal code. *Optional: Try locating the user automatically.* 211 | 212 | **Scheduled Auto Login and Action** - Make an application which logs into a given site on a schedule and invokes a certain action and then logs out. This can be useful for checking web mail, posting regular content, or getting info for other applications and saving it to your computer. 213 | 214 | **E-Card Generator** - Make a site that allows people to generate their own little e-cards and send them to other people. Do not use Flash. Use a picture library and perhaps insightful mottos or quotes. 215 | 216 | **Content Management System** - Create a content management system (CMS) like Joomla, Drupal, PHP Nuke etc. Start small. *Optional: Allow for the addition of modules/addons.* 217 | 218 | **Web Board (Forum)** - Create a forum for you and your buddies to post, administer and share thoughts and ideas. 219 | 220 | **CAPTCHA Maker** - Ever see those images with letters a numbers when you signup for a service and then asks you to enter what you see? It keeps web bots from automatically signing up and spamming. Try creating one yourself for online forms. 221 | 222 | Files 223 | --------- 224 | 225 | **Quiz Maker** - Make an application which takes various questions form a file, picked randomly, and puts together a quiz for students. Each quiz can be different and then reads a key to grade the quizzes. 226 | 227 | **File Explorer** - Create your own simple windows explorer program. Add feature(s) you always thought are missing from MS Windows Explorer or Mac Finder. 228 | 229 | **Sort Excel/CSV File Utility** - Reads a file of records, sorts them, and then writes them back to the file. Allow the user to choose various sort style and sorting based on a particular field. 230 | 231 | **Create Zip File Maker** - The user enters various files from different directories and the program zips them up into a zip file. *Optional: Apply actual compression to the files. Start with Huffman Algorithm.* 232 | 233 | **PDF Generator** - An application which can read in a text file, html file or some other file and generates a PDF file out of it. Great for a web based service where the user uploads the file and the program returns a PDF of the file. *Optional: Deploy on GAE or Heroku if possible.* 234 | 235 | **Mp3 Tagger** - Modify and add ID3v1 tags to MP3 files. See if you can also add in the album art into the MP3 file’s header as well as other ID3v2 tags. 236 | 237 | **Code Snippet Manager** - Another utility program that allows coders to put in functions, classes or other tidbits to save for use later. Organized by the type of snippet or language the coder can quickly look up code. *Optional: For extra practice try adding syntax highlighting based on the language.* 238 | 239 | Databases 240 | --------- 241 | 242 | **SQL Query Analyzer** - A utility application which a user can enter a query and have it run against a local database and look for ways to make it more efficient. 243 | 244 | **Remote SQL Tool** - A utility that can execute queries on remote servers from your local computer across the Internet. It should take in a remote host, user name and password, run the query and return the results. 245 | 246 | **Report Generator** - Create a utility that generates a report based on some tables in a database. Generates a sales reports based on the order/order details tables or sums up the days current database activity. 247 | 248 | **Event Scheduler and Calendar** - Make an application which allows the user to enter a date and time of an event, event notes and then schedule those events on a calendar. The user can then browse the calendar or search the calendar for specific events. *Optional: Allow the application to create re-occurrence events that reoccur every day, week, month, year etc.* 249 | 250 | **Budget Tracker** - Write an application that keeps track of a household’s budget. The user can add expenses, income, and recurring costs to find out how much they are saving or losing over a period of time. *Optional: Allow the user to specify a date range and see the net flow of money in and out of the house budget for that time period.* 251 | 252 | **Address Book** - Keep track of various contacts, their numbers, emails and little notes about them like a Rolodex in the database. 253 | 254 | **TV Show Tracker** - Got a favorite show you don’t want to miss? Don’t have a PVR or want to be able to find the show to then PVR it later? Make an application which can search various online TV Guide sites, locate the shows/times/channels and add them to a database application. The database/website then can send you email reminders that a show is about to start and which channel it will be on. 255 | 256 | **Travel Planner System** - Make a system that allows users to put together their own little travel itinerary and keep track of the airline / hotel arrangements, points of interest, budget and schedule. 257 | 258 | Graphics and Multimedia 259 | --------- 260 | 261 | **Slide Show** - Make an application that shows various pictures in a slide show format. *Optional: Try adding various effects like fade in/out, star wipe and window blinds transitions.* 262 | 263 | **Stream Video from Online** - Try to create your own online streaming video player. 264 | 265 | **Mp3 Player** - A simple program for playing your favorite music files. Add features you though are missing from your favorite music player. 266 | 267 | **Watermarking Application** - Have some pictures you want copyright protected? Add your own logo or text lightly across the background so that no one can simply steal your graphics off your site. Make a program that will add this watermark to the picture. *Optional: Use threading to process multiple images simultaneously.* 268 | 269 | **Turtle Graphics** - This is a common project where you create a floor of 20 x 20 squares. Using various commands you tell a turtle to draw a line on the floor. You have move forward, left or right, lift or drop pen etc. Do a search online for "Turtle Graphics" for more information. *Optional: Allow the program to read in the list of commands from a file.* 270 | 271 | Security 272 | ------------- 273 | 274 | **Caesar cipher** - Implement a Caesar cipher, both encoding and decoding. The key is an integer from 1 to 26. This cipher rotates the letters of the alphabet (A to Z). The encoding replaces each letter with the 1st to 26th next letter in the alphabet (wrapping Z to A). So key 2 encrypts "HI" to "JK", but key 20 encrypts "HI" to "BC". This simple "monoalphabetic substitution cipher" provides almost no security, because an attacker who has the encoded message can either use frequency analysis to guess the key, or just try all 26 keys. 275 | 276 | =============================================== 277 | 278 | Sources 279 | ======= 280 | 281 | * [Martyr2’s Mega Project List](http://www.dreamincode.net/forums/topic/78802-martyr2s-mega-project-ideas-list/) 282 | * [Rosetta Code](http://rosettacode.org/) 283 | * Lots and lots of contributors. Thank you all. 284 | 285 | -------------------------------------------------------------------------------- /Security/README.md: -------------------------------------------------------------------------------- 1 | Security 2 | ------------- 3 | 4 | **Caesar cipher** - Implement a Caesar cipher, both encoding and decoding. The key is an integer from 1 to 26. This cipher rotates the letters of the alphabet (A to Z). The encoding replaces each letter with the 1st to 26th next letter in the alphabet (wrapping Z to A). So key 2 encrypts "HI" to "JK", but key 20 encrypts "HI" to "BC". This simple "monoalphabetic substitution cipher" provides almost no security, because an attacker who has the encoded message can either use frequency analysis to guess the key, or just try all 26 keys. 5 | -------------------------------------------------------------------------------- /Text/README.md: -------------------------------------------------------------------------------- 1 | Text 2 | --------- 3 | 4 | **Reverse a String** - Enter a string and the program will reverse it and print it out. 5 | 6 | **Pig Latin** - Pig Latin is a game of alterations played on the English language game. To create the Pig Latin form of an English word the initial consonant sound is transposed to the end of the word and an ay is affixed (Ex.: "banana" would yield anana-bay). Read Wikipedia for more information on rules. 7 | 8 | **Count Vowels** - Enter a string and the program counts the number of vowels in the text. For added complexity have it report a sum of each vowel found. 9 | 10 | **Check if Palindrome** - Checks if the string entered by the user is a palindrome. That is that it reads the same forwards as backwards like “racecar” 11 | 12 | **Count Words in a String** - Counts the number of individual words in a string. For added complexity read these strings in from a text file and generate a summary. 13 | 14 | **Text Editor** - Notepad style application that can open, edit, and save text documents. *Optional: Add syntax highlighting and other features.* 15 | 16 | **RSS Feed Creator** - Given a link to RSS/Atom Feed, get all posts and display them. 17 | 18 | **Post it Notes Program** - A program where you can add text reminders and post them. *Optional: You can have the program also add popup reminders.* 19 | 20 | **Quote Tracker (market symbols etc)** - A program which can go out and check the current value of stocks for a list of symbols entered by the user. The user can set how often the stocks are checked. For CLI, show whether the stock has moved up or down. *Optional: If GUI, the program can show green up and red down arrows to show which direction the stock value has moved.* 21 | 22 | **Guestbook / Journal** - A simple application that allows people to add comments or write journal entries. It can allow comments or not and timestamps for all entries. Could also be made into a shout box. *Optional: Deploy it on Google App Engine or Heroku or any other PaaS (if possible, of course).* 23 | 24 | **Fortune Teller (Horoscope)** - A program that checks your horoscope on various astrology sites and puts them together for you each day. 25 | 26 | **Vigenere / Vernam / Ceasar Ciphers** - Functions for encrypting and decrypting data messages. Then send them to a friend. 27 | 28 | **Random Gift Suggestions** - Enter various gifts for certain people when you think of them. When its time to give them a gift (xmas, birthday, anniversary) it will randomly pick one. *Optional: Suggest places you can get it (link to Amazon page?).* 29 | 30 | **Markdown to HTML Converter** - Converts Markdown formatted text into HTML files. Implement basic tags like `p`, `strong`, `em` etc. *Optional: Implement all tags from [Markdown Syntax Docs](http://daringfireball.net/projects/markdown/syntax).* 31 | 32 | **Regex Query Tool** - A tool that allows the user to enter a text string and then in a separate control enter a regex pattern. It will run the regular expression against the source text and return any matches or flag errors in the regular expression. -------------------------------------------------------------------------------- /Text/caesar_cipher.py: -------------------------------------------------------------------------------- 1 | """ 2 | Caesar Cipher - Enter the cipher number and the program will "encrypt" them with 3 | the Caesar cipher (a.k.a. ROT #). Type the word "exit" when you're finished. 4 | """ 5 | 6 | while True: 7 | try: 8 | cipher = int(raw_input("Enter the cipher number: ")) 9 | break 10 | except ValueError: 11 | print "I need a valid integer, please." 12 | 13 | print "Enter the text to be encoded." 14 | print "Enter \"exit\" to leave." 15 | 16 | if __name__ == '__main__': 17 | while True: 18 | text = raw_input("> ") 19 | encoded = [] 20 | 21 | if text.lower() == "exit": 22 | break 23 | 24 | for letter in text: 25 | if letter.isalpha(): 26 | is_upper = False 27 | 28 | if letter == letter.upper(): 29 | is_upper = True 30 | letter = letter.lower() 31 | 32 | value = (ord(letter) - 97 + cipher) % 26 33 | if is_upper: 34 | value -= 32 35 | 36 | encoded.append(chr(value + 97)) 37 | else: 38 | encoded.append(letter) 39 | 40 | print ''.join(encoded) 41 | -------------------------------------------------------------------------------- /Text/count_vowels.py: -------------------------------------------------------------------------------- 1 | """ 2 | Count Vowels - Enter a string and the program counts 3 | the number of vowels in the text. For added complexity 4 | have it report a sum of each vowel found. 5 | """ 6 | 7 | from collections import defaultdict 8 | 9 | if __name__ == '__main__': 10 | string = raw_input('Enter a string: ').lower() 11 | 12 | vowels = ['a', 'e', 'i', 'o', 'u'] 13 | counts = defaultdict(int) 14 | 15 | for char in string: 16 | if char in vowels: 17 | counts[char] += 1 18 | 19 | print counts.items() 20 | -------------------------------------------------------------------------------- /Text/count_words.py: -------------------------------------------------------------------------------- 1 | """ 2 | Count Words in a String - Counts the number of individual 3 | words in a string and display the top 5/10 most used words. 4 | """ 5 | 6 | from collections import defaultdict 7 | import operator 8 | 9 | if __name__ == '__main__': 10 | text = raw_input('Enter some text: \n') 11 | words = text.split() # very naive approach, split at space 12 | 13 | counts = defaultdict(int) # no need to check existence of a key 14 | 15 | # find count of each word 16 | for word in words: 17 | counts[word] += 1 18 | 19 | # sort the dict by the count of each word, returns a tuple (word, count) 20 | sorted_counts = sorted(counts.iteritems(), \ 21 | key=operator.itemgetter(1), \ 22 | reverse=True) 23 | 24 | # print top 5 words 25 | for (word,count) in sorted_counts[:5]: # thanks @jrwren for this! 26 | print (word, count) 27 | -------------------------------------------------------------------------------- /Text/palindrome.py: -------------------------------------------------------------------------------- 1 | """ 2 | Check if Palindrome - Checks if the string entered 3 | by the user is a palindrome. That is that it reads 4 | the same forwards as backwards like "racecar" 5 | """ 6 | 7 | string = raw_input('Enter a string: ').lower() 8 | 9 | if string == string[::-1]: 10 | print '%s is a palindrome' % string 11 | else: 12 | print '%s is not a palindrome' % string 13 | -------------------------------------------------------------------------------- /Text/piglatin.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pig Latin - Pig Latin is a game of alterations played 3 | on the English language game. To create the Pig Latin 4 | form of an English word the initial consonant sound is 5 | transposed to the end of the word and an ay is affixed 6 | (Ex.: "banana" would yield anana-bay). Read Wikipedia 7 | for more information on rules. 8 | """ 9 | 10 | word = raw_input('What\'s your word? ').lower() 11 | vowels = 'aeiou' 12 | 13 | pig = 'ay' 14 | 15 | consonant = [] 16 | count = 0 17 | copy = [c for c in word] 18 | 19 | for i in range(len(copy) - 1): 20 | count = i 21 | if copy[i] in vowels: 22 | break 23 | else: 24 | consonant.append(copy[i]) 25 | 26 | new = word[count:] + "".join(consonant) + pig 27 | 28 | """ 29 | first = word[0] 30 | 31 | if first in vowels: 32 | new = word + pig 33 | else: 34 | new = word[1:] + first + pig 35 | """ 36 | 37 | print new 38 | -------------------------------------------------------------------------------- /Text/reverse.py: -------------------------------------------------------------------------------- 1 | # -*- coding: cp1252 -*- 2 | """ 3 | Reverse a String - Enter a string and the program 4 | will reverse it and print it out. 5 | """ 6 | 7 | string = raw_input("Whatchu wanna say to me? ") 8 | copy = [c for c in string] 9 | for i in range(len(copy) / 2): 10 | copy[i], copy[len(copy) - i - 1] = copy[len(copy) - i - 1], copy[i] 11 | print "You say %s, I say %s" % (string, ''.join(copy)) 12 | -------------------------------------------------------------------------------- /Text/rss.py: -------------------------------------------------------------------------------- 1 | """ 2 | RSS Feed Creator - Given a link to RSS/Atom Feed, 3 | get all posts and display them. 4 | """ 5 | 6 | import re 7 | import urllib2 8 | 9 | 10 | def main(): 11 | """ 12 | Takes in a Feedburned feed URL. 13 | 14 | Eg: http://feeds.feedburner.com/WebDesignLedger 15 | """ 16 | feed_url = raw_input('Enter Feedburner RSS URL: ') 17 | content = urllib2.urlopen(feed_url).read() # get the source code of feed 18 | 19 | link_pattern = re.compile('(.*)') 20 | title_pattern = re.compile('(.*)') 21 | 22 | links = re.findall(link_pattern, content)[1:] # skip blog url 23 | titles = re.findall(title_pattern, content)[1:] # skip the page title 24 | 25 | for (link, title) in zip(links, titles): 26 | print '{0}\n{1}\n'.format(title, link) 27 | 28 | if __name__ == '__main__': 29 | main() 30 | -------------------------------------------------------------------------------- /Threading/README.md: -------------------------------------------------------------------------------- 1 | Threading 2 | --------- 3 | 4 | **Create A Progress Bar for Downloads** - Create a progress bar for applications that can keep track of a download in progress. The progress bar will be on a separate thread and will communicate with the main thread using delegates. 5 | 6 | **Bulk Thumbnail Creator** - Picture processing can take a bit of time for some transformations. Especially if the image is large. Create an image program which can take hundreds of images and converts them to a specified size in the background thread while you do other things. For added complexity, have one thread handling re-sizing, have another bulk renaming of thumbnails etc. -------------------------------------------------------------------------------- /Web/README.md: -------------------------------------------------------------------------------- 1 | Web 2 | --------- 3 | 4 | **Page Scraper** - Create an application which connects to a site and pulls out all links, or images, and saves them to a list. *Optional: Organize the indexed content and don’t allow duplicates. Have it put the results into an easily searchable index file.* 5 | 6 | **Web Browser with Tabs** - Create a small web browser that allows you to navigate the web and contains tabs which can be used to navigate to multiple web pages at once. For simplicity don’t worry about executing Javascript or other client side code. 7 | 8 | **Online White Board** - Create an application which allows you to draw pictures, write notes and use various colors to flesh out ideas for projects. *Optional: Add feature to invite friends to collaborate on a white board online.* 9 | 10 | **Get Atomic Time from Internet Clock** - This program will get the true atomic time from an atomic time clock on the Internet. Use any one of the atomic clocks returned by a simple Google search. 11 | 12 | **Fetch Current Weather** - Get the current weather for a given zip/postal code. *Optional: Try locating the user automatically.* 13 | 14 | **Scheduled Auto Login and Action** - Make an application which logs into a given site on a schedule and invokes a certain action and then logs out. This can be useful for checking web mail, posting regular content, or getting info for other applications and saving it to your computer. 15 | 16 | **E-Card Generator** - Make a site that allows people to generate their own little e-cards and send them to other people. Do not use Flash. Use a picture library and perhaps insightful mottos or quotes. 17 | 18 | **Content Management System** - Create a content management system (CMS) like Joomla, Drupal, PHP Nuke etc. Start small. *Optional: Allow for the addition of modules/addons.* 19 | 20 | **Web Board (Forum)** - Create a forum for you and your buddies to post, administer and share thoughts and ideas. 21 | 22 | **CAPTCHA Maker** - Ever see those images with letters a numbers when you signup for a service and then asks you to enter what you see? It keeps web bots from automatically signing up and spamming. Try creating one yourself for online forms. -------------------------------------------------------------------------------- /Web/page_scraper.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/karan/Projects-my/c17b0ef85e767cbf81e537cb43b5a544ff3b3bc4/Web/page_scraper.py -------------------------------------------------------------------------------- /Web/time.py: -------------------------------------------------------------------------------- 1 | """ 2 | Get Atomic Time from Internet Clock - This program will get 3 | the true atomic time from an atomic time clock on the Internet. 4 | Use any one of the atomic clocks returned by a simple Google search. 5 | """ 6 | 7 | import re 8 | from urllib2 import urlopen 9 | 10 | 11 | def main(): 12 | url = 'http://time.is/just' 13 | content = urlopen(url).read() 14 | pattern = re.compile('
(.*)(AM|PM)
') 15 | 16 | find_match = re.search(pattern, content) 17 | 18 | location_pat = re.compile('

(.*)

') 19 | location_match = re.search(location_pat, content) 20 | 21 | print 'The time in %s is %s %s' % \ 22 | (location_match.group(1), find_match.group(1), find_match.group(2)) 23 | 24 | if __name__ == '__main__': 25 | main() 26 | --------------------------------------------------------------------------------