Sunday, November 5, 2017
Six Steps to Learning to Program With Python
Have you ever wanted to learn how to program but it just seems like there is way too much to learn? There are websites that try to make it easier to learn how to code such as code.org but they are far too simple and are aimed at kids in either middle school or younger. What if I told you that you could learn how to write a program in under five minutes? This is easily accomplished by using a more simple programming language, and the one I am going to show you is called Python. Python is known for its simplicity, however this means it is far less powerful than more complicated languages like C++ and Java.
For your first program I'm going to show you how make a program that asks for the user's name and then says “”Hi” to the user using their name.
Open Python and you should come to a screen that looks like this. This is known as the shell and this is where your program will run. Press file and then new file to open up a new program.
A screen like this should pop up. This is where you will be writing the actual code.
Use hashtags to write comments. Comments are not read by the computer and are only read by other people who read the program. Comments are important because they allow others who read your program to know what you were trying to write with your code.
Create a variable that stores the user's name. In this case the variable is called “name” and the words in the quotes are the words that the user sees.
Create a print statement that uses the user's name using the variable created previously.
Create an input statement that stops the program. Without this the program will continue to run until you close Python. After you have done this press the run button and run the program!
Once you have run the program it will ask for your name. Type your name and then press enter.
Then the print statement will pop up on the screen and it will prompt you to press enter to exit. Congratulations you have just finished your first program!!!