This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import csv | |
# Open all required files with at once | |
with open('numbers.txt', 'r') as numbersfile, \ | |
open('birthdays.txt', 'r') as birthdayfile, \ | |
open('output.txt', 'w') as output: | |
# Read in each line as a dictionary | |
# https://docs.python.org/2/library/csv.html#csv.DictReader | |
numReader = csv.DictReader(numbersfile, fieldnames=['Name','Number']) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
people = {} # let's start with an empty dictionary to hold our data | |
with open('numbers.txt', 'r') as numbers: | |
for index, line in enumerate(numbers): | |
if index > 0: # skip the first line (don't need the headers) | |
name, birthday = line.rstrip().split(',') | |
# study this line carefully, it's intentionally terse | |
people.update({ name : { 'number' : birthday } }) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Name,Number | |
Amal Albertson,7/2/1972 | |
Sondra Shoemaker,2/2/1964 | |
Ryann Ralphs,5/22/1999 | |
Delcie Demma,8/19/1975 | |
Gemma Gates,5/16/1999 | |
Su Scurlock,3/18/1990 | |
Delma Duchene,12/16/1994 | |
Kathyrn Kreps,2/25/1965 | |
Cinda Christon,6/26/1987 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Ask the user to enter a number | |
number_of_rows = int(raw_input('Enter a number: ')) | |
# Iterate through range of numbers up to what the user entered | |
for row in range(number_of_rows): | |
stars = 1 + row * 2 | |
spaces = number_of_rows - row - 1 | |
print ' ' * spaces + '*' * stars |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Problem: You are given two files, one contains a list of | |
names (names.txt) and the other a list of phone numbers (numbers.txt). | |
Your boss needs a single CSV file that can be loaded into excel. | |
Your task is to combine both txt files into one CSV file. | |
The first and last names need to be in separate columns | |
and the phone number must be in the format (555)555-5555 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def getVowels(word, includeY=False, unique=False): | |
matches = [] | |
vowels = 'aeiou' if not includeY else 'aeiouy' | |
for char in word: | |
if char.lower() in vowels: | |
matches.append(char) | |
return list(set(matches)) if unique else matches | |
print getVowels('This is a fancy test string', includeY=True, unique=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Assignment 1 - Building a star pyramid | |
# Ask the user to enter a number | |
number_of_rows = int(raw_input('Enter a number: ')) | |
# Write your code below this comment |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<style> | |
#verify { | |
position: absolute; | |
top: 0; | |
left: 0; | |
background: rgba(67, 157, 207, 0.9); | |
z-index: 200; | |
width: 100%; | |
height: 100%; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% for link in linklists.footer-nav.links %} | |
{% cycle '<ul>', '' %} | |
<li><a href="{{ link.url }}">{{ link.title }}</a></li> | |
{% cycle '', '</ul>' %} | |
{% capture needsEndingElement %}{% cycle 'yes', 'no' %}{% endcapture %} | |
{% endfor %} | |
{% if needsEndingElement == 'yes' %} | |
</ul> | |
{% endif %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% if settings.carousel_show %} | |
<div class="flexslider"> | |
<ul class="slides"> | |
{% for i in (1..5) %} | |
{% capture show %}carousel{{ i }}_show{% endcapture %} | |
{% capture image %}carousel{{ i }}.jpg{% endcapture %} | |
{% capture title %}carousel_title{{ i }}{% endcapture %} | |
{% capture link %}carousel_link{{ i }}{% endcapture %} |
NewerOlder