Skip to content

PythonFoundation-homework/list_indexing_homework

Repository files navigation

Welcome

LIST Indexing

Automated grading of homework assignments and tests

  • fork this repository
  • solve the task
  • commit with proper message

Problems

List01

Return an empty list to the result.

Example 1:

Input:
Output: []

List02

A list of several elements is given. Return the first item.

Example 1:

Input: list1=[1,2,3,4,5]
Output: 1

Example 2:

Input: list1=["x", 1, "y", 2, "z", 3]
Output: "x"

Constraints:

  • 1 <= length(list1) <= 10^5

List03

lists list1 and list2 are given. Add them (combine) and return.

Example 1:

Input: list1=[1, 2, 3, 4, 5]  list2=[6, 7, 8, 9, 10]  
Output: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

Example 2:

Input: list1=["x", 1] list2=["y", 2, "z", 3]
Output: ["x", 1, "y", 2, "z", 3]

Constraints:

  • 1 <= length(list1) <= 10^5
  • 1 <= length(list2) <= 10^5

List04

A list of several elements is given. Return the last item.

Example 1:

Input: list1=[1, 2, 3, 4, 5]
Output: 5

Example 2:

Input: list1=[5,3,'a',1,2]
Output: 2

Constraints:

  • 1 <= length(list1) <= 10^5

List05

A list of several elements is given. i Return the item in the index.

Example 1:

Input: list1=[1, 2, 3, 4, 5] i=1
Output: 2

Example 2:

Input: list1=[5,3,'a',1,2] i=3
Output: 1

Constraints:

  • 1 <= length(list1) <= 10^5
  • 0 <= i < length(list1)

List06

A list of units and zeros with a length of five is given. Replace one with True.

Example 1:

Input: list1=[1, 0, 0, 0, 0]
Output: [True, 0, 0, 0, 0]

Example 2:

Input: list1=[1, 0, 1, 1, 0]
Output: [True, 0, True, True, 0]

Constraints:

  • length(list1) == 5

List07

A list of units and zeros with a length of five is given. Replace zero with False.

Example 1:

Input: list1=[1, 0, 0, 0, 0]
Output: [1, False, False, False, False]

Example 2:

Input: list1=[1, 0, 1, 1, 0]
Output: [1, False, 1, 1, False]

Constraints:

  • length(list1) == 5

List08

A list of ones and zeros, five in length, is given. replace one with True, replace zeros with False.

Example 1:

Input: list1=[1, 0, 0, 0, 0]
Output: [True, False, False, False, False]

Example 2:

Input: list1=[1, 0, 1, 1, 0]
Output: [True, False, True, True, False]

Constraints:

  • length(list1) == 5

List09

A list of several elements is given. True if all items are the same, otherwise return False.

Example 1:

Input: list1=[0, 0, 0, 0, 0]
Output: True

Example 2:

Input: list1=['x', 'x', 'y', 'y', 'z']
Output: False

Constraints:

  • 1 <= length(list1) <= 10^5

List10

A list of numbers consisting of several elements is given. Return the largest between the first and last elements.

Example 1:

Input: list1=[5, 32, 1, 4, 3]
Output: 5

Example 2:

Input: list1=[12, 2, 5, 2, 7, 9, 1]
Output: 12

Constraints:

  • 1 <= length(list1) <= 10^5

Warning

  • don't copy other solutions or any solution
  • don't remove comments

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages