<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Saul Costa</title>
    <description>The latest articles on Forem by Saul Costa (@scosta).</description>
    <link>https://forem.com/scosta</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F67123%2F0a735df9-f72f-4ec7-9f35-7c49c89b19c8.jpg</url>
      <title>Forem: Saul Costa</title>
      <link>https://forem.com/scosta</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/scosta"/>
    <language>en</language>
    <item>
      <title>Free coding courses through May!</title>
      <dc:creator>Saul Costa</dc:creator>
      <pubDate>Tue, 28 Apr 2020 18:26:26 +0000</pubDate>
      <link>https://forem.com/nexttech/free-coding-courses-through-may-12l9</link>
      <guid>https://forem.com/nexttech/free-coding-courses-through-may-12l9</guid>
      <description>&lt;p&gt;While you are home staying safe and keeping others safe, we want to make sure you have everything you need to keep learning coding and working on your projects. That's why a couple of weeks ago, we decided to make all of Next Tech's interactive &lt;a href="https://next.tech/xyz/for-devs"&gt;courses&lt;/a&gt; and &lt;a href="https://next.tech/xyz/for-devs"&gt;sandboxes&lt;/a&gt; free through April. Now, we're extending that through May!&lt;/p&gt;

&lt;p&gt;Staying home is incredibly important, but so is your ability to continue learning new skills. With Next Tech courses, you can learn &lt;strong&gt;coding&lt;/strong&gt;, &lt;strong&gt;web development&lt;/strong&gt;, &lt;strong&gt;data science&lt;/strong&gt;, and other skills directly from your browser with hands-on projects. No downloads required!&lt;/p&gt;

&lt;p&gt;Here are some of the top courses on Next Tech right now that other dev.to readers have enjoyed:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://c.next.tech/3eyUVKy"&gt;Database Fundamentals&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://c.next.tech/2VpD3dF"&gt;Beginning Object-Oriented Programming in JavaScript&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://c.next.tech/3czRCko"&gt;SQL for Data Analytics&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://c.next.tech/2VJt6Xd"&gt;Beginning React&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://c.next.tech/3eIIn3x"&gt;Python Open Weather Map&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://c.next.tech/2KhGc93"&gt;Beginning Swift&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://c.next.tech/34T4e3B"&gt;Introduction to Python&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Just need a spot to write some code right now? Here are a few:&lt;/p&gt;

&lt;h3&gt;
  
  
  Python
&lt;/h3&gt;

&lt;p&gt;&lt;iframe src="https://next.tech/projects/ec1a199d7e29/embed"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Launch a Python sandbox &lt;a href="//nt.dev/python"&gt;here&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Java
&lt;/h3&gt;

&lt;p&gt;&lt;iframe src="https://next.tech/projects/fdce42bd458f/embed"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Launch a Java sandbox &lt;a href="//nt.dev/java11"&gt;here&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Swift
&lt;/h3&gt;

&lt;p&gt;&lt;iframe src="https://next.tech/projects/e6a7c0be19cc/embed"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Launch a Swift sandbox &lt;a href="//nt.dev/swift"&gt;here&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;And of course, if you're a student, you can apply for the &lt;a href="https://next.tech/github-students"&gt;GitHub Student Developer Pack&lt;/a&gt; and get one year of Next Tech access completely free!&lt;/p&gt;

&lt;p&gt;We hope that this free month of access will help you keep learning and building from home. Stay safe!&lt;/p&gt;

&lt;p&gt;Best wishes from Next Tech.&lt;/p&gt;

</description>
      <category>free</category>
      <category>codenewbie</category>
      <category>learning</category>
      <category>nexttech</category>
    </item>
    <item>
      <title>3 Reasons Why the GitHub Student Developer Pack Is So Awesome</title>
      <dc:creator>Saul Costa</dc:creator>
      <pubDate>Thu, 22 Aug 2019 14:05:38 +0000</pubDate>
      <link>https://forem.com/scosta/3-reasons-why-the-github-student-developer-pack-is-so-awesome-b0j</link>
      <guid>https://forem.com/scosta/3-reasons-why-the-github-student-developer-pack-is-so-awesome-b0j</guid>
      <description>&lt;p&gt;Yesterday, &lt;a href="https://next.tech" rel="noopener noreferrer"&gt;Next Tech&lt;/a&gt; launched as part of &lt;a href="https://education.github.com/pack" rel="noopener noreferrer"&gt;GitHub's Student Developer Pack&lt;/a&gt;. I'm super excited to be a part of it, but man, the Pack is just an incredible resource for students. Totally something I wish I'd had when I was in school!&lt;/p&gt;

&lt;p&gt;So here's a quick mind dump of why it's so awesome (IMO) and a few reasons you should definitely check it out if you're a student.&lt;/p&gt;

&lt;h1&gt;
  
  
  Reason #1: $45,000 of FREE stuff! 🤯
&lt;/h1&gt;

&lt;p&gt;The Pack gets you access to almost $45,000 worth of resources!! I'm not 100% sure how they calculate this, but GitHub says it, so it must be true:&lt;/p&gt;

&lt;p&gt;&lt;iframe class="tweet-embed" id="tweet-1163844898933628930-863" src="https://platform.twitter.com/embed/Tweet.html?id=1163844898933628930"&gt;
&lt;/iframe&gt;

  // Detect dark theme
  var iframe = document.getElementById('tweet-1163844898933628930-863');
  if (document.body.className.includes('dark-theme')) {
    iframe.src = "https://platform.twitter.com/embed/Tweet.html?id=1163844898933628930&amp;amp;theme=dark"
  }



&lt;/p&gt;

&lt;p&gt;College was expensive even when I went long ago (in 2010...), and I know it's only gotten more so since then. So I think it's great that the Pack helps students out with this by giving them all these great resources, enabling them to build awesome software without the cost of tools standing in their way.&lt;/p&gt;

&lt;p&gt;The Pack DOUBLED in size this school year, which is just incredible. There are now 41 awesome deals! I've covered a few of my favorites below, but you should definitely check them all out.&lt;/p&gt;

&lt;h1&gt;
  
  
  Reason #2: So many great deals! 😍
&lt;/h1&gt;

&lt;p&gt;The Pack is really diverse. There are so many different things you can build with it! Here are a few of my favorite deals (other than Next Tech's, of course!):&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fvpwev7jyr14wps8gaa12.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fvpwev7jyr14wps8gaa12.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  DigitalOcean
&lt;/h2&gt;

&lt;p&gt;I love DigitalOcean because they've done an excellent job of walking the line between a powerful cloud hosting platform and an easy to use tool. As someone who has also used Amazon Web Services, Google Cloud, and Microsoft Azure over the years, I've really come to appreciate simplicity in cloud offerings.&lt;/p&gt;

&lt;p&gt;Services like AWS and the others can do a LOT more than DigitalOcean, but in reality, you don't need that right now! Heck, Next Tech could probably even run it's entire site on top of DigitalOcean, if we wanted to (right now we're on Google Cloud). So it's plenty powerful.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fsotxrd1nv4pyu5jaus8f.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fsotxrd1nv4pyu5jaus8f.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Heroku
&lt;/h2&gt;

&lt;p&gt;I first used Heroku years ago when I started writing web apps. It's even simpler than DigitalOcean to get up your first app, so it's a great resource when you're first getting started and just want to get your ideas up there (into the cloud).&lt;/p&gt;

&lt;p&gt;It is good to eventually transition to something like DigitalOcean in my opinion, because you'll get much more experience with running your own servers if you do. But for just getting up a project for a class or as a first web app, Heroku is great!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F7ghrev5tywgj3fa1m4gh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F7ghrev5tywgj3fa1m4gh.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  SendGrid
&lt;/h2&gt;

&lt;p&gt;This is a tool we use at Next Tech for sending emails. It allows you to send a massive number of emails, which is really handy when doing something like sending confirmation emails to new users. If you just use a personal email for this, you'll eventually get rate limited, and need a tool like SendGrid to get around this.&lt;/p&gt;

&lt;p&gt;You can also use SendGrid's email template designer right on their website, which makes your emails look professional without that much effort on your part. Once you're done, you send these emails using SendGrid's API, which makes it very flexible, and also gets you some great experience with APIs!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fawz6w4n1o9ku5br7kk5b.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fawz6w4n1o9ku5br7kk5b.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Sentry
&lt;/h2&gt;

&lt;p&gt;Sentry will alert you when a user of your application gets an error, and then provide you with useful debugging information you can use to fix it. They also do useful grouping of errors which can help you see what the most important bugs are for you to focus on.&lt;/p&gt;

&lt;p&gt;I haven't used Sentry before, but we use a very similar tool (Bugsnag) to monitor for errors in our application. When I first started building web apps, I didn't know much about error monitoring, but after starting to use it, you'll never stop.&lt;/p&gt;

&lt;p&gt;As you can see above, the Pack gets you 500,000 events/month, where each "event" is an error being triggered. For what you build while in school, this should be more than enough!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fku9iu5rw74kkleo5st3n.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fku9iu5rw74kkleo5st3n.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Termius
&lt;/h2&gt;

&lt;p&gt;Termius merges your SSH sessions across Linux, OS X, Windows, iOS, and Android. If you don't know already, SSH stands for "Secure Shell", and allows you to access your computer remotely using either a password or a private key (recommended).&lt;/p&gt;

&lt;p&gt;I haven't used Termius yet (I just learned about it yesterday, when they got added to the Pack), but I plan on doing it ASAP. I use another tool to do something similar from my phone, but this looks like it may work much better!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F8n2ky9ghesckzhxl1g7a.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F8n2ky9ghesckzhxl1g7a.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  .tech Domains
&lt;/h2&gt;

&lt;p&gt;Last but not least, the fancy .tech domains. The Pack gets you one free .tech domain for one year. As the owner of next.tech, I may be a bit biased, but I think this deal is really cool.&lt;/p&gt;

&lt;h1&gt;
  
  
  Reason #3: The Pack is really well done 💎
&lt;/h1&gt;

&lt;p&gt;GitHub works closely with the Pack members. This may not seem like that great of a reason, but having just gone through the onboarding process with them, I have learned a few things from working with the Pack team:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;They really care about what they're doing. So as a student, you can rest assured that they have your best interests at heart!&lt;/li&gt;
&lt;li&gt;They make sure that each new deal brings a lot of value to the Pack for students. This makes it well worth your time to get access to the Pack.&lt;/li&gt;
&lt;li&gt;They work hard to ensure that each Pack offer makes it easy for students to redeem their offer.&lt;/li&gt;
&lt;/ol&gt;

&lt;h1&gt;
  
  
  How to Get the Pack 🚀
&lt;/h1&gt;

&lt;p&gt;Getting started with the Pack is really easy. Just head &lt;a href="https://education.github.com/pack/join" rel="noopener noreferrer"&gt;here&lt;/a&gt; to get started! They'll walk you through a quick approval process, and then you can get started with redeeming your offers.&lt;/p&gt;

&lt;h1&gt;
  
  
  Next Tech's promotion 👩‍💻👨‍💻
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F3h28ktxbe29tbej05q0h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F3h28ktxbe29tbej05q0h.png" alt="Alt Text"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Once you have your Pack, if you're interested in learning a new tech skill or want to write some code online, come grab your free year on &lt;a href="https://next.tech" rel="noopener noreferrer"&gt;Next Tech&lt;/a&gt;. All you have to do is sign up with GitHub.&lt;/p&gt;

&lt;h1&gt;
  
  
  Also...
&lt;/h1&gt;

&lt;p&gt;What's your favorite deal? Let me know in the comments! As the CEO of an education startup, I'd love to see what most interests you as a student.&lt;/p&gt;

&lt;p&gt;TTFN!&lt;/p&gt;

</description>
      <category>github</category>
      <category>beginners</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Free coding environments and interactive courses!</title>
      <dc:creator>Saul Costa</dc:creator>
      <pubDate>Tue, 20 Aug 2019 16:56:20 +0000</pubDate>
      <link>https://forem.com/nexttech/free-coding-environments-and-interactive-courses-1oaf</link>
      <guid>https://forem.com/nexttech/free-coding-environments-and-interactive-courses-1oaf</guid>
      <description>&lt;p&gt;Hello Dev.to readers! 👋&lt;/p&gt;

&lt;p&gt;We have some exciting news to share with you: we’ve partnered with the &lt;a href="https://education.github.com/pack"&gt;GitHub Student Developer Pack&lt;/a&gt; to make it easier for students everywhere to learn programming and write your own programs!&lt;/p&gt;

&lt;p&gt;What does this mean for you as a student? Well, students now get access to Next Tech’s course library and sandboxed computing environments for free for a whole year! Typically this would cost $228, but with our offer, you can save that money for a ☔ day (or a ☀️ one, for that matter!).&lt;/p&gt;

&lt;p&gt;As former and current computing students ourselves, we know that setting up your computer for programming can be tough. It’s especially frustrating when you can see the solution to your homework or next project in your head, but your computer just isn’t working.&lt;/p&gt;

&lt;p&gt;This is the exact problem Next Tech was founded to solve! Instead of having to do this set up yourself, you can launch a real programming environment in a couple of seconds and use it directly from your browser. 🤯&lt;/p&gt;

&lt;p&gt;With these programming environments, you can learn programming, web development, data science, and more with our &lt;a href="https://next.tech/xyz/for-devs"&gt;library of courses&lt;/a&gt;. Or, you can start from scratch and build an entire project using some &lt;a href="https://next.tech/sandbox/for-devs"&gt;coding sandboxes&lt;/a&gt;. All with no downloads, fast access from any computer anywhere, and now, free for you. 😊&lt;/p&gt;

&lt;p&gt;Sound like fun? Head over to the &lt;a href="https://education.github.com/pack"&gt;GitHub Student Developer Pack&lt;/a&gt; page to claim yours, or if you already have the Pack, come check out &lt;a href="https://next.tech/github-students"&gt;Next Tech&lt;/a&gt;!&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>codenewbie</category>
      <category>students</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Build a Blackjack Command Line Game</title>
      <dc:creator>Saul Costa</dc:creator>
      <pubDate>Tue, 23 Jul 2019 16:16:21 +0000</pubDate>
      <link>https://forem.com/nexttech/build-a-blackjack-command-line-game-3o4b</link>
      <guid>https://forem.com/nexttech/build-a-blackjack-command-line-game-3o4b</guid>
      <description>&lt;p&gt;In this tutorial, we'll cover how to build a command line game for playing Blackjack using Python! You'll get to build the game from start to finish, and when you're done, you'll have a fully functioning game to play from the command line.&lt;/p&gt;

&lt;p&gt;While building the game, we'll explore a few handy Python concepts, such as object-oriented programming using classes and how to manage a game loop. This tutorial is also extracted from an entire course on building a Blackjack game using a graphical user environment (GUI), which you can check out &lt;a href="https://c.next.tech/30VhCRH" rel="noopener noreferrer"&gt;here&lt;/a&gt; if you're interested.&lt;/p&gt;

&lt;p&gt;Sound fun? Let's do it!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpouc05qohzfdvxtwlgn3.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpouc05qohzfdvxtwlgn3.gif" width="820" height="696"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  What is Blackjack?
&lt;/h1&gt;

&lt;p&gt;Blackjack is a gambling game that requires only a deck of cards. The goal of the game is to get as close as possible to a hand worth 21 points as the dealer flips over your cards – but go over and you're out!&lt;/p&gt;

&lt;p&gt;In Blackjack, numbered cards (2 through 10) are worth their face value, picture cards (jack, queen, and king) are worth 10, and an ace is worth either 1 or 11 depending on your other cards. To start a hand, players place their bets and are dealt two cards face up. They can choose to "hit" (receive another card) or "stick" (stay with their current hand) as they attempt to get as close as possible to 21. If they chose to hit and go over 21, they "bust" and lose the hand (and the money they bet!).&lt;/p&gt;

&lt;p&gt;Players face off against the dealer, who starts with one card face down and one face up. When all players have chosen to stick or have busted, the dealer then flips over their hidden card and either hits or sticks, their goal being to get a higher hand than any of the players.&lt;/p&gt;

&lt;p&gt;If the dealer busts, they pay out the value of each player's wager to that player, provided that the player hasn't already busted. They also need to pay out if they don't get a higher hand than a player.&lt;/p&gt;

&lt;p&gt;There are a lot of other rules (of course!) that you can &lt;a href="https://bicyclecards.com/how-to-play/blackjack/" rel="noopener noreferrer"&gt;read up on&lt;/a&gt; if you're interested, but the above is everything you need to know to build this game.&lt;/p&gt;

&lt;p&gt;Okay, let's get started with some coding!&lt;/p&gt;

&lt;h1&gt;
  
  
  Installing Python
&lt;/h1&gt;

&lt;p&gt;If you don't already have Python installed on your computer, you'll need to do so based on the instructions &lt;a href="https://realpython.com/installing-python/" rel="noopener noreferrer"&gt;here&lt;/a&gt;. If you'd rather avoid that, you can grab an online coding sandbox with Python and other necessary libraries pre-installed &lt;a href="https://nt.dev/python" rel="noopener noreferrer"&gt;here&lt;/a&gt; (sign in required).&lt;/p&gt;

&lt;h1&gt;
  
  
  Defining Classes
&lt;/h1&gt;

&lt;p&gt;Before we begin coding our blackjack game, it's important we cover how we'll use object-oriented programming, since we will need to utilize classes for our game.&lt;/p&gt;

&lt;p&gt;We will begin by defining the classes that will be used in order to separate out different aspects of the game of blackjack. We will model three of the components of the game:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;Card&lt;/code&gt;: A basic playing card. The card belongs to a suit (hearts ♥, diamonds ♦, spades ♠, or clubs ♣) and is worth a certain value.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;Deck&lt;/code&gt;: A collection of cards. The deck shrinks as cards are drawn and contains 52 unique cards.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;Hand&lt;/code&gt;: Each player's assigned cards. A hand is what defines each player's score and thus who wins.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let's begin with the simplest concept: the &lt;code&gt;Card&lt;/code&gt;.&lt;/p&gt;

&lt;h1&gt;
  
  
  The &lt;code&gt;Card&lt;/code&gt; class
&lt;/h1&gt;

&lt;p&gt;The &lt;code&gt;Card&lt;/code&gt; class will be the first class we define, as both of our other classes will need to use it. Create a Python file called &lt;em&gt;blackjack.py&lt;/em&gt;, then add the following code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;random&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Card&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;__init__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;suit&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;suit&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;suit&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;__repr__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt; of &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;join&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;suit&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The only import we will need for our game is the &lt;code&gt;random&lt;/code&gt; module. This will allow us to shuffle our virtual deck of cards at the beginning of every game.&lt;/p&gt;

&lt;p&gt;Our first class will be one representing the playing cards. Each card will have a suit (hearts, diamonds, spades, and clubs) and a value (ace through king). We define the &lt;code&gt;__repr__&lt;/code&gt; function in order to change how the card is displayed when we call &lt;code&gt;print&lt;/code&gt; on it. Our function will return the value and the suit, for example, &lt;code&gt;King of Spades&lt;/code&gt;. That's all we need to do for a &lt;code&gt;Card&lt;/code&gt;!&lt;/p&gt;

&lt;p&gt;Next up, we need to create a &lt;code&gt;Deck&lt;/code&gt; of these &lt;code&gt;Card&lt;/code&gt; classes.&lt;/p&gt;

&lt;h1&gt;
  
  
  The &lt;code&gt;Deck&lt;/code&gt; class
&lt;/h1&gt;

&lt;p&gt;The &lt;code&gt;Deck&lt;/code&gt; will need to contain 52 unique cards and must be able to shuffle itself. It will also need to be able to deal cards and decrease in size as cards are removed. Create the &lt;code&gt;Deck&lt;/code&gt; class in the &lt;em&gt;blackjack.py&lt;/em&gt; file using the below code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Deck&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;__init__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;cards&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nc"&gt;Card&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;v&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Spades&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Clubs&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Hearts&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                      &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Diamonds&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;v&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;A&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;2&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;3&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;4&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;5&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;6&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
                      &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;7&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;8&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;9&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;10&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;J&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Q&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;K&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]]&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;shuffle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;cards&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;random&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;shuffle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;cards&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;deal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;cards&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;cards&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;pop&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When creating an instance of the &lt;code&gt;Deck&lt;/code&gt;, we simply need to have a collection of every possible card. We achieve this by using a list comprehension containing lists of every suit and value. We pass each combination over to the initialization for our &lt;code&gt;Card&lt;/code&gt; class to create 52 unique &lt;code&gt;Card&lt;/code&gt; instances.&lt;/p&gt;

&lt;p&gt;Our &lt;code&gt;Deck&lt;/code&gt; will need to be able to be shuffled so that every game is different. We use the &lt;code&gt;shuffle&lt;/code&gt; function in the &lt;code&gt;random&lt;/code&gt; library to do this for us (how fitting). To avoid any potential errors, we will only shuffle a deck which still has two or more cards in it, since shuffling one or zero cards is pointless.&lt;/p&gt;

&lt;p&gt;After shuffling, we will need to deal cards too. We utilize the &lt;code&gt;pop&lt;/code&gt; function of a list (which is the data structure holding our cards) to return the top card and remove it from the deck so that it cannot be dealt again.&lt;/p&gt;

&lt;p&gt;That's it for the &lt;code&gt;Deck&lt;/code&gt; class! The final utility class to be created for our game to work is the &lt;code&gt;Hand&lt;/code&gt;. All players have a hand of cards, and each hand is worth a numerical value based on the cards it contains.&lt;/p&gt;

&lt;h1&gt;
  
  
  The &lt;code&gt;Hand&lt;/code&gt; class
&lt;/h1&gt;

&lt;p&gt;A &lt;code&gt;Hand&lt;/code&gt; class will need to contain cards just like the &lt;code&gt;Deck&lt;/code&gt; class does. It will also be assigned a value by the rules of the game based on which cards it contains. Since the dealer's hand should only display one card, we also keep track of whether the &lt;code&gt;Hand&lt;/code&gt; belongs to the dealer to accommodate this rule.&lt;/p&gt;

&lt;p&gt;Start with the below to create the &lt;code&gt;Hand&lt;/code&gt; class in the &lt;em&gt;blackjack.py&lt;/em&gt; file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Hand&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;__init__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;dealer&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;False&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;dealer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;dealer&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;cards&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;add_card&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;card&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;cards&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;card&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Much like the &lt;code&gt;Deck&lt;/code&gt;, a &lt;code&gt;Hand&lt;/code&gt; will hold its cards as a list of &lt;code&gt;Card&lt;/code&gt; instances. When adding a card to the hand, we simply add the &lt;code&gt;Card&lt;/code&gt; instance to our &lt;code&gt;cards&lt;/code&gt; list.&lt;/p&gt;

&lt;p&gt;Within the &lt;code&gt;Hand&lt;/code&gt; class, calculating the currently held &lt;code&gt;cards&lt;/code&gt; value is where the rules of the game come into play the most:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;calculate_value&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
        &lt;span class="n"&gt;has_ace&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;False&lt;/span&gt;
        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;card&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;cards&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;card&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;isnumeric&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
                &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="nf"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;card&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;card&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;A&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                    &lt;span class="n"&gt;has_ace&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;
                    &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;11&lt;/span&gt;
                &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                    &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;

        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;has_ace&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;21&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt; &lt;span class="o"&gt;-=&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;get_value&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;calculate_value&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;You may note that the above code is already indented. This is intentional and done below too! This way, you don't need to perform the indents yourself and can focus on reading the instructions and code instead of chasing down whitespace errors.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;In this code, we first initialize the value of the hand to &lt;code&gt;0&lt;/code&gt; and assume the player does not have an ace (since this is a special case).&lt;/p&gt;

&lt;p&gt;Then, we loop through the &lt;code&gt;Card&lt;/code&gt; instances and try to add their value as a number to the player's total, using the following logic:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;If the card's value is numerical, we add its value to the value of this hand (&lt;code&gt;self.value&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;If it is not numerical, we check to see whether the card is an ace. If it is, we add &lt;code&gt;11&lt;/code&gt; to the hand's value and set the &lt;code&gt;has_ace&lt;/code&gt; flag to &lt;code&gt;True&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;If it is not an ace, we simply add &lt;code&gt;10&lt;/code&gt; to the value of the hand.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Once this is done, we check to see if there was an ace and the increase of &lt;code&gt;11&lt;/code&gt; points brought the hand's value over &lt;code&gt;21&lt;/code&gt;. If so, we make the ace worth &lt;code&gt;1&lt;/code&gt; point instead by subtracting &lt;code&gt;10&lt;/code&gt; from the hand's value.&lt;/p&gt;

&lt;p&gt;Now, we need some way for the game to display each hand's cards, so we use a simple function to print each card in the hand, and the value of the player's hand too. The dealer's first card is face down, so we print &lt;code&gt;hidden&lt;/code&gt; instead:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;display&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;dealer&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;hidden&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;cards&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
        &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;card&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;cards&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;card&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Value:&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get_value&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now that we have all of our underlying data structures written, it's time for the main game loop!&lt;/p&gt;

&lt;h1&gt;
  
  
  The Game Loop
&lt;/h1&gt;

&lt;p&gt;We will define the game's main loop within its &lt;code&gt;play&lt;/code&gt; method, so that to start a game, you will simply need to create an instance of the &lt;code&gt;Game&lt;/code&gt; class and call &lt;code&gt;.play()&lt;/code&gt; on it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Game&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;__init__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;pass&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;play&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;playing&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;

        &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="n"&gt;playing&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;deck&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Deck&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
            &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;deck&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;shuffle&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

            &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;player_hand&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Hand&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
            &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;dealer_hand&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Hand&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;dealer&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

            &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
                &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;player_hand&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add_card&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;deck&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;deal&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
                &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;dealer_hand&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add_card&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;deck&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;deal&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;

            &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Your hand is:&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;player_hand&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;display&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
            &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
            &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Dealer&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;s hand is:&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;dealer_hand&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;display&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above code is pretty lengthy, so let's break it down:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;We start off our loop with a Boolean (&lt;code&gt;playing&lt;/code&gt;) which will be used to track whether or not we are still playing the game.&lt;/li&gt;
&lt;li&gt;If we are, we need a shuffled &lt;code&gt;Deck&lt;/code&gt; and two &lt;code&gt;Hand&lt;/code&gt; instances—one for the dealer and one for the player. &lt;/li&gt;
&lt;li&gt;We use the &lt;code&gt;range&lt;/code&gt; function to deal two cards each to the player and the dealer. Our &lt;code&gt;deal&lt;/code&gt; method will return a &lt;code&gt;Card&lt;/code&gt; instance, which is passed to the &lt;code&gt;add_card&lt;/code&gt; method of our &lt;code&gt;Hand&lt;/code&gt; instances.&lt;/li&gt;
&lt;li&gt;Finally, we display the hands to our player. We can use the &lt;code&gt;display&lt;/code&gt; method on our &lt;code&gt;Hand&lt;/code&gt; instances to print this to the screen.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This marks the end of the code that needs to run at the beginning of every new game. Now, we enter a loop that will run until a winner is decided. We again control this with a Boolean (&lt;code&gt;game_over&lt;/code&gt;):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;            &lt;span class="n"&gt;game_over&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;False&lt;/span&gt;

            &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;game_over&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="n"&gt;player_has_blackjack&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;dealer_has_blackjack&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;check_for_blackjack&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Before continuing, we first need to check for blackjack. If either player has been dealt an ace and a picture card, their hand will total &lt;code&gt;21&lt;/code&gt;, so they automatically win. Let's create the method to do this (under the &lt;code&gt;play&lt;/code&gt; method):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;check_for_blackjack&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;player&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;False&lt;/span&gt;
        &lt;span class="n"&gt;dealer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;False&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;player_hand&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get_value&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;21&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;player&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;dealer_hand&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get_value&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;21&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;dealer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;

        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;player&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;dealer&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We need to keep track of which player may have blackjack, so we will keep a Boolean for the player (&lt;code&gt;player&lt;/code&gt;) and the dealer (&lt;code&gt;dealer&lt;/code&gt;).&lt;/p&gt;

&lt;p&gt;Next, go back to the &lt;code&gt;while not game_over&lt;/code&gt; loop inside the &lt;code&gt;play()&lt;/code&gt; method. We need to check whether either hand totals &lt;code&gt;21&lt;/code&gt;, which we will do using two &lt;code&gt;if&lt;/code&gt; statements. If either has a hand value of &lt;code&gt;21&lt;/code&gt;, their Boolean is changed to &lt;code&gt;True&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;If either of the Booleans are &lt;code&gt;True&lt;/code&gt;, then we have a winner, and will print the winner to the screen and &lt;code&gt;continue&lt;/code&gt;, thus breaking us out of the game loop. To accomplish this, add the below directly underneath the &lt;code&gt;player_has_blackjack, dealer_has_blackjack = self.check_for_blackjack()&lt;/code&gt; line of code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;                &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;player_has_blackjack&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="n"&gt;dealer_has_blackjack&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                    &lt;span class="n"&gt;game_over&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;
                    &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;show_blackjack_results&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
                        &lt;span class="n"&gt;player_has_blackjack&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;dealer_has_blackjack&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                    &lt;span class="k"&gt;continue&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We must once again pause to create the method &lt;code&gt;show_blackjack_results()&lt;/code&gt;, which will print the winner to the screen. We do this by adding the code below underneath the &lt;code&gt;check_for_blackjack&lt;/code&gt; method:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;show_blackjack_results&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;player_has_blackjack&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;dealer_has_blackjack&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;player_has_blackjack&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;dealer_has_blackjack&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Both players have blackjack! Draw!&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

        &lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="n"&gt;player_has_blackjack&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;You have blackjack! You win!&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

        &lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="n"&gt;dealer_has_blackjack&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Dealer has blackjack! Dealer wins!&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If neither player had blackjack, the game loop will continue.&lt;/p&gt;

&lt;p&gt;The player can now make a choice—whether or not to add more cards to their hand (hit) or submit their current hand (stick). To do this, add the below to the &lt;code&gt;play&lt;/code&gt; method:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;                &lt;span class="n"&gt;choice&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;input&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Please choose [Hit / Stick] &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;lower&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
                &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="n"&gt;choice&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;h&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;s&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;hit&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;stick&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]:&lt;/span&gt;
                    &lt;span class="n"&gt;choice&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;input&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Please enter &lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;hit&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt; or &lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;stick&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt; (or H/S) &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;lower&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We use the &lt;code&gt;input&lt;/code&gt; function to collect a choice from the user. This will always return us a string containing the text the user typed into the command line.&lt;/p&gt;

&lt;p&gt;Since we have a string, we can cast the user's input to lowercase using the &lt;code&gt;lower&lt;/code&gt; function to avoid having to check combinations of upper case and lower case when parsing their reply.&lt;/p&gt;

&lt;p&gt;If their input is not recognized, we will simply keep asking for it again until it is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;                &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;choice&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;hit&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;h&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]:&lt;/span&gt;
                    &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;player_hand&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add_card&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;deck&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;deal&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
                    &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;player_hand&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;display&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Should the player choose to hit, they will need to add an extra card to their hand. This is done in the same way as before with the &lt;code&gt;deal()&lt;/code&gt; and &lt;code&gt;add_card()&lt;/code&gt; methods.&lt;/p&gt;

&lt;p&gt;Since their total has changed, we will now need to check whether they are over the allowed limit of &lt;code&gt;21&lt;/code&gt;. Let's define a method that does this now:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;player_is_over&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;player_hand&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get_value&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;21&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This method simply checks whether the player's hand value is over &lt;code&gt;21&lt;/code&gt; and returns the information as a Boolean.&lt;/p&gt;

&lt;p&gt;Now, back in the &lt;code&gt;play&lt;/code&gt; method, add the following inside the &lt;code&gt;if choice in ['hit', 'h']&lt;/code&gt; block:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;                    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;player_is_over&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
                        &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;You have lost!&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                        &lt;span class="n"&gt;game_over&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If the player’s hand has a value over &lt;code&gt;21&lt;/code&gt;, they have lost, so the game loop needs to break and we set &lt;code&gt;game_over&lt;/code&gt; to &lt;code&gt;True&lt;/code&gt; (indicating that the dealer has won).&lt;/p&gt;

&lt;p&gt;Okay, now let's handle when the player decides to stick with their hand. If they do this, it's time for their score to be compared with the dealer's. To do this, add the below aligned with the &lt;code&gt;if choice in ['hit', 'h']&lt;/code&gt; statement:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;                &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                    &lt;span class="n"&gt;player_hand_value&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;player_hand&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get_value&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
                    &lt;span class="n"&gt;dealer_hand_value&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;dealer_hand&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get_value&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

                    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Final Results&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Your hand:&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;player_hand_value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Dealer&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;s hand:&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;dealer_hand_value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

                    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;player_hand_value&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;dealer_hand_value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                        &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;You Win!&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                    &lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="n"&gt;player_hand_value&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;dealer_hand_value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                        &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Tie!&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                    &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                        &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Dealer Wins!&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                    &lt;span class="n"&gt;game_over&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We use the &lt;code&gt;else&lt;/code&gt; statement here because we have already established that the user's answer was either hit or stick, and we have just checked hit. This means we will only get into this block when the user wants to stick.&lt;/p&gt;

&lt;p&gt;The value of both the player's and the dealer's hand are printed to the screen to give the final results. We then compare the values of each hand to see which is higher.&lt;/p&gt;

&lt;p&gt;If the player's hand is a higher value than the dealer's, we print &lt;code&gt;You Win!&lt;/code&gt;. If the scores are equal, then we have a tie, so we print &lt;code&gt;Tie!&lt;/code&gt;. Otherwise, the dealer must have a higher hand than the player, so we show &lt;code&gt;Dealer wins!&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;That completes the logic required for a user to play a single game. Now, let's make it possible for them to play another game by adding the following at the end of the &lt;code&gt;play&lt;/code&gt; method, outside of the &lt;code&gt;while&lt;/code&gt; loop:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;            &lt;span class="n"&gt;again&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;input&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Play Again? [Y/N] &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="n"&gt;again&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;lower&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;y&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;n&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]:&lt;/span&gt;
                &lt;span class="n"&gt;again&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;input&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Please enter Y or N &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;again&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;lower&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;n&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Thanks for playing!&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                &lt;span class="n"&gt;playing&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;False&lt;/span&gt;
            &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="n"&gt;game_over&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;False&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We once again use the combination of &lt;code&gt;lower&lt;/code&gt; and a &lt;code&gt;while&lt;/code&gt; loop to ensure our answer is a &lt;code&gt;y&lt;/code&gt; or &lt;code&gt;n&lt;/code&gt;. If the player answers with &lt;code&gt;n&lt;/code&gt;, we thank them for playing and set our &lt;code&gt;playing&lt;/code&gt; Boolean to &lt;code&gt;False&lt;/code&gt;, thus breaking us out of the main game loop and ending the program. If not, they must have answered &lt;code&gt;y&lt;/code&gt;, so we set &lt;code&gt;game_over&lt;/code&gt; to &lt;code&gt;False&lt;/code&gt; and let our main loop run again. This will take us right back to the top at &lt;code&gt;self.deck = Deck()&lt;/code&gt; to set up a brand new game.&lt;/p&gt;

&lt;h1&gt;
  
  
  Running the Game
&lt;/h1&gt;

&lt;p&gt;We've completed the game! Now, it's time to run this code. To do this, we simply create an instance of the &lt;code&gt;Game&lt;/code&gt; class at the end of the file and call the &lt;code&gt;play()&lt;/code&gt; method:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;__name__&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;__main__&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;game&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Game&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="n"&gt;game&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;play&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we have a game, give it a play. You can start the game by typing &lt;code&gt;python3 blackjack.py&lt;/code&gt; into your command line (or pressing the blue "Run" button, if you're using the sandbox mentioned earlier).&lt;/p&gt;

&lt;p&gt;You should see something like the following printed onto your screen:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;workspace $ python3 blackjack.py
Your hand is:
A of Diamonds
5 of Clubs
Value: 16

Dealer's hand is:
hidden
A of Clubs
Please choose [Hit / Stick] H
A of Diamonds
5 of Clubs
10 of Hearts
Value: 16
Please choose [Hit / Stick] H
A of Diamonds
5 of Clubs
10 of Hearts
2 of Clubs
Value: 18
Please choose [Hit / Stick] S
Final Results
Your hand: 18
Dealer's hand: 16
You Win!
Play Again? [Y/N] N
Thanks for playing!
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Wrapping Up
&lt;/h1&gt;

&lt;p&gt;Congrats on working your way through this tutorial! In it, we covered how to build handy concepts like object-oriented programming, game flow design, and even the basics of Blackjack.&lt;/p&gt;

&lt;p&gt;If you got stuck, the complete solution for this project can be found &lt;a href="https://gist.github.com/saulcosta/13909e2e51f94ff7b37700c74b885ab6" rel="noopener noreferrer"&gt;here&lt;/a&gt;. You can also launch an online coding sandbox with it preloaded &lt;a href="https://next.tech/projects/94217701d98d/share?ref=ce315f8c" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Two limitations of this game are that the dealer will never hit and there is no concept of betting. Feel free to add these features yourself if you'd like! Because a dealer is required to hit or stick at certain hand values, you can develop a program that mimic the dealer exactly.&lt;/p&gt;

&lt;p&gt;You can also check out the &lt;a href="https://c.next.tech/30VhCRH" rel="noopener noreferrer"&gt;full course&lt;/a&gt; behind this tutorial, if you'd like!&lt;/p&gt;

</description>
      <category>tutorial</category>
      <category>python</category>
      <category>beginners</category>
      <category>oop</category>
    </item>
    <item>
      <title>Launch VS Code in online computing environments</title>
      <dc:creator>Saul Costa</dc:creator>
      <pubDate>Tue, 28 May 2019 21:26:40 +0000</pubDate>
      <link>https://forem.com/nexttech/launch-vs-code-in-online-computing-environments-2eim</link>
      <guid>https://forem.com/nexttech/launch-vs-code-in-online-computing-environments-2eim</guid>
      <description>&lt;p&gt;I'm excited to share that Next Tech has released alpha support for Visual Studio Code!&lt;/p&gt;

&lt;p&gt;VS Code is hands-down one of (if not) the best code editors out there. It's trounced others (like Sublime and Atom) in popularity in recent years, thanks to the incredible features Microsoft has added and the vast library of extensions tens of thousands of developers have created.&lt;/p&gt;

&lt;p&gt;Installing VS Code is pretty straightforward and you can do it yourself on your computer if you'd like. However, we've found that our hosted environments for Python, Node, Go, Haskell, and many other programming languages make it super easy to get started with a new programming project in just a few seconds.&lt;/p&gt;

&lt;p&gt;So we thought, wouldn't it be great if you could use these environments… and VS Code?!&lt;/p&gt;

&lt;p&gt;Well now, you can. This includes the ability to install extensions, change your settings, debug programs, push to GitHub, &lt;a href="https://c.next.tech/2JM6fqn"&gt;deploy to Azure&lt;/a&gt;, and much more.&lt;/p&gt;

&lt;p&gt;This guide walks you through how to get started with VS Code on Next Tech. If you just want to jump into a sandbox with VS Code, click &lt;a href="https://c.next.tech/2K59jNN"&gt;here&lt;/a&gt;. In a few seconds you'll have VS Code running in your browser:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--EAxj0Hki--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2A2b2JRNx3flF6h1OJCYO85A.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--EAxj0Hki--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2A2b2JRNx3flF6h1OJCYO85A.png" alt="img"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Or, read on for the details!&lt;/p&gt;

&lt;h1&gt;
  
  
  Why VS Code?
&lt;/h1&gt;

&lt;p&gt;Over the years we've received many requests for innovative features like code collaboration, debuggers, version control integration, and much more, but our focus is increasingly on our infrastructure offerings. As such, we see VS Code as being able to address a number of these requests as we continue to develop innovative infrastructure offerings.&lt;/p&gt;

&lt;p&gt;VS Code is also the most popular code editor by &lt;em&gt;far&lt;/em&gt;. Here's Stack Overflow's 2019 developer survey results for the most popular development environments:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--yheSukyt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2AoJqJ7ZvrI0J_YNjV2N2BYQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--yheSukyt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2AoJqJ7ZvrI0J_YNjV2N2BYQ.png" alt="img"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is also coming at a cost to other editors. Here's the Google Trends data for VS Code (blue) versus Sublime (red) and Atom (yellow):&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--JkNdk_lk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2AAgJiQ7tAv1SxjuQoQasE3w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--JkNdk_lk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2AAgJiQ7tAv1SxjuQoQasE3w.png" alt="img"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So we feel that our investment into integrating VS Code will be well worth it as we'll be able to provide a well-loved tool inside our infrastructure.&lt;/p&gt;

&lt;p&gt;This feature is currently in a very early alpha state (current limitations are documented &lt;a href="https://docs.next.tech/sandbox/vscode/alpha-status"&gt;here&lt;/a&gt;). However, in the coming months we'll be rolling out a more tightly integrated version and many other related improvements.&lt;/p&gt;

&lt;h2&gt;
  
  
  Here's what's currently supported:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Intelligent code completion (IntelliSense).&lt;/li&gt;
&lt;li&gt;Powerful debugging functionality.&lt;/li&gt;
&lt;li&gt;Numerous different ways to configure your interface (multiple tabs, zen mode, etc.).&lt;/li&gt;
&lt;li&gt;Integrated terminals.&lt;/li&gt;
&lt;li&gt;Multiple themes.&lt;/li&gt;
&lt;li&gt;VS Code's command line interface.&lt;/li&gt;
&lt;li&gt;…and many other extensions you can install.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Very soon, we'll also be adding support for:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;An integrated web browser.&lt;/li&gt;
&lt;li&gt;VS Code's Live Share feature, which allows you to collaborate with others in real-time.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For now, I hope you'll take a look and &lt;a href="https://feedback.next.tech/vscode"&gt;share your feedback&lt;/a&gt;!&lt;/p&gt;

&lt;h1&gt;
  
  
  Getting Started
&lt;/h1&gt;

&lt;p&gt;To get started, head over to the &lt;a href="https://c.next.tech/2KaW6Dp"&gt;sandbox launchpad&lt;/a&gt;. Once you're there, pick the language you'd like to use (this guide uses Golang), then check &lt;strong&gt;Use Visual Studio Code&lt;/strong&gt;, as shown below:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ymt11XlN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/0%2AypD_Mjn2_pMAr26r" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ymt11XlN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/0%2AypD_Mjn2_pMAr26r" alt="img"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You'll be shown a dialog that contains an explanation of the current limitations of this feature (also detailed at the end of this page). Just click the &lt;strong&gt;Sounds fun, let's go!&lt;/strong&gt; button and your sandbox will load with the VS Code interface:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--p_XO4UO4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/0%2AN00UlUcFrPKFaJ_3" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--p_XO4UO4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/0%2AN00UlUcFrPKFaJ_3" alt="img"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You may notice that VS Code is just another tab type in the sandbox interface. If you click the &lt;strong&gt;+&lt;/strong&gt; to create a new tab, you may notice that some options are now hidden:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s---k16HD3x--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/0%2Apo14izi2eqQHTPgp" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s---k16HD3x--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/0%2Apo14izi2eqQHTPgp" alt="img"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Eventually these will all be hidden as we integrate them directly inside of the VS Code interface.&lt;/p&gt;

&lt;p&gt;For the best experience, you can click the square in the top right corner of the VS Code interface to make VS Code full screen:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--GWk8NCJu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/0%2AlnyAclE7854mooun" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--GWk8NCJu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/0%2AlnyAclE7854mooun" alt="img"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To get started, you can click File, then New File:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--vQjvDs02--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/0%2Ah6bIGRBMQCVm31Gd" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vQjvDs02--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/0%2Ah6bIGRBMQCVm31Gd" alt="img"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;(note that the Ctrl+N will not work in the browser)&lt;/p&gt;

&lt;p&gt;Save your file as main.go, then put this code in it:&lt;/p&gt;

&lt;p&gt;Now, head over to the extensions marketplace and install the Go extension:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--COrssZpb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/0%2AmK-6xStVebIVo4sU" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--COrssZpb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/0%2AmK-6xStVebIVo4sU" alt="img"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;(you may need to press Ctrl+Shift+P, type “reload”, then select &lt;strong&gt;Developer: Reload Window&lt;/strong&gt; to get things working correctly)&lt;/p&gt;

&lt;p&gt;You'll be prompted in the   bottom right to install several packages. Go for it!&lt;/p&gt;

&lt;p&gt;You can try typing b in the code editor to see the intelligent autocomplete kicking in. Here, it sees that b is actually an array with 5 ints in it:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--NcHYjKzc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/0%2ARNAwfGAOP6J_4y_6" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--NcHYjKzc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/0%2ARNAwfGAOP6J_4y_6" alt="img"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can run code using the software normally installed in your sandbox. To run this file, click Terminal, then New Terminal:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--igAPB5PW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/0%2AYcYjtU6ehcZfrJt4" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--igAPB5PW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/0%2AYcYjtU6ehcZfrJt4" alt="img"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Then you can use the already installed go program from your sandbox:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ekzadLF_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/0%2AmV37hQpsML4xs4YG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ekzadLF_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/0%2AmV37hQpsML4xs4YG" alt="img"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And there you have it! You've just used VS Code in the cloud to write a Go program.&lt;/p&gt;

&lt;h1&gt;
  
  
  Feedback
&lt;/h1&gt;

&lt;p&gt;If you try this new feature, I'd love to hear what you think. Feel free to respond to this post or submit a ticket &lt;a href="https://feedback.next.tech/vscode"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Thanks for reading!&lt;/p&gt;

&lt;h1&gt;
  
  
  Shout-out
&lt;/h1&gt;

&lt;p&gt;This integration uses an adapted version of &lt;a href="https://github.com/cdr/code-server"&gt;this&lt;/a&gt; awesome open source project by Coder!&lt;/p&gt;

</description>
      <category>vscode</category>
      <category>microsoft</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Learn Python Interactively with These 5 Tutorials</title>
      <dc:creator>Saul Costa</dc:creator>
      <pubDate>Thu, 23 May 2019 22:13:23 +0000</pubDate>
      <link>https://forem.com/nexttech/learn-python-interactively-with-these-5-tutorials-47cg</link>
      <guid>https://forem.com/nexttech/learn-python-interactively-with-these-5-tutorials-47cg</guid>
      <description>&lt;p&gt;This post walks you through how to launch an online coding environment and then covers 5 tutorials for learning various Python skills. You can use your sandbox alongside these tutorials so you can learn by doing as you read!&lt;/p&gt;

&lt;p&gt;Let's get started!&lt;/p&gt;




&lt;h1&gt;
  
  
  Setup
&lt;/h1&gt;

&lt;p&gt;To get started, launch a Python sandbox on Next Tech by &lt;a href="https://c.next.tech/2JASxqq"&gt;clicking here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Then pick one of the sites from the list below, for example, &lt;a href="https://developers.google.com/edu/python/introduction"&gt;Google's Python Class&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;That link skips the install section of the class entirely, since your sandbox already has Python installed!&lt;/p&gt;

&lt;p&gt;This tutorial says you can use an interactive command line (launch by typing &lt;code&gt;python&lt;/code&gt; into your sandbox terminal) OR a file with Python code in it. To do the latter, just create a file in your sandbox (e.g. &lt;code&gt;main.py&lt;/code&gt;) and put your code in there. Click the blue &lt;strong&gt;Run&lt;/strong&gt; button to execute your program.&lt;/p&gt;

&lt;p&gt;As you read through the tutorial, you can click the copy icon in the top right of each code box to copy the code to your clipboard. Then, back in your sandbox, paste the code into your editor or command line.&lt;/p&gt;

&lt;p&gt;While the other tutorials may differ slightly, they all follow this general idea: take the code in the tutorial, and run it inside your sandbox. Let's take a look at all the tutorials!&lt;/p&gt;




&lt;h1&gt;
  
  
  #1: &lt;a href="https://developers.google.com/edu/python/introduction"&gt;Google's Python Class&lt;/a&gt;
&lt;/h1&gt;

&lt;p&gt;Google's Python Class is free and designed for people with some programming experience (i.e. know what a "variable" or "if statement" is) and want to learn Python. The class is actually used inside Google to introduce people to Python!&lt;/p&gt;

&lt;p&gt;The class includes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Written tutorials&lt;/li&gt;
&lt;li&gt;Videos&lt;/li&gt;
&lt;li&gt;Code exercises&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The class starts with basic Python concepts like strings and lists, working towards full programs that cover text files, processes, and http connections.&lt;/p&gt;




&lt;h1&gt;
  
  
  #2: &lt;a href="https://docs.python.org/3/tutorial/index.html"&gt;The Official Python Tutorial&lt;/a&gt;
&lt;/h1&gt;

&lt;p&gt;The Official Python Tutorial is provided by the Python Software Foundation that is the creator of the Python programming language.&lt;/p&gt;

&lt;p&gt;While the tutorial claims to not attempt to cover every single feature, it is extremely in-depth, and covers the following topics:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;An introduction to Python&lt;/li&gt;
&lt;li&gt;Program control flow&lt;/li&gt;
&lt;li&gt;Data structures&lt;/li&gt;
&lt;li&gt;Modules&lt;/li&gt;
&lt;li&gt;Input and output&lt;/li&gt;
&lt;li&gt;Errors and exceptions&lt;/li&gt;
&lt;li&gt;Classes&lt;/li&gt;
&lt;li&gt;Some of the Python standard libraries&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;After reading it, you will be able to read and write Python modules and programs and will be ready to learn more about the various Python library modules described in The Python Standard Library.&lt;/p&gt;




&lt;h1&gt;
  
  
  #3: &lt;a href="https://docs.python.org/3/tutorial/index.html"&gt;Official Flask Tutorial&lt;/a&gt;
&lt;/h1&gt;

&lt;p&gt;Flask is a Python microframework used for creating web applications. Their official tutorial covers:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Project layout&lt;/li&gt;
&lt;li&gt;Application setup&lt;/li&gt;
&lt;li&gt;Database integration&lt;/li&gt;
&lt;li&gt;Blueprints, views, and templates&lt;/li&gt;
&lt;li&gt;Static files&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;...and quite a bit more!&lt;/p&gt;

&lt;p&gt;The tutorial walks you through creating a basic blog application called Flaskr. Once completed, users of the application will be able to register, log in, create posts, and edit or delete their own posts.&lt;/p&gt;

&lt;p&gt;You should have at least some basic Python knowledge to get started with this tutorial.&lt;/p&gt;




&lt;h1&gt;
  
  
  #4: &lt;a href="https://realpython.com/introduction-to-python-generators/"&gt;Introduction to Python Generators&lt;/a&gt;
&lt;/h1&gt;

&lt;p&gt;In Python, generators are functions that can be stopped and started on demand, returning an object that can be iterated over later. Unlike lists, they are "lazy" and produce (or "generate") items one at a time and only when necessary. This makes them much more memory efficient when dealing with large amounts of data.&lt;/p&gt;

&lt;p&gt;This tutorial details how to create generators and expressions and when and why you might use them.&lt;/p&gt;




&lt;h1&gt;
  
  
  #5: &lt;a href="https://stripe.com/docs/api"&gt;Stripe's Python Integration&lt;/a&gt;
&lt;/h1&gt;

&lt;p&gt;Stripe is the leading payment processing platform and makes it easy for developers to integrate payment processing into their application. Stripe's official documentation walks you through how to use their API using Python. It includes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Using a REST API&lt;/li&gt;
&lt;li&gt;API authentication&lt;/li&gt;
&lt;li&gt;API error handling&lt;/li&gt;
&lt;li&gt;API pagination&lt;/li&gt;
&lt;li&gt;All Stripe API endpoints&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;While this isn't a proper tutorial, it does a great job of walking you through how to explore the Stripe API using Python. Be sure to select Python when you load the page!&lt;/p&gt;




&lt;h1&gt;
  
  
  Summary
&lt;/h1&gt;

&lt;p&gt;In this post we've covered 5 tutorials and guides you can use with a &lt;a href="https://c.next.tech/2JASxqq"&gt;Python sandbox&lt;/a&gt;. I hope it's been useful! If you have ideas for other tutorials to include, just drop us a note below!&lt;/p&gt;

</description>
      <category>python</category>
      <category>learning</category>
      <category>api</category>
    </item>
    <item>
      <title>Using Python's Django framework in the cloud</title>
      <dc:creator>Saul Costa</dc:creator>
      <pubDate>Tue, 21 May 2019 17:21:57 +0000</pubDate>
      <link>https://forem.com/nexttech/using-python-s-django-framework-in-the-cloud-f3</link>
      <guid>https://forem.com/nexttech/using-python-s-django-framework-in-the-cloud-f3</guid>
      <description>&lt;p&gt;&lt;a href="https://www.djangoproject.com/"&gt;Django&lt;/a&gt; is a Python framework for building web apps. Their website describes it like so:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;Django is a high-level Python Web framework that encourages rapid development and clean, pragmatic design. Built by experienced developers, it takes care of much of the hassle of Web development, so you can focus on writing your app without needing to reinvent the wheel. It's free and open source.&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;In this post, we'll cover how to use the Next Sandbox to get started with Django without downloading anything! We'll walk through how you can launch a Python sandbox and then install Django in it.&lt;/p&gt;

&lt;p&gt;First, click &lt;a href="https://nt.dev/python"&gt;here&lt;/a&gt; to launch a Python sandbox (you'll need to create a free Next Tech account if you haven't already).&lt;/p&gt;

&lt;p&gt;Once your sandbox has loaded, run the following commands in your sandbox's terminal to install Django:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;apt update
&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-y&lt;/span&gt; python3-django
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Then, create a new Django project:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;django-admin startproject project &lt;span class="nb"&gt;.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Now you can run the initial Django migrations:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;python3 manage.py migrate
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Migrations in Django are explained in detail &lt;a href="https://docs.djangoproject.com/en/2.2/topics/migrations/"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;To start the Django web server, run the following in your terminal:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;python3 manage.py runserver 0.0.0.0:8000
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Note the use of the &lt;code&gt;0.0.0.0:8000&lt;/code&gt;. This is required to allow remote connections, which you will technically be making to your sandbox.&lt;/p&gt;

&lt;p&gt;You'll also need to make some changes to the &lt;code&gt;project/settings.py&lt;/code&gt; file. First, replace the contents of the &lt;code&gt;MIDDLEWARE&lt;/code&gt; list with this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;MIDDLEWARE&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="s"&gt;'django.middleware.security.SecurityMiddleware'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s"&gt;'django.contrib.sessions.middleware.SessionMiddleware'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s"&gt;'django.middleware.common.CommonMiddleware'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s"&gt;'django.middleware.csrf.CsrfViewMiddleware'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s"&gt;'django.contrib.auth.middleware.AuthenticationMiddleware'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s"&gt;'django.contrib.messages.middleware.MessageMiddleware'&lt;/span&gt;
&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;This removes an option added by default that prevents your webpage from being embedded, which it needs to be so the in-sandbox web browser can load it.&lt;/p&gt;

&lt;p&gt;Then, you need add this line to the file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;ALLOWED_HOSTS&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;'*'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;This will allow any host to connect so the domain your sandbox is running on will be able to.&lt;/p&gt;

&lt;p&gt;This part of your file should now look something like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--4hwQPV2M--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/tdij5pnt2nzo04qnesg3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--4hwQPV2M--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/tdij5pnt2nzo04qnesg3.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Okay, all set! Now, click the &lt;code&gt;+&lt;/code&gt; and select a browser, then enter &lt;code&gt;localhost:8000&lt;/code&gt; in the URL bar. You'll be shown this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--y9dW4DCg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/i37dy11pcwc46rq4chul.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--y9dW4DCg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/i37dy11pcwc46rq4chul.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Great work! You can now continue to explore Django. I recommend reading through the &lt;a href="https://docs.djangoproject.com/en/2.2/intro/tutorial01/"&gt;Django Quick Start guide&lt;/a&gt;, which covers some of what we have in this post, and much more!&lt;/p&gt;

&lt;p&gt;Have a question or comment? Drop us a note below!&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>python</category>
      <category>learning</category>
    </item>
    <item>
      <title>Getting Started with the Next Sandbox</title>
      <dc:creator>Saul Costa</dc:creator>
      <pubDate>Wed, 08 May 2019 16:02:01 +0000</pubDate>
      <link>https://forem.com/nexttech/getting-started-with-the-next-sandbox-4jb4</link>
      <guid>https://forem.com/nexttech/getting-started-with-the-next-sandbox-4jb4</guid>
      <description>&lt;p&gt;&lt;strong&gt;I’m excited to announce the release of Next Tech’s newest product: Next Sandbox!&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The &lt;a href="https://next.tech/sandbox/for-devs" rel="noopener noreferrer"&gt;Next Sandbox&lt;/a&gt; provides access to real-world computing environments in 2 seconds directly from your browser. Rather than installing the programming language or software you want to use on your computer, you can just click a button and access that language or software right away using a browser-based development tool.&lt;/p&gt;

&lt;p&gt;We built Sandbox to solve two key problems we experienced ourselves as developers almost every day:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Installing software is haaaaaaard. Even experienced developers can struggle with this and it’s something that can get in the way of trying out new ideas. It’s nice to have something work out of the box so you can focus on innovating.&lt;/li&gt;
&lt;li&gt;When you DO install software on your computer yourself — especially if you just want to test it — it can quickly clutter your environment. Maybe you want to try the newest version of Java, but installing it on your computer could cause issues with your current version.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The Next Sandbox addresses these issues by shifting the burden of installing software off of you and onto us. But that’s okay, we’ve been doing this for years! The Next Sandbox is based on the same infrastructure and interface that powers our product for teaching and learning tech skills, which is used by leading educational companies all around the world. In fact, the CS50 program at Harvard actually built their own sandbox atop our infrastructure!&lt;/p&gt;

&lt;p&gt;Here’s what a sandbox for the Python programming language looks like when you first launch it:‌&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmnzmsb3eahecvguv9qkk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmnzmsb3eahecvguv9qkk.png" alt="img" width="800" height="514"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this getting started guide we’ll cover how to launch your first sandbox and some of the exciting things you can do with it.&lt;/p&gt;

&lt;p&gt;Let’s dive right in!&lt;/p&gt;

&lt;h1&gt;
  
  
  First things first
&lt;/h1&gt;

&lt;p&gt;To start, I recommend using this link to sign up for Next Tech if you haven’t already:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://nt.dev/?ref=ce315f8c" rel="noopener noreferrer"&gt;nt.dev?ref=ce315f8c&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Next Tech uses minute-based pricing, where you pay 1 cent per minute you spend on the page with a sandbox open. You typically get $10 in free credits when you sign up (that’s 1,000 minutes of coding!), but if you use that link, you’ll get $15!&lt;/p&gt;

&lt;p&gt;The account for that referral link also receives $5 each time a referred user activates their account. &lt;strong&gt;If you sign up with that link, you’ll be entered to win access said account, as we’ll be randomly selecting a referred user to win once the account value hits $250!&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you have any questions about our pricing, please don’t hesitate to comment directly on this post.&lt;/p&gt;

&lt;p&gt;Okay, back to it. Once you’ve created a Next Tech account, you have two options for launching a sandbox:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Use a nt.dev URL, like &lt;a href="https://nt.dev/python" rel="noopener noreferrer"&gt;nt.dev/python&lt;/a&gt;. This will instantly get you into a fresh Python sandbox.&lt;/li&gt;
&lt;li&gt;Use the &lt;a href="https://next.tech/sandbox/launch" rel="noopener noreferrer"&gt;launchpad&lt;/a&gt; to select the environment you’d like. This page contains a number of details about each environment.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Initially your sandbox will display a directory tree viewer, code editor, and terminal. To add some code, just click the &lt;code&gt;+&lt;/code&gt; icon or the &lt;code&gt;...&lt;/code&gt; next to your working directory, then &lt;strong&gt;New File&lt;/strong&gt;:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8gih84n0vqk6ys1o345m.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8gih84n0vqk6ys1o345m.png" alt="img" width="279" height="114"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You’ll be shown an overlay like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgk0rhqrfsmtv4v44pkz7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgk0rhqrfsmtv4v44pkz7.png" alt="img" width="800" height="608"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Go ahead and create a file named &lt;code&gt;main.py&lt;/code&gt;. Don't worry about the tabs at the bottom yet — we'll cover those soon!&lt;/p&gt;

&lt;p&gt;Or — if you want to get fancy — you can type &lt;code&gt;touch main.py&lt;/code&gt; in your terminal. The Linux &lt;code&gt;touch&lt;/code&gt; command will create a new file with the specified name.&lt;/p&gt;

&lt;p&gt;Once you’ve created a file, it will be saved to your working directory (shown in the file tree as &lt;code&gt;~/workspace&lt;/code&gt;, the absolute path for which is &lt;code&gt;/home/nt-user/workspace&lt;/code&gt;). So the full path for this file is &lt;code&gt;/home/nt-user/workspace/main.py&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;You can put any Python code you’d like here, but in case you don’t have some handy, here’s a quick calculator to get you started:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;subtract&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;multiply&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;divide&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;__name__&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;__main__&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;input&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Please enter a number: &lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
    &lt;span class="n"&gt;y&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;input&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Please enter another number: &lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;subtract&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;multiply&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;divide&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can run this file from the terminal however you’d like, for example, &lt;code&gt;python3 main.py&lt;/code&gt;. You'll be shown the output of the program, for example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;workspace $ python3 main.py
Please enter a number: 123
Please enter another number: 456
579
-333
56088
0.26973684210526316
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;‌The terminal connects you to an actual computing environment. Go ahead, give &lt;code&gt;ls -l /&lt;/code&gt; a try in the terminal, where you'll see a full operating system directory structure! You also have full admin access (&lt;code&gt;sudo&lt;/code&gt;), so you can alter any part of the filesystem you'd like.&lt;/p&gt;

&lt;p&gt;You can read about more ways to use a sandbox &lt;a href="https://next.tech/sandbox/uses" rel="noopener noreferrer"&gt;here&lt;/a&gt;!&lt;/p&gt;

&lt;h1&gt;
  
  
  Other computing environments
&lt;/h1&gt;

&lt;p&gt;There are sandboxes for a multitude of other environments, including:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Common programming languages like Java, C++, Swift, and C#&lt;/li&gt;
&lt;li&gt;Web development technologies like HTML, CSS, JavaScript, Ruby on Rails, and PHP&lt;/li&gt;
&lt;li&gt;Data science frameworks for Python and R&lt;/li&gt;
&lt;li&gt;Databases like PostgreSQL and MySQL&lt;/li&gt;
&lt;li&gt;Specialty languages like Elm, Haskell, Golang, and Rust‌&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can find a complete list of the environments &lt;a href="https://next.tech/sandbox/launch" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Each sandbox comes with certain programs preinstalled. If you launched the Python sandbox, you can run &lt;code&gt;ipython&lt;/code&gt; in the terminal to jump into &lt;a href="https://en.wikipedia.org/wiki/IPython" rel="noopener noreferrer"&gt;that nifty piece of software&lt;/a&gt;. You can also install new software, for example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo apt install -y gnome-calculator
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each sandbox is given access to 256MB of free disk space and can use up to 2GB of RAM. It also has access to up to 4 CPU’s worth of processing power.&lt;/p&gt;

&lt;h1&gt;
  
  
  Tab-based interface
&lt;/h1&gt;

&lt;p&gt;After you’ve run the above command, open a &lt;strong&gt;Desktop&lt;/strong&gt; tab by clicking the &lt;code&gt;+&lt;/code&gt;and selecting Desktop, then run &lt;code&gt;gnome-calculator&lt;/code&gt; in the terminal . You'll see this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flj2g2pfm17sp5vf5sag7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flj2g2pfm17sp5vf5sag7.png" alt="img" width="408" height="434"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is a real calculator running in your sandbox!&lt;/p&gt;

&lt;p&gt;Pretty slick, right?&lt;/p&gt;

&lt;p&gt;You probably noticed by now that there are a multitude of other tabs you can select from. Here’s a quick list of the others:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Terminal tabs give you access to a new terminal, which makes it easy to run multiple programs or commands concurrently.&lt;/li&gt;
&lt;li&gt;Browser tabs load a web browser you can use to connect to web accessible services running in your sandbox.&lt;/li&gt;
&lt;li&gt;Jupyter tabs loads an actual Jupyter Notebook for you to work in, which is great for data science or machine learning.&lt;/li&gt;
&lt;li&gt;Skulpt is a JavaScript implementation of some of the basic features of Python, oftentimes used with the &lt;code&gt;turtle&lt;/code&gt; and &lt;code&gt;processing&lt;/code&gt; Python libraries.&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Sharing your work
&lt;/h1&gt;

&lt;p&gt;You’ve probably already seen the &lt;strong&gt;Share&lt;/strong&gt; button at the top right of the page! If you send a share URL to someone, they’ll get a copy of your sandbox as it stands when they click the URL. Note that you &lt;strong&gt;will not be billed for their usage.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Here’s my share URL for the project I used to take the screenshots for this post:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://next.tech/projects/0295f1cee35f/share" rel="noopener noreferrer"&gt;next.tech/projects/0295f1cee35f/share&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you click that, you’ll be taken straight to a Python sandbox with the calculator code in it. Note that it won’t have the &lt;code&gt;gnome-calculator&lt;/code&gt; installed because (currently) sandboxes do not persist newly installed software, so you'll have to install that yourself if you'd like to try it.&lt;/p&gt;

&lt;p&gt;There are a number of other pre-made sandboxes ready for launch &lt;a href="https://next.tech/sandbox/uses" rel="noopener noreferrer"&gt;here&lt;/a&gt;!&lt;/p&gt;

&lt;h1&gt;
  
  
  Downloading your work
&lt;/h1&gt;

&lt;p&gt;The files you create (and the tabs) are saved automatically as you work in your sandbox. However, sometimes you may want to save them to your local machine, for example if you’ve tested a proof-of-concept and now want to continue to work on it as part of your normal development process.&lt;/p&gt;

&lt;p&gt;To do this, just click the settings gear in the bottom left of the page, then choose &lt;strong&gt;Download&lt;/strong&gt;.&lt;/p&gt;

&lt;h1&gt;
  
  
  Summary
&lt;/h1&gt;

&lt;p&gt;Whew, that was a lot to cover! Let’s recap. Above, we explored:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Launching a computing environment for Python in a few seconds (especially if you used the nt.dev URL)&lt;/li&gt;
&lt;li&gt;Writing a basic calculator in Python&lt;/li&gt;
&lt;li&gt;The various interface elements available to you in a sandbox&lt;/li&gt;
&lt;li&gt;Installing software in a sandbox (the &lt;code&gt;gnome-calculator&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Opening an actual desktop environment and using that software&lt;/li&gt;
&lt;li&gt;Downloading your work for use in your local development environment&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This has been just a quick guide to get you started. If you’d like, you can explore the rest of the Sandbox documentation &lt;a href="https://docs.next.tech/sandbox/getting-started" rel="noopener noreferrer"&gt;here&lt;/a&gt; to learn more about what you can do in a sandbox!&lt;/p&gt;

&lt;p&gt;If you have any feedback you’d like to share, please don’t hesitate respond to this post. We’d love to hear from you!&lt;/p&gt;

</description>
      <category>productivity</category>
      <category>showdev</category>
      <category>programming</category>
      <category>gui</category>
    </item>
    <item>
      <title>New Year, New Interface!</title>
      <dc:creator>Saul Costa</dc:creator>
      <pubDate>Sun, 20 Jan 2019 21:56:56 +0000</pubDate>
      <link>https://forem.com/nexttech/new-year-new-interface-38bo</link>
      <guid>https://forem.com/nexttech/new-year-new-interface-38bo</guid>
      <description>&lt;p&gt;At Next Tech we’re are incredibly excited to announce the release of our tab-based interface! This enables any interface component (e.g. a web browser or terminal) to be placed in any section (or “pane”) of the interface. This means a terminal can be loaded next to a code file, a full GUI viewer can be alongside a SQL display, and so forth.&lt;/p&gt;

&lt;p&gt;Previously, each pane could only support a single component. So if you wanted a code editor, terminal, and web browser, you needed a three pane layout. This worked well for introductory use cases but as we’ve pushed further into serving developers as well as beginners with learning materials, we found this approach to be a major limitation. For example, when teaching a web framework, a terminal is only required to run a command or two. So having to keep it on the screen taking space away from a code editor and web browser led to an unnecessarily squashed layout.&lt;/p&gt;

&lt;p&gt;Here’s what that might have looked like before:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--FLFLrlC_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/9mdaaqv0kmqlde7s8z6f.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--FLFLrlC_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/9mdaaqv0kmqlde7s8z6f.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And here’s what it would look like now:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--NJxLvKMW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/9f4fzmeownzti7tzz9qv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--NJxLvKMW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/9f4fzmeownzti7tzz9qv.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Note that the GUI and terminal tabs are now located side-by-side in a two pane layout versus requiring a three pane layout to accommodate the identical use case.&lt;/p&gt;

&lt;p&gt;Now the large number of interface elements we support and the new ones we’re creating can be mixed and matched in hundreds of ways. The option to open a new tab can also be left to the learner versus pre-configured.&lt;/p&gt;

&lt;p&gt;Currently, we support the following tab types:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Editable code and text files&lt;/li&gt;
&lt;li&gt;Terminals with or without root access&lt;/li&gt;
&lt;li&gt;Web browsers for any port&lt;/li&gt;
&lt;li&gt;GUI displays with X support&lt;/li&gt;
&lt;li&gt;SQL result tables&lt;/li&gt;
&lt;li&gt;Python graphic displays for Skulpt programs&lt;/li&gt;
&lt;li&gt;Media files such as images and videos&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We believe wholeheartedly that providing a traditional IDE loaded with menus does a disservice to learners and anyone working on a project. At the same time, a box that simply runs code isn’t useful either. So this interface, like others we have built, was designed carefully, one piece at a time to ensure it is powerful yet simple for anyone to use.&lt;/p&gt;

&lt;p&gt;We’ve already put this interface to good use with a number of our courses on programming, web development, database design, and machine learning. We’re now offering a $9 a month subscription to access our courses, and you can &lt;a href="https://next.tech/register"&gt;get started free for a week&lt;/a&gt;!&lt;/p&gt;

&lt;p&gt;If you’d like to learn more about how to build your own courses with this interface atop Next Tech, we’d love to &lt;a href="https://next.tech"&gt;hear from you&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>startup</category>
      <category>learntocode</category>
      <category>release</category>
    </item>
    <item>
      <title>New Course: Database Fundamentals</title>
      <dc:creator>Saul Costa</dc:creator>
      <pubDate>Wed, 03 Oct 2018 17:01:24 +0000</pubDate>
      <link>https://forem.com/nexttech/database-fundamentals-new-course-4blo</link>
      <guid>https://forem.com/nexttech/database-fundamentals-new-course-4blo</guid>
      <description>&lt;p&gt;We just released &lt;a href="https://c.next.tech/2MZYex6"&gt;Database Fundamentals&lt;/a&gt;, the latest interactive course on Next XYZ!&lt;/p&gt;

&lt;p&gt;This course will take you through the foundational concepts of databases and SQL (Structured Query Language). Plus, it’s &lt;strong&gt;free&lt;/strong&gt;!&lt;/p&gt;

&lt;p&gt;You’ll help Codey ― the Next XYZ coding bot ― design, build, and maintain a database for a construction company, as well as answer important questions using data.&lt;/p&gt;

&lt;p&gt;Along the way, you’ll learn how to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Create databases and modify their schemas&lt;/li&gt;
&lt;li&gt;Add, update, and delete data&lt;/li&gt;
&lt;li&gt;Query records in a database using SQL&lt;/li&gt;
&lt;li&gt;Join, filter, group, and sort results&lt;/li&gt;
&lt;li&gt;Ensure your database is normalized&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You don’t need to have worked with databases before or have any coding experience to take this course.&lt;/p&gt;

&lt;p&gt;Want to take a look? You can find it &lt;a href="https://c.next.tech/2MZYex6"&gt;here&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>learning</category>
      <category>sql</category>
      <category>database</category>
    </item>
    <item>
      <title>An Interview with Andrew Sverdrup</title>
      <dc:creator>Saul Costa</dc:creator>
      <pubDate>Mon, 02 Jul 2018 18:32:58 +0000</pubDate>
      <link>https://forem.com/nexttech/learning-python-openweathermap-3mio</link>
      <guid>https://forem.com/nexttech/learning-python-openweathermap-3mio</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;“The ability to provide something of value to many people is the driving force behind my love of technology.”&lt;br&gt;
― Andrew Sverdrup&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Hey Andrew, excited to be sitting down with you and doing this interview! To get started, mind telling me a little about yourself?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Sure thing! I am a recent college grad and am excited to put the programming knowledge I have learned to use. My degree is in Software Engineering from Embry-Riddle in Arizona. And I recently joined Next XYZ as their first full time software engineer!&lt;/p&gt;

&lt;p&gt;I like to stay active by working out and playing basketball. I love learning and trying out new programming languages to see what they’re like. I learn by doing so I enjoy finding new languages and libraries and seeing what I can build with them.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Awesome. So tell me about your course!&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The Python OpenWeatherMap (PyOWM) course teaches you how to use the OpenWeatherMap API with Python. OpenWeatherMap is a powerful API that lets you retrieve weather data for virtually any location in the world, and they have a generous free tier to get you started! The PyOWM library allows you to easily use the OpenWeatherMap API with Python.&lt;/p&gt;

&lt;p&gt;The first half of the course covers the basics that you need to know to get weather data using PyOWM, including the temperature, wind speed, and humidity. The second half is my favorite though. That’s where we use the temperature data to create a graphical user interface (GUI) to display the temperature forecast! And finally at the end you’re challenged to modify that GUI to display the humidity forecast.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What made you decide to build this course?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I decided to build the course because I’ve learned many cool things while programming and I want to share them with others so they can learn too! Programming provides seemingly endless possibilities to create both fun and useful projects. Next XYZ allows me to easily share what I’ve learned with others and I look forward to hearing what people think of the course!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What got you interested in technology in the first place?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I’ve been fascinated by computers ever since I was a kid. It takes a lot of money to build things such as houses, but with programming you can create something valuable with very few resources. All you need is a computer, some programming skills, and some ideas! The ability to provide something of value to many people is the driving force behind my love of technology.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Do you have any ideas for future courses you might build?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I love sharing what I’ve learned with other people so they can see all the cool things that can be done with programming. I’m always exploring new languages and libraries and I will be creating more courses for some of my favorites, so stay tuned!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Where can readers find your course?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The course is published on Next XYZ &lt;a href="https://www.next.xyz/xyz/python-open-weather-map"&gt;here&lt;/a&gt;. Give it a try and let me know what you think!&lt;/p&gt;

&lt;p&gt;&lt;em&gt;You can find Andrew &lt;a href="https://twitter.com/AndrewSverdrup"&gt;on Twitter&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>python</category>
      <category>learning</category>
      <category>api</category>
    </item>
    <item>
      <title>CS50</title>
      <dc:creator>Saul Costa</dc:creator>
      <pubDate>Mon, 25 Jun 2018 16:52:39 +0000</pubDate>
      <link>https://forem.com/nexttech/cs50-5d73</link>
      <guid>https://forem.com/nexttech/cs50-5d73</guid>
      <description>&lt;p&gt;&lt;em&gt;By &lt;a href="https://twitter.com/SaulDCosta"&gt;Saul Costa&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;After a long day at SIGCSE 2018 this past February, I arrived back at my hotel room ready to wind down for the night. Working my way through an overflowing inbox, one email in particular from a Harvard University address caught my eye. And not just any Harvard address. It was an email from Dr. David J. Malan, the instructor for Harvard’s CS50 course, one of the most influential courses in computer science education.&lt;/p&gt;

&lt;p&gt;Sleep would have to wait. After a few quick emails, David and I met for a late-night chat over iced tea and juice. By the end of the meeting, it was clear that an exciting opportunity was at hand.&lt;/p&gt;

&lt;p&gt;CS50 is one of the most influential courses in computer science education and an icon in the field. The course is delivered with just the right mix of novelty and difficulty, which results in an engaging and valuable experience for its students. It’s no surprise that has become the largest course at Harvard, with over 600 students enrolled on campus and more than a million online. While CS50 provides an introduction to a range of concepts including abstraction, algorithms, and security, David strives to make the whole course an experience that students can look back on fondly, enabling them to explore areas beyond their comfort zone and hopefully fall in love with a new field of study.&lt;/p&gt;

&lt;p&gt;At Codevolve, we believe that delivering opportunities to learn tech skills via an easy-to-use development environment removes the barriers that can derail a student when they’re just getting started. To execute on this core belief, we’ve built a platform that allows students to gain hands-on experience with technical skills like programming, web development, database management, and data science. We’ve already partnered with leading education companies around the world to power learning experiences for their students.&lt;/p&gt;

&lt;p&gt;With Codevolve’s focus on building great tools for learning tech skills and CS50’s dedication to producing top-of-the-line learning materials, it was immediately apparent that both teams working together would have an incredibly positive impact on the students of CS50. That collaboration is now underway, and we’re already seeing excellent results!&lt;/p&gt;

&lt;p&gt;Since SIGCSE, CS50 has leveraged our technology to develop &lt;a href="https://sandbox.cs50.io"&gt;sandbox.cs50.io&lt;/a&gt;, where students and teachers can quickly spin up an online, real-world coding environment preloaded with support for various languages like C, C++, HTML, Java, Python, and SQL. Users can set the environment to use any combination of text editor, terminal, web browser, or full GUI via an interface developed by CS50. Each sandbox has no preloaded learning content and instead provides value by allowing users to open environments in seconds so they can experiment with new ideas and concepts.&lt;/p&gt;

&lt;p&gt;One of the great features of the CS50 sandbox is the ability to share a link that clones the current environment. Using this feature, an instructor can write a program in the sandbox during a class to show students a new concept and then share the link so they can easily pick up exploring where the instructor left off. Or a struggling student can copy their program into a sandbox environment and share that with a teaching fellow for feedback. No doubt, a multitude of other use cases will emerge in the coming semesters!&lt;/p&gt;

&lt;p&gt;Backing each sandbox is a custom image that contains everything CS50 needs, from the languages they teach to custom tools that they have built. Codevolve hosts this specialized image and backs it with our “smart-scaler” to ensure that each sandbox session is provided a fresh environment in seconds (2.13 on average, as of this writing). While we have used these tools internally for years, this is the first time we have hosted a completely custom image for a partner. We foresee doing much more of this in the future as it opens up many exciting opportunities to form new partnerships!&lt;/p&gt;

&lt;p&gt;CS50 has already been an invaluable source of feedback for us. Until now we have primarily partnered with learning companies, which adds a layer between us and their learners, who are the people using our product every day. Over the course of SIGCSE, I met with the CS50 team multiple times (as well as a couple of times all over the country since!) to discuss what worked, what didn’t, and what needed polishing. This feedback from one of the most experienced teams working on computer science education helped us map out numerous future improvements to our product, many of which we have already implemented.&lt;/p&gt;

&lt;p&gt;In the coming months, CS50 plans to build lessons using API endpoints that we added per their request that let them remotely run their custom test suite (check50) to test student code. They’ll also use a git-centric structure for hosting their content, allowing them to create highly customized lessons very quickly without having to train their staff on our authoring tool. Internally we have always seen this as a logical next step for our product, and it is exciting to see such a talented group beginning to bring this vision to life before we’ve had the chance to build it ourselves!&lt;/p&gt;

&lt;p&gt;Even though they’ve logged 90% of our recent feature requests, working with David and his team at CS50 has already been an incredible experience. They’ve pushed the boundaries of our product and already built out a great tool on top of it. We can’t wait to see what they come up with next!&lt;/p&gt;

&lt;p&gt;In the meantime, want to learn more about CS50? You can take it for free at &lt;a href="https://cs50.edx.org/"&gt;cs50.edx.org&lt;/a&gt;!&lt;/p&gt;

&lt;p&gt;Originally published on Medium &lt;a href="https://medium.com/nextdotxyz/cs50-690dc87b213a"&gt;here&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>learning</category>
      <category>learntocode</category>
      <category>education</category>
      <category>coding</category>
    </item>
  </channel>
</rss>
