Creating and Running a Code Snippet - Replit
00:00
Let’s get started using Repl.it to create and run our little code snippets—the for
loop that we’ve been working with. Now I’ll head over to their website—this is simply repl.it.
00:12 REPL stands for Read-Evaluate-Print Loop. This is what happens when you have your Python console open and you type something in there—it reads, evaluates, prints, and then loops back to the beginning.
00:22 So that is what this is based on, where the name comes from. And again, there is other online coding environments but the idea is the same, and this is a very nice one, actually. On the main page, now I’m going to show you that you don’t even have to have an account.
00:36 I’m not even logged in right now and I can go and click on make a new repl. Then it suggests me languages. I can just type it in and say, “python”, I want to use Python—not the legacy Python but just Python 3.
00:50 And then I create this Repl. That’s really all I need to do, and here I have my integrated development environment ready for me in the cloud. Here you can see, we have a file structure here on the side.
01:02
I’m going to put this away for now. I don’t want to deal with that right now. All I’m interested in is my place for writing the script—the text editor—and then the output in the terminal. Let’s go ahead. I have this main.py
, and let’s go and write this loop for x in
—and you see, we have again autocompletion, so it’s suggesting me to put range()
in here, which is what I want to do, so I just press Enter and put in here 5
. Also, very nice—we get all these suggestions.
01:30
You can read about the documentation on this function right in here. It’s great for learning as well. Well, what do we want to do? We said x = x**2
(x
squared),
01:42 then print it out. And that’s it! Let’s see if we can make this a bit bigger.
01:49 So, I don’t think there’s really a way of increasing the font size in here, but you can increase the browser font size in general, just pressing Command + Plus. It makes everything a bit bigger.
01:59 That’s just zooming in on a browser, right? Well, maybe that makes it a bit better visible for us. So, I have this loop in here and now I want to run it, so pressing up here executes it, and we have our results over there in the terminal.
02:16 It looks a bit different than the ones we looked at before. We have the script editor here on the left side and then the terminal here on the right side, but essentially it’s the same.
02:24 And it’s pretty nice that you don’t have to install anything for that. You simply go to a certain URL, create this Repl, don’t even have to sign up—
02:32 even though you can—and then all the Repls you create get saved and you can re-access them. But you have a unique URL up here that you can share with your friends.
02:41 They can access it and they can clone the Repl and continue working from the code that you wrote. So it’s a great way of working interactively and working collaboratively on some code. It’s easy to share. And that’s really the main thing about it.
02:55 We don’t need to install anything, we can just go there, create a Repl, decide what’s the language that we’re using—we’re using Python—write the code here on the left side, press this to run it, and then we can also share. So here, for example—the link, copy it, send it to your friends, and that’s it! They can access it.
03:13 They can run the code, see the output. It also has lots of other features. It’s actually a very sophisticated environment. And in the next video, we’re going to take a look at how does debugging work in an online environment like this one. See you there.
Become a Member to join the conversation.