In iPython:
~ $ ipython
Python 2.7.10 (default, Oct 23 2015, 19:19:21)
Type "copyright", "credits" or "license" for more information.
IPython 2.3.0 -- An enhanced Interactive Python.
| package main | |
| import "fmt" | |
| //From http://blog.codinghorror.com/why-cant-programmers-program/ | |
| func main() { | |
| for i := 1; i <= 100; i++ { | |
| if (i % 3 == 0) && (i % 5 == 0) { | |
| fmt.Println("FizzBuzz") | |
| } else if i % 3 == 0 { |
| //From http://blog.codinghorror.com/why-cant-programmers-program/ | |
| function FizzBuzz() { | |
| for (var i = 1; i <= 100; i++) { | |
| if ((i % 3 === 0) && (i % 5 === 0)) { | |
| console.log("FizzBuzz"); | |
| } else if (i % 3 === 0) { | |
| console.log("Fizz") | |
| } else if (i % 5 === 0) { | |
| console.log("Buzz") | |
| } else { |
| #From http://blog.codinghorror.com/why-cant-programmers-program/ | |
| def FizzBuzz(): | |
| for i in range(1,100): | |
| if ((i % 3 == 0) and (i % 5 == 0)): | |
| print "FizzBuzz" | |
| elif (i % 3 == 0): | |
| print "Fizz" | |
| elif (i % 5 == 0): | |
| print "Buzz" | |
| else: |
| #!/usr/bin/expect -f | |
| # usage: ./hubottest "hubot help" | |
| spawn bin/hubot.coffee | |
| sleep 3 | |
| expect "Hubot>" | |
| send "hubot [lrange $argv 0 10]\n" | |
| expect eo |
| import time | |
| import sys | |
| trips_to_store = 0 | |
| total_bottles_drank =0 | |
| bottles = 100 | |
| def final_stats(trips_to_store, total_bottles_drank): | |
| if trips_to_store == 0: | |
| print("\nNever went to the store for more beer.") |
| # put this in your .bash_profile | |
| if [ $ITERM_SESSION_ID ]; then | |
| export PROMPT_COMMAND='echo -ne "\033];${PWD##*/}\007"; ':"$PROMPT_COMMAND"; | |
| fi | |
| # Piece-by-Piece Explanation: | |
| # the if condition makes sure we only screw with $PROMPT_COMMAND if we're in an iTerm environment | |
| # iTerm happens to give each session a unique $ITERM_SESSION_ID we can use, $ITERM_PROFILE is an option too | |
| # the $PROMPT_COMMAND environment variable is executed every time a command is run | |
| # see: ss64.com/bash/syntax-prompt.html |
| def inception(target_depth, current_depth=0, going_deeper=True): | |
| if going_deeper == True: | |
| if current_depth < target_depth: | |
| current_depth += 1 | |
| if current_depth != target_depth: | |
| print("Dream Level: {0}, going deeper..".format(current_depth)) | |
| elif current_depth == target_depth: | |
| print("Dream Level: {0}, coming back up..".format(current_depth)) | |
| return inception(target_depth, current_depth, True) | |
| elif current_depth == target_depth: |
| import random | |
| def hodor(): | |
| hodor_text = "Hodor" | |
| rand_num_words = random.randrange(5, 9) | |
| for i in range(rand_num_words): | |
| if random.randrange(1, 4) == 3 and i != (rand_num_words - 1): | |
| hodor_text += " hodor," | |
| else: | |
| hodor_text += " hodor" |