pythonanywhere.com for training

Learning programming and database technology

Many of us who have been programming for years feel obligated to share our skills with others. https://www.pythonanywhere.com is ideal for sharing our programming knowledge with younger people who are interesting in either a new career or just want to learn how to program, use a database or learn about making a web page.

This is site offers an environment to learn python, the most popular programming language. This website also allows remote access so students can follow along. You can add as many students as needed who will have remote website access. Not only does this website offer python but also either a choice of MySQL or Postgres database applications.

 

Go ahead and sign up and login, it’s free for basic usage. Login and get this screen.

This is the basic Dashboard. Notice the buttons across the top right.  Notice the second button, Consoles. 

Consoles can be various versions of Python, a database console to manage the MySQL and something called Bash. Bash stands for Bourne-Again SHell. Named after my old boss, Stephen R. Bourne, the original inventor of the UNIX shell. Like the Windows Command line, it’s a way to directly control the Operating System with text based commands. MySQL is a shell like command to directly manage the database you can create for free on this website, more about that later.

The next button is the Files button

This website allows you to create files and directories for your use with a limit on file usage.

I am going to skip the Web and Tasks buttons. You can create websites and fire off tasks from this website. I will not cover that here.

The Databases button offers two choices MySQL or Postgres database.

 I enabled the MySQL database function. You can create one or more individual MySQL databases. You can manage the databases using the database console as mentioned. Notice the database has a global address that you can reach from anywhere on the Internet. More about the MySQL feature later.

Python is probably the most popular programming language. You can setup a class about Python as described below. Go back to the Consoles button.

There are several versions of Python as shown. IPython is a powerful front end to Python. “I” stands for Interface and it used with the Jupyter Notebook for self contained scripts. IPython and Jupyter Notebook is for advanced Python programmers. PyPy is more of a performance port of Python.

Getting started using Python with and without the Interpreter.

Push the 3.8 button

 

This starts the Python interpreter. The “print” command is a Python command to print a string or series of letters.

Push the Bash button 

 

This is the UNIX/Linux like shell. You can see what happens if I type > date a typical shell command. I used the “echo” command to send text to a file called sample.py. I then typed

> python sample.py

This is the usual way of  running a Python script.

These shell commands are used in Unix, Linux and Mac-OS operating systems and worthwhile learning.

Most often you would add python code to a file called something.py. You would then run the file with  $ python something.py.

Sharing your session as teacher. pythonanywhere.com allows you to share your session with your “students”

Push the Share with Others button

 

Enter their email address. They get an email like this.

They can open up their browser and see what you are doing.

Some Python highlights

Python has hundreds of libraries, here are the just ones for Python 3. https://docs.python.org/3/library/

Libraries are code modules written by the Python community. They provide functionality that you would have to write yourself. Don’t write code you can just download.

Python is a very popular language because it’s easy to learn. It is probably the most used programming language other than the language of the web that being JavaScript.

Editing files in the shell

Traditionally files are created using vi or vim. vi is a mature text editor that have been used for decades for UNIX and Linux.

Here is a web site with documentation for “vim”

“https://vim.rtorr.com/”

You will be editing and running files in the bash console. python files will be created in folders or directories. Create a folder for you files with this simple command

$ mkdir pythonTestFiles

$ cd pythonTestFiles

$ vi myTest.py

Add this line

print (“Hello World”)

$ python myTest.py

Outputs “Hello World”

Python Code examples

There are numerous sites with Python coding example to train and test your students. “geekforgeeks.com” is very comprehensive.

“https://www.programiz.com/python-programming/examples/add-number”

“https://skillcrush.com/blog/python-programming-examples/”

“https://www.geeksforgeeks.org/python-programming-examples/”

Python can be run directly in a Python console from pythonanywhere.com. This console may also be shared with the “students”

 

Using MySQL from pythonanywhere.com

As mentioned the popular MySQL database is platformed by pythonanywhere.com”.

Click on the Databases button on pythonanywhere.com. Create a database if you haven’t done so already. Start a console for one of your Databases. Remember you are only allowed two consoles for the free version so close any of the consoles you aren’t using. To begin configuring a MySQL database login to it.

The blanked out parts are the account name for pythonanywhere.com

From here you can create the tables you need for testing Python access to the internal database provided by pythonanywhere.com. Accessing a database from Python is a useful skill.

Here is more help for setting up and accessing the MySQL database in pythonanywhere.com.. https://help.pythonanywhere.com/pages/UsingMySQL/

Conclusions:

You can setup a class for teaching a group of people or do some work to teach yourself about either Python or MySQL. PostgreSQL is available on a paid plan. Two additional features I didn’t mention were Tasks and a dynamic Web page. Tasks are arbitrary tasks you may want to run from a network server. The Web feature from pythonanywhere.com is powered by using your choice of Django, web2py, Flask, Bottle all Python technologies. All these features are useful skills for you to learn in the digital economy. Python is easy to get started with and sophisticated enough to do big projects.