# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

# + [markdown] colab_type="text" id="BEQtdLADyxjl"
# # Basic list exercises
# This notebook is a quick assessment of your progress on learning Python.
# -

# ## Instructions to Students
# - **Do not add or remove cells in this notebook. Do not edit or remove the `### START FUNCTION` or `### END FUNCTION` comments. Do not add any code outside of the functions you are required to edit. Doing any of this will lead to a mark of 0%!**
# - Answer the questions according to the specifications provided.
# - Use the given cell in each question to to see if your function matches the expected outputs.
# - Do not hard-code answers to the questions.
# - The use of stackoverflow, google, and other online tools are permitted. However, copying fellow student's code is not permissible and is considered a breach of the Honour code below. Doing this will result in a mark of 0%.
# - Good luck, and may the force be with you!

# + [markdown] colab_type="text" id="0ZMgrpz7N7-x"
# ## Honour Code

# + [markdown] colab_type="text" id="eklbvqFjN7-z"
# I **YOUR NAME, YOUR SURNAME**, confirm - by submitting this document - that the solutions in this notebook are a result of my own work and that I abide by the   <a href="https://drive.google.com/open?id=1FXCIf425JLRx3JQi-ltSWppj8BCF3Np1" target="_blank">EDSA Student Manifesto</a>.
#
# Non-compliance with the honour code constitutes a material breach of contract.

# + [markdown] colab_type="text" id="X_Dj3nPoyxjw"
# # Question 1
#
# Given a list of lowercase strings, return a list with the strings sorted in alphabetical order, except group all the strings that begin with `x` at the beginning of the list.<br>
# e.g. ['mix', 'xyz', 'apple', 'xanadu', 'aardvark'] yields<br>
# `['xanadu', 'xyz', 'aardvark', 'apple', 'mix']`<br>

# + [markdown] colab_type="text" id="dHSLkVevN7-0"
# Hint: This can be done by making 2 lists and sorting each of them before combining them.
#
# Hint: Remember that Python's `list` object has a `sort()` function. Python also has a built-in function called `sorted()`. 

# + colab={} colab_type="code" id="xDOT_zbXyxjx" nbgrader={"grade": false, "grade_id": "front_x", "locked": false, "schema_version": 1, "solution": true}
### START FUNCTION
def front_x(words):
    # your code here
    finder = list(words)
    found  = []
    found_2 = []
    final_list = []
    for elements in finder:
        search_bear = list(elements)
        if search_bear[0] == 'x':
            found.append(elements)
        else:
            found_2.append(elements)
    final_list = sorted(found)+sorted(found_2)
    return final_list
### END FUNCTION


# + [markdown] colab_type="text" id="MYtjGg4nN7-4"
# You may upload to the Autograder as many times as you wish; It can be a useful ally.

# + [markdown] colab_type="text" id="8vO6Nx8HN7-5"
# If your output to the following function calls matches the corresponding output, then your solution may be working.

# + colab={"base_uri": "https://localhost:8080/", "height": 36} colab_type="code" executionInfo={"elapsed": 3757, "status": "ok", "timestamp": 1575361414037, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "13254939673721675351"}, "user_tz": -120} id="0DUW0V6Gyxjz" nbgrader={"grade": true, "grade_id": "correct_front_x", "locked": true, "points": 2, "schema_version": 1, "solution": false} outputId="de83978a-4c92-40b2-f766-5edefb6ed867"
front_x(['mix', 'xyz', 'apple', 'xanadu', 'aardvark'])


# + [markdown] colab_type="text" id="2ydSz7Ij5SBg"
# **Expected Outputs:**
# ```python
# front_x(['mix', 'xyz', 'apple', 'xanadu', 'aardvark']) == ['xanadu', 'xyz', 'aardvark', 'apple', 'mix']
# front_x(['netowrk', 'artist', 'xamarian', 'king', 'cat']) == ['xamarian', 'artist', 'cat', 'king', 'netowrk']
# front_x(['jhsdfi', 'jeiri', 'iopqwu', 'bhvaiau', 'loaks']) == ['bhvaiau', 'iopqwu', 'jeiri', 'jhsdfi', 'loaks']
# ```

# + [markdown] colab_type="text" id="Cjl-BjjaN7_G"
# # Question 2
# ## RNA Length
#
# Proteins are the building blocks of life. The process starts when another protein (a polymerase) reads your genetic code and performs transcription, the code (RNA) for making protein. Ribosomes will then attach to this RNA code to begin making specific proteins. Your genetic code is made up of pairs of nucleotides. Once transcribed into the code, these nucleotides contain the following nucleotides:
#
# U,G,A,C.
#
# UGA, UAA, and UAG are stop codons and AUG is a start codon so that the protein, ribosome, can identify where to stop and start the protein formation.
#
# A genetics lab has tasked you to design a function which recognises the length of the RNA code (excluding the start and stop codons). The function must also determine if their code is actually valid (must contain AUG as a start codon and UGA, UAA, or UAG at the end)
#
# Note: RNA starts with a start codon AUG and ends with UGA, UAA, or UAG
#
# The function must return "Not readable RNA code" if the above conditions are not met.
#

# + colab={} colab_type="code" id="e5oLBZUlN7_H"
### START FUNCTION
def rna_length(mrna):
    # your code here
    finder = mrna
    
    if finder.startswith('AUG') and finder.endswith('UGA') or finder.endswith('UAA') or finder.endswith('UAG'):
        count = len(finder) - 6
        return count
    else:
        return "Not readable RNA code"
### END FUNCTION


# + colab={"base_uri": "https://localhost:8080/", "height": 35} colab_type="code" executionInfo={"elapsed": 1228, "status": "ok", "timestamp": 1575364362513, "user": {"displayName": "<NAME>", "photoUrl": "", "userId": "13254939673721675351"}, "user_tz": -120} id="gnBb_6JnN7_J" outputId="2ec819b8-8d31-4a48-8c8a-9c08aa24dbc4"
rna_length('AUGAGGCACCUUCUGCUCCUUAC')

# + [markdown] colab_type="text" id="LtJq6eFbN7_W"
# **Expected Outputs:** 
# ```python
# rna_length('AUGUAGCAUAA') == 5
# rna_length('AUGUUAUAG') == 3
# rna_length('AUGUAGGCACAUUUAUGCUCCUGA') == 18
# rna_length('AUGAGGCACCUUCUGCUCCUUAC') == "Not readable RNA code"
# ```

# + [markdown] colab_type="text" id="Vm13pjSjyxkI"
# # References

# + [markdown] colab_type="text" id="OxjO59-2yxkJ"
# This tutorial was created using the wonderful [Google Python Developers](https://developers.google.com/edu/python/) course, and has been modified under the [Creative Common's licence 2.5](https://creativecommons.org/licenses/by/2.5/) 

# + [markdown] colab_type="text" id="Y5w2IupiyxkJ"
# Copyright 2010 Google Inc.
# Licensed under the Apache License, Version 2.0
# http://www.apache.org/licenses/LICENSE-2.0
#
# Google's Python Class
# http://code.google.com/edu/languages/google-python-class/

StarcoderdataJupyterScriptsDedupFiltered