Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a index slicing exercise to Python basics assignment #208

Merged
merged 4 commits into from
Dec 19, 2024

Conversation

SponsoredByPuma
Copy link
Contributor

No description provided.

@SponsoredByPuma
Copy link
Contributor Author

@pkeilbach Is this fine for you?

Copy link
Owner

@pkeilbach pkeilbach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking more of something like this, where students need to implemet variants of slicing (sorry I should have provided more instructions here):

# Function Prompt: Implement the following slicing operations
def slicing_examples(input_list):
    """
    This function takes a list and returns a dictionary with results of different slicing operations.
    
    Implement the following:
    1. "first_three": Get the first three elements.
    2. "last_two": Get the last two elements.
    3. "reversed": Reverse the list.
    4. "skip_two": Get every second element in the list.
    5. "middle_slice": Get all elements except the first and last.
    
    Args:
        input_list (list): A list of elements.
    
    Returns:
        dict: A dictionary with keys as the operation names and values as the resulting sliced lists.
    """
    # Example structure for the return dictionary
    return {
        "first_three": None,  # Replace with slicing logic
        "last_two": None,     # Replace with slicing logic
        "reversed": None,     # Replace with slicing logic
        "skip_two": None,     # Replace with slicing logic
        "middle_slice": None, # Replace with slicing logic
    }

# Example usage:
# slicing_examples([1, 2, 3, 4, 5, 6])
# Expected output:
# {
#     "first_three": [1, 2, 3],
#     "last_two": [5, 6],
#     "reversed": [6, 5, 4, 3, 2, 1],
#     "skip_two": [1, 3, 5],
#     "middle_slice": [2, 3, 4, 5]
# }

@pkeilbach pkeilbach added the assignments Assignment submissions or anything else related to the assignments label Dec 16, 2024
@pkeilbach pkeilbach linked an issue Dec 16, 2024 that may be closed by this pull request
@SponsoredByPuma
Copy link
Contributor Author

@pkeilbach I adjusted the function and the tests

src/htwgnlp/python_basics.py Outdated Show resolved Hide resolved
src/htwgnlp/python_basics.py Outdated Show resolved Hide resolved
Copy link
Owner

@pkeilbach pkeilbach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! 🚀

@pkeilbach pkeilbach merged commit 41788f1 into pkeilbach:main Dec 19, 2024
3 checks passed
@pkeilbach pkeilbach modified the milestone: Winter term 2024/25 Dec 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
assignments Assignment submissions or anything else related to the assignments
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a index slicing exercise to Python basics assignment
2 participants