Intial commit.
This commit is contained in:
commit
7f5fc6574a
3 changed files with 88 additions and 0 deletions
1
episode14/.gitignore
vendored
Normal file
1
episode14/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
.idea
|
73
episode14/coding101.py
Normal file
73
episode14/coding101.py
Normal file
|
@ -0,0 +1,73 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
# Coding 101
|
||||
#
|
||||
# Written by Erik C. Thauvin (erik@thauvin.net)
|
||||
# http://erik.thauvin.net/
|
||||
# http://github.com/ethauvin/coding101/episode14
|
||||
# April 26, 2014
|
||||
|
||||
import textwrap
|
||||
|
||||
# Print opening title
|
||||
print "================================ CODING 101 ================================"
|
||||
|
||||
# Open the file
|
||||
episodeFile = open("coding101.txt", "r")
|
||||
# Read the lines into a list
|
||||
linesFromFile = episodeFile.readlines()
|
||||
# Close the file
|
||||
episodeFile.close()
|
||||
|
||||
# Let's go. The program will execute until run = False
|
||||
run = True
|
||||
while run:
|
||||
# Print an empty line
|
||||
print
|
||||
# Print the episode list
|
||||
print "Choose an episode:"
|
||||
print
|
||||
|
||||
# Loop through the episodes list.
|
||||
count = 0
|
||||
for line in linesFromFile:
|
||||
# Increment the episode number.
|
||||
count += 1
|
||||
# Split the line using tab as the delimiter
|
||||
# The format is: Date<TAB>Episode Title<TAB>Description
|
||||
episode = line.split("\t")
|
||||
# Print the episode number & title.
|
||||
# The episode number is converted into a str, and right justified
|
||||
print "\t{0}. {1}".format(str(count).rjust(2), episode[1])
|
||||
|
||||
print
|
||||
|
||||
# Ask for the episode number
|
||||
choice = raw_input("Enter 0-" + str(count) + " (or ENTER to quit): ")
|
||||
|
||||
# Did you press enter?
|
||||
if not choice:
|
||||
# Stop the program execution. Bye-Bye!
|
||||
run = False
|
||||
|
||||
# Validate the selected episode number. It must be a number...
|
||||
elif choice.isdigit():
|
||||
# Convert the selection to an integer.
|
||||
selection = int(choice)
|
||||
|
||||
# It must also be between 1 and the total number of episodes
|
||||
# Could be written as: selection >= 1 and selection <= count
|
||||
if 1 <= selection <= count:
|
||||
print
|
||||
print
|
||||
print "============================================================================"
|
||||
# Get and split the line for the episode, the list is zero-based.
|
||||
episode = linesFromFile[selection - 1].split('\t')
|
||||
# Print the episode, title
|
||||
print "Episode #" + choice + ": \"" + episode[1] + '" aired on ' + episode[0]
|
||||
print
|
||||
# Print the description, using textwrap to make it look pretty.
|
||||
print textwrap.fill(episode[2], width=76)
|
||||
print "============================================================================"
|
||||
print
|
||||
raw_input("Press ENTER to continue...")
|
14
episode14/coding101.txt
Normal file
14
episode14/coding101.txt
Normal file
|
@ -0,0 +1,14 @@
|
|||
January 23, 2014 Coding 01100101 In the first episode of Coding 101, we learn how to convert binary into decimal, then break it down into machine code.
|
||||
January 30, 2014 while (c101 > awesome) Today we learn all about variables, while loops, and converting integers to binary.
|
||||
February 6, 2014 Do While Conditioner This week we are taking a look at Xamarin Studio on Mac OSX, While Loops, For Loops, and Relational Operators.
|
||||
February 13, 2014 If Coding, Then Watch This This week we are reviewing For Loops, and checking out If (then) Else Statements.
|
||||
February 20, 2014 Somewhat Function(al) This week we are reviewing If (then) Else Statements and Functions.
|
||||
February 27, 2014 Coding101(Padre, Snubs) This week we are talking about Object Oriented Programming.
|
||||
March 06, 2014 Runtime, Funtime This week we are reviewing function returns, checking out your viewer submissions, and we're getting graphical!
|
||||
March 13, 2014 Farewell to C# This week we are reviewing objects, checking out your viewer submissions, and getting into classes and methods!
|
||||
March 20, 2014 ISS-Above with Python This week we chat with the inventor of ISS-Above: a device that lights up whenever the International Space Station is nearby.
|
||||
March 27, 2014 Randal Schwartz's "Perls of Wisdom" This week we chat with Randal Schwartz, host of "FLOSS Weekly" and co-author of books such as "Programming Perl" and "Learning Perl".
|
||||
April 3, 2014 Python: Getting Started This week we are introducing our newest module, Python with Code Warrior Dale Chase!
|
||||
April 10, 2014 Lists[Python] This week we check out your viewer submissions and we continue in Python with Lists.
|
||||
April 17, 2014 Sanitize')DROP TABLE Python; Your Python list example, we'll explain the Heartbleed bug with jelly beans, and a While Loop.
|
||||
April 24, 2014 Thrown a For Loop We learn about for loops, if then statements, and get modded before Dale Chase gives us the lowdown on using external data.
|
Loading…
Add table
Add a link
Reference in a new issue