Python challenges

Practice problem statements with input format, output format, constraints and solutions.

beginner

Python Introduction challenge

Build a small solution that uses Python Introduction in Python and handles one normal case plus one edge case.

Input format

Use a short text value, array, query, or sample object depending on the topic.

Output format

Print, render, or return the processed result in a readable format.

Constraints

  • Keep the solution under 60 lines.
  • Use descriptive names.
  • Do not depend on hidden external services.

Starter code

items = ["Python Introduction", "practice", "review"]
for position, item in enumerate(items, start=1):
    print(f"{position}. {item}")

Test cases

  • basic sample - valid processed result
  • empty or small sample - safe fallback result

Hint

Focus on the core python introduction pattern before polishing the final output.

Solution

items = ["Python Introduction solution", "practice", "review"]
for position, item in enumerate(items, start=1):
    print(f"{position}. {item}")
beginner

Syntax and Indentation challenge

Build a small solution that uses Syntax and Indentation in Python and handles one normal case plus one edge case.

Input format

Use a short text value, array, query, or sample object depending on the topic.

Output format

Print, render, or return the processed result in a readable format.

Constraints

  • Keep the solution under 60 lines.
  • Use descriptive names.
  • Do not depend on hidden external services.

Starter code

items = ["Syntax and Indentation", "practice", "review"]
for position, item in enumerate(items, start=1):
    print(f"{position}. {item}")

Test cases

  • basic sample - valid processed result
  • empty or small sample - safe fallback result

Hint

Focus on the core syntax and indentation pattern before polishing the final output.

Solution

items = ["Syntax and Indentation solution", "practice", "review"]
for position, item in enumerate(items, start=1):
    print(f"{position}. {item}")
beginner

Variables challenge

Build a small solution that uses Variables in Python and handles one normal case plus one edge case.

Input format

Use a short text value, array, query, or sample object depending on the topic.

Output format

Print, render, or return the processed result in a readable format.

Constraints

  • Keep the solution under 60 lines.
  • Use descriptive names.
  • Do not depend on hidden external services.

Starter code

items = ["Variables", "practice", "review"]
for position, item in enumerate(items, start=1):
    print(f"{position}. {item}")

Test cases

  • basic sample - valid processed result
  • empty or small sample - safe fallback result

Hint

Focus on the core variables pattern before polishing the final output.

Solution

items = ["Variables solution", "practice", "review"]
for position, item in enumerate(items, start=1):
    print(f"{position}. {item}")
beginner

Data Types challenge

Build a small solution that uses Data Types in Python and handles one normal case plus one edge case.

Input format

Use a short text value, array, query, or sample object depending on the topic.

Output format

Print, render, or return the processed result in a readable format.

Constraints

  • Keep the solution under 60 lines.
  • Use descriptive names.
  • Do not depend on hidden external services.

Starter code

items = ["Data Types", "practice", "review"]
for position, item in enumerate(items, start=1):
    print(f"{position}. {item}")

Test cases

  • basic sample - valid processed result
  • empty or small sample - safe fallback result

Hint

Focus on the core data types pattern before polishing the final output.

Solution

items = ["Data Types solution", "practice", "review"]
for position, item in enumerate(items, start=1):
    print(f"{position}. {item}")
beginner

Numbers and Math challenge

Build a small solution that uses Numbers and Math in Python and handles one normal case plus one edge case.

Input format

Use a short text value, array, query, or sample object depending on the topic.

Output format

Print, render, or return the processed result in a readable format.

Constraints

  • Keep the solution under 60 lines.
  • Use descriptive names.
  • Do not depend on hidden external services.

Starter code

items = ["Numbers and Math", "practice", "review"]
for position, item in enumerate(items, start=1):
    print(f"{position}. {item}")

Test cases

  • basic sample - valid processed result
  • empty or small sample - safe fallback result

Hint

Focus on the core numbers and math pattern before polishing the final output.

Solution

items = ["Numbers and Math solution", "practice", "review"]
for position, item in enumerate(items, start=1):
    print(f"{position}. {item}")
beginner

Strings challenge

Build a small solution that uses Strings in Python and handles one normal case plus one edge case.

Input format

Use a short text value, array, query, or sample object depending on the topic.

Output format

Print, render, or return the processed result in a readable format.

Constraints

  • Keep the solution under 60 lines.
  • Use descriptive names.
  • Do not depend on hidden external services.

Starter code

items = ["Strings", "practice", "review"]
for position, item in enumerate(items, start=1):
    print(f"{position}. {item}")

Test cases

  • basic sample - valid processed result
  • empty or small sample - safe fallback result

Hint

Focus on the core strings pattern before polishing the final output.

Solution

items = ["Strings solution", "practice", "review"]
for position, item in enumerate(items, start=1):
    print(f"{position}. {item}")
beginner

String Formatting challenge

Build a small solution that uses String Formatting in Python and handles one normal case plus one edge case.

Input format

Use a short text value, array, query, or sample object depending on the topic.

Output format

Print, render, or return the processed result in a readable format.

Constraints

  • Keep the solution under 60 lines.
  • Use descriptive names.
  • Do not depend on hidden external services.

Starter code

items = ["String Formatting", "practice", "review"]
for position, item in enumerate(items, start=1):
    print(f"{position}. {item}")

Test cases

  • basic sample - valid processed result
  • empty or small sample - safe fallback result

Hint

Focus on the core string formatting pattern before polishing the final output.

Solution

items = ["String Formatting solution", "practice", "review"]
for position, item in enumerate(items, start=1):
    print(f"{position}. {item}")
beginner

Lists challenge

Build a small solution that uses Lists in Python and handles one normal case plus one edge case.

Input format

Use a short text value, array, query, or sample object depending on the topic.

Output format

Print, render, or return the processed result in a readable format.

Constraints

  • Keep the solution under 60 lines.
  • Use descriptive names.
  • Do not depend on hidden external services.

Starter code

items = ["Lists", "practice", "review"]
for position, item in enumerate(items, start=1):
    print(f"{position}. {item}")

Test cases

  • basic sample - valid processed result
  • empty or small sample - safe fallback result

Hint

Focus on the core lists pattern before polishing the final output.

Solution

items = ["Lists solution", "practice", "review"]
for position, item in enumerate(items, start=1):
    print(f"{position}. {item}")
beginner

List Comprehensions challenge

Build a small solution that uses List Comprehensions in Python and handles one normal case plus one edge case.

Input format

Use a short text value, array, query, or sample object depending on the topic.

Output format

Print, render, or return the processed result in a readable format.

Constraints

  • Keep the solution under 60 lines.
  • Use descriptive names.
  • Do not depend on hidden external services.

Starter code

items = ["List Comprehensions", "practice", "review"]
for position, item in enumerate(items, start=1):
    print(f"{position}. {item}")

Test cases

  • basic sample - valid processed result
  • empty or small sample - safe fallback result

Hint

Focus on the core list comprehensions pattern before polishing the final output.

Solution

items = ["List Comprehensions solution", "practice", "review"]
for position, item in enumerate(items, start=1):
    print(f"{position}. {item}")
beginner

Tuples challenge

Build a small solution that uses Tuples in Python and handles one normal case plus one edge case.

Input format

Use a short text value, array, query, or sample object depending on the topic.

Output format

Print, render, or return the processed result in a readable format.

Constraints

  • Keep the solution under 60 lines.
  • Use descriptive names.
  • Do not depend on hidden external services.

Starter code

items = ["Tuples", "practice", "review"]
for position, item in enumerate(items, start=1):
    print(f"{position}. {item}")

Test cases

  • basic sample - valid processed result
  • empty or small sample - safe fallback result

Hint

Focus on the core tuples pattern before polishing the final output.

Solution

items = ["Tuples solution", "practice", "review"]
for position, item in enumerate(items, start=1):
    print(f"{position}. {item}")