Python Review

Review

How review works

Ideas you missed in a checkpoint come back here a day later, then again a few days after that. A couple of short problems each. Coming back to them after a gap is what makes them stick.

    Back to the course
      problem.py
      print(9 / 3)
      print(9 // 4)
      print(9 % 4)
      print(2 ** 3 * 2)
      print(-9 // 4)
      
      problem.py to run
      total = 3725
      minutes = total // 60
      seconds = total % 60
      print(total, "seconds is", minutes, "min", seconds, "s")
      
      problem.py to run
      total = 200
      minutes = 0
      seconds = 0
      print(total, "seconds is", minutes, "min", seconds, "s")
      
      problem.py
      word = "brainlag"
      print(word[0:5])
      print(word[-3:])
      print(len(word) - 1)
      print(word.upper().count("A"))
      
      problem.py to run
      song = "Neon Rain"
      seconds = 207
      print(f"___ is ___:___ long")
      
      problem.py to run
      first = "Ada"
      last = "Lovelace"
      print(f"{first}.{last}.")
      
      problem.py
      score = 85
      if score > 50:
          print("pass")
      elif score > 80:
          print("merit")
      else:
          print("fail")
      if score > 80:
          print("well done")
      
      problem.py to run
      mark = int(input())
      if mark >= 40:
          print("Pass")
      elif mark >= 70:
          print("Distinction")
      elif mark >= 55:
          print("Merit")
      else:
          print("Fail")
      
      problem.py to run
      n = int(input())
      print("even")
      
      problem.py
      n = input()
      print(n * 3)
      print(int(n) * 3)
      
      problem.py to run
      price = int(input())
      qty = int(input())
      print(f"Total: {price * qty:.2f}")
      
      problem.py to run
      a = input()
      b = input()
      print(a + b)
      
      problem.py
      n = 10
      while n > 1:
          n = n // 2
          print(n)
      
      problem.py to run
      lives = 3
      while lives == 0:
          print("Lives left:", lives)
          lives -= 1
      print("Game over")
      
      problem.py to run
      n = 3
      while n <= 15:
          print(n)
          n += 1
      
      Python 3.13

      Code editor. Press Control or Command plus Enter to run the code. Tab indents; to move focus out of the editor, press Escape and then Tab.