This file contains hidden or 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
6. What's With "with"? | |
with open('fun_file.txt') as close_this_file: | |
setup = close_this_file.readline() | |
punchline = close_this_file.readline() | |
print(setup) | |
7. What is a CSV File? |
This file contains hidden or 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
letters = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"] | |
points = [1, 3, 3, 2, 1, 4, 2, 4, 1, 8, 5, 1, 3, 4, 1, 3, 10, 1, 1, 1, 1, 4, 4, 8, 4, 10] | |
letter_to_points = {letters:points for letters, points in zip(letters, points)} | |
letter_to_points[''] = 0 | |
def score_word(word): | |
point_total = 0 | |
for i in word: |
This file contains hidden or 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
Unit 8 - Using Dictionaries - Lessons 4 - 10 Assignment | |
4, Try ? Except to Get a Key | |
caffeine_level = {"espresso": 64, "chai": 40, "decaf": 0, "drip": 120, "matcha":30} | |
try: | |
print(caffeine_level["matcha"]) | |
except: | |
print("Unknown Caffeine Level") |