Python practice: Definite Loops with for and range()

Chapter 7 · 8 questions · included in full access

  1. Question 1 · easy

    Loop with range(5)

    Use a for loop with range(5) to print numbers 0 to 4 on separate lines:

    Solve it in your browser
  2. Question 2 · easy

    Sum of numbers 1 to 10

    Calculate the sum of numbers from 1 to 10 using a for loop with range(1, 11) and an accumulator total = 0. Print total:

    Solve it in your browser
  3. Question 3 · easy

    Multiples of 5 with step

    Use range(10, 35, 5) to print numbers 10, 15, 20, 25, 30 on separate lines:

    Solve it in your browser
  4. Question 4 · easy

    Iterate through string characters

    Loop through the string "ACME" with a for loop and print each character in uppercase on a separate line:

    Solve it in your browser
  5. Question 5 · easy

    Indexed loop with enumerate

    Given reps = ["Asha", "Ravi", "Priya"], use enumerate(reps, start=1) to print each rep formatted as f"#{rank}: {rep}":

    Solve it in your browser
  6. Question 6 · easy

    Accumulate order revenues

    Given orders = [1200, 3400, 850, 4100], compute total revenue using a loop and print total:

    Solve it in your browser
  7. Question 7 · medium

    Count positive balances

    Given balances = [100, -50, 200, 0, 350, -10], count how many accounts have balance > 0 and print count:

    Solve it in your browser
  8. Question 8 · medium

    Find maximum transaction

    Given sales = [450, 1200, 310, 890, 750], find the highest sale using a loop and variable peak = 0. Print peak:

    Solve it in your browser

These questions are part of full access.

The first chapters of every track are free. Full access is a one-time payment.

See pricing