Skip to content
/ DA_M1_list1 Public template

Data Analytics module 1 , Google's Python Class list 1 activity

Notifications You must be signed in to change notification settings

CodeYouOrg/DA_M1_list1

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

Basic List Exercises

Welcome to the Basic List Exercises assignment! This exercise will help you practice working with lists in Python by implementing several functions. Follow the instructions below to complete the assignment.

Instructions

  1. Fill in the Code:

    • You will complete the functions provided in the list1.py file.
    • Each function has a description of what it should do. Your task is to write the code inside each function to achieve the described behavior.
    • The main() function is already set up to call these functions with various inputs and print 'OK' when a function is correct.
  2. Function Descriptions:

    • A. match_ends:
      • Given a list of strings, return the count of the number of strings where the string length is 3 or more and the first and last characters of the string are the same.
      • Example: match_ends(['aba', 'xyz', 'aa', 'x', 'bbb']) should return 3.
    • B. front_x:
      • Given a list of strings, return a list with the strings in sorted order, except group all the strings that begin with 'x' first.
      • Example: front_x(['mix', 'xyz', 'apple', 'xanadu', 'aardvark']) should return ['xanadu', 'xyz', 'aardvark', 'apple', 'mix'].
    • C. sort_last:
      • Given a list of non-empty tuples, return a list sorted in increasing order by the last element in each tuple.
      • Example: sort_last([(1, 7), (1, 3), (3, 4, 5), (2, 2)]) should return [(2, 2), (1, 3), (3, 4, 5), (1, 7)].
  3. Testing Your Code:

    • The main() function includes test cases that will help you verify if your implementations are correct.
    • The test() function compares the output of your function with the expected result and prints 'OK' if they match, otherwise it prints 'X'.

Submission

  • Complete as many functions as you can.
  • Ensure your code runs without errors.
  • Submit your completed list1.py file by pushing your repo to GitHub and it will auto grade.

Happy coding!

About

Data Analytics module 1 , Google's Python Class list 1 activity

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages