<jupyter_start><jupyter_text>The Astro 300 Python programming style guide ![XKCD Style](http://imgs.xkcd.com/comics/code_quality.png) This notebook is a summary of the python programming style we will use in Astro 300.**Half** of your grade, on each assignment,will be based on how well your code follows these guidelines.These guidelines are a small subset of the [PEP 8](https://www.python.org/dev/peps/pep-0008/)programming style used by python developers. `|--------|---------|---------|---------|---------|---------|---------|---------`  Variable Names- use only lowercase letters [a-z] and underscores [ _ ]- no blank spaces between the characters- avoid using a single character as a variable name- The purpose of the variable should be obvious from its name   *An Example:*You want to find the kinetic energy of a particle with mass 10 and velocity 20:$$ \mathrm{Kinetic\ Energy}\ = \frac{1}{2}\ mv^2 $$<jupyter_code># Good - Full credit

mass_particle = 10.0
velocity_particle = 20.0

kinetic_energy = 0.5 * mass_particle * (velocity_particle ** 2)

print(kinetic_energy)
# Bad - Half credit at best

x = 10.0
y = 20.0

print(0.5*x*y**2)
# Really bad - no credit

print(0.5*10*20**2)<jupyter_output><empty_output><jupyter_text>`|--------|---------|---------|---------|---------|---------|---------|---------`  Function NamesUse the same guidelines as for variable names<jupyter_code># Good

def find_kinetic_energy(mass_part, velocity_part):
    
    kinetic_energy = 0.5 * mass_part * velocity_part ** 2
    return(kinetic_energy)
# Bad

def KE(x,y):
    return(0.5*x*y**2)
# Good

mass_particle = 10.0
velocity_particle = 20.0

kinetic_energy = find_kinetic_energy(mass_particle,velocity_particle)

print(kinetic_energy)
# Bad

print(KE(10,20))<jupyter_output><empty_output><jupyter_text>`|--------|---------|---------|---------|---------|---------|---------|---------`  Line Length- Limit all lines to a maximum of 79 characters- The piece that seperates the sections in this notebook is 79 characters long- If you have to scroll horizontally - your line is too longThe preferred way of wrapping long lines is by using Python's implied line continuationinside parentheses (), brackets [] and braces {}. Long lines can be broken over multiple lines by wrapping expressions in parentheses.   *An Example:*<jupyter_code># Some variables to use in an equation

gross_wages = 50000
taxable_interest = 1000
dividends = 50
qualified_dividends = 10
ira_deduction = 2000
student_loan_interest = 3000
medical_deduction = 1000
# Good

income = (gross_wages
          + taxable_interest
          + (dividends - qualified_dividends)
          - ira_deduction
          - student_loan_interest
          - medical_deduction)

print(income)
# Bad
 
income = gross_wages + taxable_interest + (dividends - qualified_dividends) - ira_deduction - student_loan_interest - medical_deduction

print(income)<jupyter_output><empty_output><jupyter_text>Long text can be wrapped in `"""`<jupyter_code>quote_the_raven = """
Once upon a midnight dreary, while I pondered, weak and weary,
Over many a quaint and curious volume of forgotten lore—
While I nodded, nearly napping, suddenly there came a tapping,
As of some one gently rapping, rapping at my chamber door.
"Tis some visiter," I muttered, "tapping at my chamber door—
            Only this and nothing more."
"""
print(quote_the_raven)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.14809384164222875, 'fraction_numerical': 0.025806451612903226, 'mean_word_length': 3.3786906290115533, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 1, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '157984', 'license': 'MIT', 'n_tokens_mistral': 1129, 'n_tokens_neox': 1009, 'n_words': 345, 'path': 'StyleGuide.ipynb', 'repo_name': 'UWashington-Astro300/Astro300-Wtr19', 'size': '3410'}