Skip main navigation

Demonstration: Using the Python Playground

Demonstration: Using the Python Playground
<v ->So now I wanna tell you a little bit</v> about what we call the Python Playground. So the Python Playground is here in week two and it’s down here in Python Playground. It’s an exercise, but it’s not a graded exercise. So if you look at all the other exercises, they have a grade. But when you go the Python Playground, let’s get there, get to the Python Playground. So the Python Playground, as this word says, it’s an open-ended space for you to write and execute Python programs. And so the idea of all the other ones is there is some goal. On the right hand side there’s like a what you’ve done and then what it expects.
But in this one, there’s no expectation. It’s not an assignment, it’s just a place for you to write code. And so you can just write anything you want, print,
and then you can run it, all right? (beep) And so there you go. So this output runs and away you go. Now why would you wanna use this? Well, again, we encourage you to install Python yourself on your computers and do all your testing and playing around, but some of you aren’t gonna have computers. Some of you are just like using iPads or a computer in the library or a computer at your school and you can’t install software. So this allows you to play with Python programs. When you get to the point when you have files, there are files that you can open here. And this is the very beginning of the class, but if you…
say open(“mbox-short.txt”),
that actually doesn’t print anything out, but there are three files that, (laughs) yeah, your program doesn’t have any output, exactly. There are three files that are used in the textbook, mbox-short.txt, romeo.txt, and words.txt that allow you to open them in this little environment. And actually I can print them out, I can do this. print(open(“mbox-short.txt”).read())
This is too complex, but watch this. See, it just printed out that file that I read. So that’s one line to open a file, read the file, and print it out. And so there you go. And again, you can use this to interact with your teaching assistants outside of one of your graded assignments. Sometimes you’ll be working on something, you’ll go into Python Playground and then you’ll tell your teaching assistant, you’ll say, “Hey, I’m in Python Playground “and my name is so and so.”
And they will come in, they’ll get an extra button here and they can go find it and they can look at your code in Python Playground and then you can interact with them without having to post your code to the forums to get help. And so it’s pretty easy, you’ll use it for your own purposes. I don’t have any goals with it, I just wanted to make it so that you had availability of an open-ended place to run Python, okay? Hope you find it useful.

Demonstration: Using the Python Playground

Note: When utilizing the Python Playground for assistance, please include your Learner ID to facilitate easier communication between Learners and Mentors.

This article is from the free online

Programming for Everybody (Getting Started with Python)

Created by
FutureLearn - Learning For Life

Reach your personal and professional goals

Unlock access to hundreds of expert online courses and degrees from top universities and educators to gain accredited qualifications and professional CV-building certificates.

Join over 18 million learners to launch, switch or build upon your career, all at your own pace, across a wide range of topic areas.

Start Learning now