How do I … in Python?

When we’re doing problem based learning – focusing on what we’re trying to achieve and learning about the tools and concepts we need to use, when we need them – it helps to look at the theory from a different perspective. This section outlines some of the questions you might want to answer if you’re working on the text based adventure game problem.

Alternatively, take a look at a cheat sheet like this one for a good summary of all the python basics

How do I …?

  • Print a message to the screen
  • Get information from the user
  • Perform calculations
  • Store basic information for later in the program
  • Repeat actions a specific number of times
  • Repeat actions until a condition is met
  • Perform an action if a condition is met
  • Store lists of information
  • Store lists of information and access the information using a text key or label
  • Perform an action on each item of a list
  • Generate a random number
  • Write reusable code
  • Store information that still exists when the program has stopped running
  • Retrieve previously saved information