Hello, everyone! I’m sure that we all know about how impactful computer science has been on our modern lives. From it be powering our mobile devices or being implemented in machine learning to aid our fight against the COVID-19 pandemic, I’m very sure that all of us had our lives impacted by computer science in one way or another. Unfortunately, though, not all of us had the opportunity to be properly exposed to it and learn about it. To give you an introduction to programming, here is how to make your first interactive program in Python!
What you Need
-
● A device that allows you to type (ex: computer and keyboard, laptop, phone, etc.). For this tutorial, I will be using my phone
-
● A Python compiler (in this tutorial I will be using an online compiler called repl.it)
The Steps in Making Your First Interactive Program!
1)
The first step to making your first interactive computer program is to find a good compiler that will follow the commands you send it with your code. In this tutorial I will be using the virtual compiler replit since it allows you to store all your programs on it, share it with who you want, and have the entire world see your program! Make an account by clicking on the top right hand corner and signing up
Once you make an account, click on the “+ New Repl” button, select the programming language to be Python, and name it whatever you want!
-
3) In order to make this program interactive, we need a way to let the user know that he or she needs to input values into the compiler. To do this we use the print() function, which outputs anything you want onto the screen that is within the parentheses. Since we want to output a specific message onto the screen, we have to enclose what we want to output onto the screen in quotation marks. Here is the complete command: print(“Hello! I am Sal the virtual robot! What is your name?”)
-
4) In order to let the user type in his or her name, we need to use the input() function to allow the user to type in something and store the name somewhere. To do this, we store it in a variable. On the next line (which you get to by hitting the “Enter” key), call the variable “name” and set it equal to the input() function. Here is the complete command: name = input()
-
5) Since the program needs to respond to the user input, we will use the print() function again. On the next line, follow what you did in step 3 except we need to have 3 separate things in this output: the first part of the response, the user’s inputted name (which is stored in the variable “name”), and the last part of the response. To connect each part, put a plus sign in between each one. Here is the complete command: print(“Hello “ + name + “! What can I do for you?)
-
6) To let the user type in something again, simply type “input()” onto the screen.We don’t need to set it to anything in this case since the program will only have one response to the inputted command
-
7) To make the program respond to the user properly, we will use the print() function again like how we did in step 5. Think of a creative message that makes it sound like the program is reasonably responding to anything the user inputs. Here is my complete command: print(“Sorry, “ + name + “. I am not designed to carry out that command.”)
8) To see the program run and to interact with it, press the “Run’ at the top of the screen if you are using a computer and the triangle button at the bottom right hand corner if you are using a phone
Although this is a much simpler program than those that power modern society, I hope this tutorial at least helped you be introduced into and be interested in programming. There is much more to computer programming and artificial intelligence than just asking someone what he or she wants done and then immediately rejecting the request, but this at least gets you one step closer!
Hey Jordan, I thought your piece was super interesting. I really liked how you made it interactive and went through the details of every step rather than just giving an overview of programming because I wouldn't have know how or where to begin. Great Job!
ReplyDelete- Diana Quintanilla
This was a cool piece, it was very insightful, I've never really knew computer programing in depth or even what to do so thanks for providing the steps necessary to do so.-Shannon Thompson
ReplyDeleteThis was definitely something that was helpful and very interesting to read about. I liked how use gave a detailed step by step process and even used pictures as well to help us understand how to make our own computer program- Daniel Boehl
ReplyDeleteHi Jordan,
ReplyDeleteI really enjoyed your piece because I personally needed a refresher on coding. I almost forgot how to, but now that you reminded me of how easy and interesting it actually is, I just might start coding again for fun! I like how you used python, instead of java, because I plan on using it for the future. Overall, great job and thank you!
- Rumaan Cheema
This piece is very informative, especially as I don't know a single thing about coding nor have I ever done it before. If I ever want to try I know what to refer back to. -Caitlin Munar
ReplyDeleteYour how-to was very interesting to read. I enjoyed reading about your tutorial because I can tell it is something that you are passionate about! If anyone ever needed to use your guide, they would have no trouble following it. You've written the steps in a cohesive and user-friendly way that anyone could follow. You even included pictures! Great job.
ReplyDeleteHi there!! I like coding HTML and Java, but Python is not my cup of tea. Your piece made me want to try learning the language. Thank you so much!!!
ReplyDelete-Hrishika Reddy Nanamala
Jordan, you had a great hook especially since it was like my situation--wanting to learn, but not having enough experience. I appreciate the instructions and the photos because they were straightforward and provided a high quality touch. The terminology was comprehensible and interesting. This seems so efficient, necessary, and simple for today’s world. Amazing piece, Jordan! -Laylah Perez
ReplyDeleteThis is such a cool idea! Programming has always seemed way too difficult to me, but my dad does it for work so it's interested me. This laid it out so simply. Good job! -Amy H. :)
ReplyDeleteThis was extremely informative! Since I do a multitude of things with scripts (3d printer coding, custom firmware, etc.), I found this a very nostalgic and made me reflect on my roots as a young coder. Thank you so much for introducing others to the wonderful (and infinite) world of code!
ReplyDeleteRyan Carter
As someone who periodically programs themselves I really enjoyed reading this piece as it is one of my own hobbies. I really liked how you built up the concept and idea from the ground level up and how you made it easy for someone who has no experience to thoroughly understand it. Amazing job, you even taught me a few things. -kevin de Lama
ReplyDeleteWow! As someone who has been experimenting with python for quite some time now, you did a very wonderful job at explaining it in a very understandable and comprehendible way! You show a clear passion for programming as well and it is really inspiring. Great piece! - Sumbal Sharif
ReplyDelete