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
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<dict> | |
<key>CFBundleDevelopmentRegion</key> | |
<string>$(DEVELOPMENT_LANGUAGE)</string> | |
<key>CFBundleExecutable</key> | |
<string>$(EXECUTABLE_NAME)</string> | |
<key>CFBundleIdentifier</key> | |
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string> |
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
''' | |
Find all of the numbers from 1-1000 that are divisible by 7 | |
''' | |
div7 = [n for n in range(1,1000) if n % 7 == 0] | |
print(div7) |
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
''' | |
Find all of the numbers from 1-1000 that have a 3 in them | |
''' | |
three = [n for n in range(0,1000) if '3' in str(n)] | |
print(three) |
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
''' | |
Count the number of spaces in a string | |
''' | |
some_string = 'the slow solid squid swam sumptuously through the slimy swamp' | |
spaces = [s for s in some_string if s == ' '] | |
print(len(spaces)) |
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
''' | |
Create a list of all the consonants in the string "Yellow Yaks like yelling and yawning and yesturday they yodled while eating yuky yams" | |
''' | |
sentence = "Yellow Yaks like yelling and yawning and yesturday they yodled while eating yuky yams" | |
result = [letter for letter in sentence if letter not in 'a,e,i,o,u, " "'] |
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
''' | |
Get the index and the value as a tuple for items in the list ["hi", 4, 8.99, 'apple', ('t,b','n')]. Result would look like [(index, value), (index, value)] | |
''' | |
items = ["hi", 4, 8.99, 'apple', ('t,b','n')] | |
result = [(index, item) for index, item in enumerate(items)] | |
print(result) |
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
''' | |
Find the common numbers in two lists (without using a tuple or set) list_a = [1, 2, 3, 4], list_b = [2, 3, 4, 5] | |
''' | |
list_a = [1, 2, 3, 4] | |
list_b = [2, 3, 4, 5] | |
common = [a for a in list_a if a in list_b] | |
print(common) |
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
''' | |
Get only the numbers in a sentence like 'In 1984 there were 13 instances of a protest with over 1000 people attending'. Result is a list of numbers like [3,4,5] | |
''' | |
sentence = 'In 1984 there were 13 instances of a protest with over 1000 people attending' | |
words = sentence.split() | |
result = [number for number in words if not number.isalpha() ] | |
print(result) |
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
''' | |
Given numbers = range(20), produce a list containing the word 'even' if a number in the numbers is even, and the word 'odd' if the number is odd. Result would look like ['odd','odd', 'even'] | |
''' | |
result = ['even' if n%2 == 0 else 'odd' for n in range(20)] | |
print(result) | |
''' | |
Let's see the for loop and break out the syntax of the list comprehension |
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
''' | |
Produce a list of tuples consisting of only the matching numbers in these lists list_a = [1, 2, 3,4,5,6,7,8,9], list_b = [2, 7, 1, 12]. Result would look like (4,4), (12,12) | |
''' | |
list_a = [1, 2, 3,4,5,6,7,8,9] | |
list_b = [2, 7, 1, 12] | |
result = [(a, b) for a in list_a for b in list_b if a == b] | |
print(result) |
OlderNewer