Python Basics

Jacobhoskins
3 min readDec 31, 2020

What is Python? Python is a programming language created in 1991 by Guido van Rossum. Python is a great programming language to learn if its one of your first ones because of the simplicity of the syntax, and it teaches you good coding habits and how to structure a program. The difference Between Python and other languages is that instead of having a compiler, it interprets the code line by line instead of all at once. Python is used by Google, Netflix, and a lot more major companies. So now lets get to the fun part of the article and learn some basic commands.

Print()

In Python, print() is a function that will output any code or variable inside of it to the console. It might not seem like it does much but this can come in handy for debugging, asking a user something before gathering input, and seeing the outcome of a function or problem you need to solve! Below is how you would use the print() function in your Python script.

>print(“Hello World!”)

>>Hello World!

Variables

Variables are one of the most important things to learn when learning Python. If you don’t understand variables then you will never be able to actually create a good program. Variables are used to store data, the data could be used at a later point in time or even to store a users name and age and print it to the console using the function you just learned. As I said earlier, Pythons syntax is very easy to understand. All you need to do to create a variable is name it and give it a value. Now remember, there are multiple ways to properly name a variable but many more ways to do it incorrectly. Some things you can not do is start the variable name with a number. And as you learn more and more how to code, you might want other people to see your code. So different ways to name your variable could be camel casing, this is where the first letter of the first word is lowercase and the beginning of the rest of the words have uppercase letters. Another way is with the underscore, this way is just done by separating each word with a underscore.

>userName = “Jacob”

>user_age = 21

>print(userName)

>print(user_age)

>>Jacob

>>21

Data Types

Python has multiple different data types. You may be wondering what that is and what they’re used for, well good question I’ll tell you. Data Types is a fancy way of saying different ways to store different types of variables. You might want to save a users name and age together in one variable, but what if you have a bunch of people that you want to add to a list? Will you have to store each one in a new variable for each persons age and name? Nope, thanks to Python we have Dictionaries. Dictionaries are a Data Type where the variable is a KEY VALUE pair. That means you could add each person to the variable, where it would say their name and age together, the key and the value

Dictionaries

>Dictionary = {Key: Value, Key, Value}

>guestList = {“Jacob”: 21, “Gabby”: 24, “Alex”: 27}

Another type of Data Type is List. And it can be explained as simply that, a list. This data type is created with The square brackets. You might have realized that Dictionaries are created using the Curly Braces. If you change those curly braces with a square bracket you have a list! One way you might want to use the list data type is to take a users input about what they need from the grocery store and store it in a storeList =[] variable!

List

storeList = [“Milk”, “Eggs”, “Bread”, “Butter”]

store_list = [“Milk”, “Eggs”, “Bread”, “Butter”]

I hoped you learned a little bit from the article! I appreciate you taking your time to read it. I will be releasing articles twice a week starting the new year each on Python! Don’t forget how helpful Youtube videos are and Python documentation itself!

--

--