Python Syntax
Lesson 1 of 1
  1. 1
    If programming is the act of teaching a computer to have a conversation with a user, it would be most useful to first teach the computer how to speak. In Python, this is accomplished with the print…
  2. 2
    There are two different Python versions. Both Python 2 and Python 3 are used throughout the globe. The most significant difference between the two is how you write a print statement. In Python 3, p…
  3. 3
    When printing things in Python, we are supplying a text block that we want to be printed. Text in Python is considered a specific type of data called a string. A string, so named because they’re …
  4. 4
    As we get more familiar with the Python programming language, we run into errors and exceptions. These are complaints that Python makes when it doesn’t understand what you want it to do. Everyone r…
  5. 5
    In Python, and when programming in general, we need to build systems for dealing with data that changes over time. That data could be the location of a plane, or the time of day, or the television …
  6. 6
    One thing computers are capable of doing exceptionally well is performing arithmetic. Addition, subtraction, multiplication, division, and other numeric calculations are easy to do in most programm…
  7. 7
    Changing the contents of a variable is one of the essential operations. As the flow of a program progresses, data should be updated to reflect changes that have happened. fish_in_clarks_pond = 50 …
  8. 8
    Most of the time, code should be written in such a way that it is easy to understand on its own. However, if you want to include a piece of information to explain a part of your code, you can use t…
  9. 9
    Variables can also hold numeric values. The simplest kind of number in Python is the integer, which is a whole number with no decimal point: int1 = 1 int2 = 10 int3 = -5 A number with a decimal …
  10. 10
    In Python 2, when we divide two integers, we get an integer as a result. When the quotient is a whole number, this works fine: quotient = 6/2 # the value of quotient is now 3, which makes sense Ho…
  11. 11
    We have seen how to define a string with single quotes and with double quotes. If we want a string to span multiple lines, we can also use triple quotes: address_string = “””136 Whowho Rd Apt 7 Wh…
  12. 12
    Sometimes we have a need for variables that are either true or false. This datatype, which can only ever take one of two values, is called a boolean. In Python, we define booleans using the keyword…
  13. 13
    Python automatically assigns a variable the appropriate datatype based on the value it is given. A variable with the value 7 is an integer, 7. is a float, and “7” is a string. Sometimes, we will wa…
  14. 14
    Great! So far we’ve looked at: - Print statements - How to create, modify, and use variables - Arithmetic operations like addition, subtraction, division, and multiplication - How to use comments …

What you'll create

Portfolio projects that showcase your new skills

How you'll master it

Stress-test your knowledge with quizzes that help commit syntax to memory