Have A Go

Posted by Neville on June 23, 2016 under How To, Python, Resources, Training, Uncategorized | Comments are off for this article

A console to share:

Python is an interpreted language. That means that it needs an interpreter to take the code that a user has produced and translate it so the computer’s processor can work on it.
One way to get access to the python interpreter is by using a console. Often it is necessary to download and configure python on your machine.
The frame below, however, will provide you with a console that is shared from the pythonanywhere site.

After the console loads and displays some information about python and the version being used you can type some commands at the cursor in the current input (In) line.

Try some of these:

Use the console as a calculator. For example type some of the following math statements, or use your own. After each one press the enter(return) key to see the result.

  • 5 + 6
  • 45 * 5
  • 81 / 9
  • 2 ** 3 (don’t type this:  2 to the 3rd power)

Playing with strings (words and letters).

  • print(“Hello”)
  • name = “Tom”
  • print(name)

 

 

Use this pythonanywhere console:

Some more examples to try: Remember to hit Enter at the end of each line. For multiple lines as below, hit Enter on the blank line after you finish to send the lines for processing.

1: for count in range(5):

print(count)

2: Creating and displaying a list:

mylist = [8, 9, 6, 5, 4]

mylist

3: Sorting the list.

mylist.sort()

mylist

 

 

 

 

If you enjoyed this post, please consider leaving a comment or subscribing to the RSS feed to have future articles delivered to your feed reader.

Comments are closed.