8000 Initial commit · uchinx/c9-python-getting-started@b09501b · GitHub
[go: up one dir, main page]

Skip to content

Commit b09501b

Browse files
author
Christopher Harrison
committed
Initial commit
1 parent 3f33727 commit b09501b

File tree

133 files changed

+1716
-38
lines changed
  • Some content is hidden

    Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

    133 files changed

    +1716
    -38
    lines changed

    .gitignore

    Lines changed: 38 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -1,3 +1,9 @@
    1+
    env
    2+
    3+
    # Created by https://www.gitignore.io/api/python,visualstudiocode
    4+
    # Edit at https://www.gitignore.io/?templates=python,visualstudiocode
    5+
    6+
    ### Python ###
    17
    # Byte-compiled / optimized / DLL files
    28
    __pycache__/
    39
    *.py[cod]
    @@ -20,6 +26,8 @@ parts/
    2026
    sdist/
    2127
    var/
    2228
    wheels/
    29+
    pip-wheel-metadata/
    30+
    share/python-wheels/
    2331
    *.egg-info/
    2432
    .installed.cfg
    2533
    *.egg
    @@ -38,6 +46,7 @@ pip-delete-this-directory.txt
    3846
    # Unit test / coverage reports
    3947
    htmlcov/
    4048
    .tox/
    49+
    .nox/
    4150
    .coverage
    4251
    .coverage.*
    4352
    .cache
    @@ -72,9 +81,20 @@ target/
    7281
    # Jupyter Notebook
    7382
    .ipynb_checkpoints
    7483

    84+
    # IPython
    85+
    profile_default/
    86+
    ipython_config.py
    87+
    7588
    # pyenv
    7689
    .python-version
    7790

    91+
    # pipenv
    92+
    # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
    93+
    # However, in case of collaboration, if having platform-specific dependencies or dependencies
    94+
    # having no cross-platform support, pipenv may install dependencies that don’t work, or not
    95+
    # install all needed dependencies.
    96+
    #Pipfile.lock
    97+
    7898
    # celery beat schedule file
    7999
    celerybeat-schedule
    80100

    @@ -102,3 +122,21 @@ venv.bak/
    102122

    103123
    # mypy
    104124
    .mypy_cache/
    125+
    .dmypy.json
    126+
    dmypy.json
    127+
    128+
    # Pyre type checker
    129+
    .pyre/
    130+
    131+
    ### VisualStudioCode ###
    132+
    .vscode/*
    133+
    !.vscode/settings.json
    134+
    !.vscode/tasks.json
    135+
    !.vscode/launch.json
    136+
    !.vscode/extensions.json
    137+
    138+
    ### VisualStudioCode Patch ###
    139+
    # Ignore all local history of files
    140+
    .history
    141+
    142+
    # End of https://www.gitignore.io/api/python,visualstudiocode
    Lines changed: 15 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -0,0 +1,15 @@
    1+
    # I check to see if the requirements for honour roll are met
    2+
    gpa = float(input('What was your Grade Point Average? '))
    3+
    lowest_grade = float(input('What was your lowest grade? '))
    4+
    5+
    # Boolean variables allow you to remember a True/False value
    6+
    if gpa >= .85 and lowest_grade >= .70:
    7+
    honour_roll = True
    8+
    else:
    9+
    honour_roll = False
    10+
    11+
    # Somewhere later in your code if you need to check if students is
    12+
    # on honour roll, all I need to do is check the boolean variable
    13+
    # I set earlier in my code
    14+
    if honour_roll:
    15+
    print('You made honour roll')
    Lines changed: 24 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -0,0 +1,24 @@
    1+
    # When you join a hockey team you get your name on the back of the jersey
    2+
    # but the jersey may not be big enough to hold all the letters
    3+
    # Ask the user for their first name
    4+
    5+
    # Ask the user for their last name
    6+
    7+
    # if first name is < 10 characters and last name is < 10 characters
    8+
    # print first and last name on the jersey
    9+
    # if first name >= 10 characters long and last name is < 10 characters
    10+
    # print first initial of first name and the entire last name
    11+
    # if first name < 10 characters long and last name is >= 10 characters
    12+
    # print entire first name and first initial of last name
    13+
    # if first name >= 10 characters long and last name is >= 10 characters
    14+
    # print last name only
    15+
    16+
    # Test with the following values
    17+
    # first name: Susan last name: Ibach
    18+
    # output: Susan Ibach
    19+
    # first name: Susan last name: ReallyLongLastName
    20+
    # output: Susan R.
    21+
    # first name: ReallyLongFirstName last name: Ibach
    22+
    # output: R. Ibach
    23+
    # first name: ReallyLongFirstName last name: ReallyLongLastName
    24+
    # output: ReallyLongLastName
    Lines changed: 37 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -0,0 +1,37 @@
    1+
    # When you join a hockey team you get your name on the back of the jersey
    2+
    # but the jersey may not be big enough to hold all the letters
    3+
    # Ask the user for their first name
    4+
    first_name = input('Please enter your first name: ')
    5+
    # Ask the user for their last name
    6+
    last_name = input('Please enter your last name: ')
    7+
    8+
    # if first name is < 10 characters and last name is < 10 characters
    9+
    # print first and last name on the jersey
    10+
    # if first name >= 10 characters long and last name is < 10 characters
    11+
    # print first initial of first name and the entire last name
    12+
    # if first name < 10 characters long and last name is >= 10 characters
    13+
    # print entire first name and first initial of last name
    14+
    # if first name >= 10 characters long and last name is >= 10 characters
    15+
    # print last name only
    16+
    17+
    # Check length of first name
    18+
    if len(first_name) >=10:
    19+
    long_first_name = True
    20+
    else:
    21+
    long_first_name = False
    22+
    23+
    # Check length of last name
    24+
    if len(last_name) >= 10:
    25+
    long_last_name = True
    26+
    else:
    27+
    long_last_name = False
    28+
    29+
    # Evaluate possible jersey print combinations for different lengths
    30+
    if long_first_name and long_last_name:
    31+
    print(last_name)
    32+
    elif long_first_name:
    33+
    print(first_name[0:1] + '. ' + last_name)
    34+
    elif long_last_name:
    35+
    print(first_name + ' ' + last_name[0:1] + '.')
    36+
    else:
    37+
    print(first_name + ' ' + last_name)
    Lines changed: 31 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -0,0 +1,31 @@
    1+
    # Complex condition checks
    2+
    3+
    Conditional execution can be completed using the [if](https://docs.python.org/3/reference/compound_stmts.html#the-if-statement) statement.
    4+
    5+
    `if` syntax
    6+
    7+
    ```python
    8+
    if expression:
    9+
    # code to execute
    10+
    elif expression:
    11+
    # code to execute
    12+
    else:
    13+
    # code to execute
    14+
    ```
    15+
    16+
    [Boolean values](https://docs.python.org/3/library/stdtypes.html#boolean-values) can be either `False` or `True`
    17+
    18+
    [Boolean operators](https://docs.python.org/3/library/stdtypes.html#boolean-operations-and-or-not)
    19+
    20+
    - **x *or* y** - If either x **OR** y is true, the expression is executed
    21+
    - **x *and* y** - If x **AND** y are both true, the expression is executed
    22+
    23+
    [Comparison operators](https://docs.python.org/3/library/stdtypes.html#comparisons)
    24+
    25+
    - < less than
    26+
    - < greater than
    27+
    - == is equal to
    28+
    - \>= greater than or equal to
    29+
    - <= less than or equal to
    30+
    - != not equal to
    31+
    - **x *in* [a,b,c]** Does x match the value of a, b, or c
    Lines changed: 9 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -0,0 +1,9 @@
    1+
    # A student makes honour roll if their average is >=85
    2+
    # and their lowest grade is not below 70
    3+
    gpa = float(input('What was your Grade Point Average? '))
    4+
    lowest_grade = input('What was your lowest grade? ')
    5+
    lowest_grade = float(lowest_grade)
    6+
    7+
    if gpa >= .85 and lowest_grade >= .70:
    8+
    print('You made the honour roll')
    9+

    11 - Collections/README.md

    Lines changed: 14 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -0,0 +1,14 @@
    1+
    # Collections
    2+
    3+
    Collections are groups of items. Python supports several types of collections. Three of the most common are dictionaries, lists and arrays.
    4+
    5+
    ## Lists
    6+
    7+
    [Lists](https://docs.python.org/3/tutorial/introduction.html#lists) are a collection of items. Lists can be expanded or contracted as needed, and can contain any data type. Lists are most commonly used to store a single column collection of information, however it is possible to [nest lists](https://docs.python.org/3/tutorial/datastructures.html#nested-list-comprehensions)
    8+
    ## Arrays
    9+
    10+
    [Arrays](https://docs.python.org/3/library/array.html) are similar to lists, however are designed to store a uniform basic data type, such as integers or floating point numbers.
    11+
    12+
    ## Dictionaries
    13+
    14+
    [Dictionaries](https://docs.python.org/3/tutorial/datastructures.html#dictionaries) are key/value pairs of a collection of items. Unlike a list where items can only be accessed by their index or value, dictionaries use keys to identify each item.

    11 - Collections/arrays.py

    Lines changed: 5 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -0,0 +1,5 @@
    1+
    from array import array
    2+
    scores = array('d')
    3+
    scores.append(97)
    4+
    scores.append(98)
    5+
    print(scores)

    11 - Collections/common-operations.py

    Lines changed: 4 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -0,0 +1,4 @@
    1+
    names = ['Christopher', 'Susan']
    2+
    print(len(names)) # Get the number of items
    3+
    names.insert(0, 'Bill') # Insert before index
    4+
    print(names)

    11 - Collections/dictionaries.py

    Lines changed: 4 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -0,0 +1,4 @@
    1+
    person = {'first': 'Christopher'}
    2+
    person['last'] = 'Harrison'
    3+
    print(person)
    4+
    print(person['first'])

    0 commit comments

    Comments
     (0)
    0