Skip to content

Codeschool-Python/tuple_indexing_homework

Repository files navigation

Welcome

TUPLE Indexing

Automated grading of homework assignments and tests

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

Problems

tuple01

Return an empty Tuple to the result.

Example 1:

Input:
Output: ()

tuple02

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

Example 1:

Input: tuple1=(1,2,3,4,5)
Output: 1

Example 2:

Input: tuple1=("x", 1, "y", 2, "z", 3)
Output: "x"

Constraints:

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

tuple03

tuples tuple1 and tuple2 are given. Add them (combine) and return.

Example 1:

Input: tuple1=(1, 2, 3, 4, 5)  tuple2=(6, 7, 8, 9, 10)  
Output: (1, 2, 3, 4, 5, 6, 7, 8, 9, 10)

Example 2:

Input: tuple1=("x", 1) tuple2=("y", 2, "z", 3)
Output: ("x", 1, "y", 2, "z", 3)

Constraints:

  • 1 <= length(tuple1) <= 10^5
  • 1 <= length(tuple2) <= 10^5

tuple04

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

Example 1:

Input: tuple1=(1, 2, 3, 4, 5)
Output: 5

Example 2:

Input: tuple1=(5,3,'a',1,2)
Output: 2

Constraints:

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

tuple05

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

Example 1:

Input: tuple1=(1, 2, 3, 4, 5) i=1
Output: 2

Example 2:

Input: tuple1=(5,3,'a',1,2) i=3
Output: 1

Constraints:

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

tuple06

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

Example 1:

Input: tuple1=(1, 0, 0, 0, 0)
Output: (True, 0, 0, 0, 0)

Example 2:

Input: tuple1=(1, 0, 1, 1, 0)
Output: (True, 0, True, True, 0)

Constraints:

  • length(tuple1) == 5

tuple07

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

Example 1:

Input: tuple1=(1, 0, 0, 0, 0)
Output: (1, False, False, False, False)

Example 2:

Input: tuple1=(1, 0, 1, 1, 0)
Output: (1, False, 1, 1, False)

Constraints:

  • length(tuple1) == 5

tuple08

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

Example 1:

Input: tuple1=(1, 0, 0, 0, 0)
Output: (True, False, False, False, False)

Example 2:

Input: tuple1=(1, 0, 1, 1, 0)
Output: (True, False, True, True, False)

Constraints:

  • length(tuple1) == 5

tuple09

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

Example 1:

Input: tuple1=(0, 0, 0, 0, 0)
Output: True

Example 2:

Input: tuple1=('x', 'x', 'y', 'y', 'z')
Output: False

Constraints:

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

tuple10

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

Example 1:

Input: tuple1=(5, 32, 1, 4, 3)
Output: 5

Example 2:

Input: tuple1=(12, 2, 5, 2, 7, 9, 1)
Output: 12

Constraints:

  • 1 <= length(tuple1) <= 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

 
 
 

Contributors

Languages