Learn to code in python! Part 1: Basic Concepts and Setup
[deleted]

Learn to code in python! Part 1: Basic Concepts and Setup

Hello to-be master coders! You have decided to learn Python, this is great news! If you are new to coding Python is the place to start, it is known as todays BASIC. If you don't know what BASIC is, it is was pretty much the first programming language. Anyway Python is a really easy programming language that you should grasp fairly easily, if you have coding experience you will fly through this!

What is Python?

Now, what is Python? Python is a multi-purpose, high-level interpreted programming language. What is an interpreted language? An interpreted language is a language that directly executes instructions written in a programming or scripting language, without requiring them previously to have been compiled into a machine language program. That may not have made any sense but that doesn't matter. For now lets move on.

How to set-up Python

You can use replit.com or you can go to python.org to download python on your computer. On the page you will see this ->

Select downloads and install the latest version of Python

Currently the latest version is 3.9.2. However I have 3.9.1 installed on my computer. Now in the search bar type "IDLE python" and open that, if you are using replit.com then you don't need to open IDLE. This is the Interpreter that comes installed with Python.

Now to the good stuff(code)

First we are going to go over some key vocabulary:

  • String
    • A sequence of characters
  • Int
    • Int is short for integer which is a whole number, not decimal
  • Float
    • Float is a decimal number
  • Boolean
    • True or False
  • Concatenation
    • The joining of strings
  • Interpreter
    • A application that runs code line by line
  • Iterate
    • Loops through an object
  • Variable
    • A word or letter that contains data
  • Function
    • Something that performs a task in a single command
  • Data Type
    • Int, String, Float, Bool
  • Comment
    • A comment is a line that the interpreter ignores when the code is run

Python Basics

The most basic python function is print("Hello World"). This displays the text inside the parenthesis. Notice how the text Hello World is inside two double line quotes. These define the texts data type, the double line quotes "" define it as type string. Two single line quotes '' would do the same, you could use double line quotes,

or single line quotes

When displaying text that a variable contains we can insert the variable inside the parenthesis,

You can also do maths,

Variables

A variable holds data of any one of the data types. A variable consists of two parts, the identifier and the data. identifier = data. There are rules around what the identifier can be, it cannot begin with numbers 1 = 1 or 1number = 1. It must begin with either an underscore _ or a letter abc. It cannot be a Python keyword or contain any symbols other than _.

Comments

A comment is a line of code that when run the interpreter ignores. They can be used to tell other people what your code does. They look like this

User Input

Input can be gathered from the user using the input() function. They can be stored inside variables and printed.

You could also use concatenation (Which is the joining of strings) to provide a response from the computer.

Notice how in print("Hello,", name) I used a comma after the string to join the strings, and in print("How is your day " + name + "?") I used plus signs. I did this because when you use a comma an extra space is added after the string, but when you use a plus sign no extra space is added.

That is it for our first python tutorial, keep an eye out for more and please comment if you want more and if this helped!

Cheers!,
ChickenTendys
Part 2

You are viewing a single comment. View All
[deleted]

This: True or Fals, should be: True or False