Python #1

Like I told yall, I’m stepping away from web development and cracking down on Python. Can’t keep wasting time on languages that have little to do with data science.

FreeCodeCamp’s Python courses are just videos with a multiple-choice question at the end of each one. That’s not going to teach me the language practically. So I’ll keep them as a supplemental resource.

Starting off, the best resource I’ve found is pythonprinciples.com. They have a premium version, but right now they’re letting you get it for free. Just create an account and click ‘upgrade’. So if you’re interested in Python I recommend you get on that now before they start charging again.

Print

First, we use the ‘print’ command. You first type ‘print’, parenthesize your number(s) of choice, then when you run the program, it’ll show that number in the output. ‘Print’ is just the command, it won’t show in the output. And you don’t need a space between ‘print’ and the parentheses. Spaces don’t usually count in programming

We can also use ‘print’ for basic math operations. Just type your equation in with your plus, minus, times or divisor, and it’ll show the answer in the output

print(34*21)

Strings

Next we got strings. A string is how you represent text in Python.

Unlike the numbers, the text has to be wrapped in double quotes.

print("text")

We can also combine (also called ‘concatenating’) the strings which is basically adding 2 texts together to be outputted as one

print("pro" + "gram")

That would output as ‘program’.

Variable

A variable lets you store a value under a name. Just like in algebra when we say x = whatever; x saves us from having to say whatever.

You just type the name you’re using, assign that to a value with the equal sign, then ‘print’ that name.

whatever = 25
print(whatever)

The value you give that name is called a ‘variable assignment’. And the math operations and concatenations can still be used for this too

Just like social media handles, variables can’t contain spaces, so we use underscores.

Leave a comment