El Code Snippet

Take and Use ... It's cool!

Python: Introduction

Python is a high-level programming language that been around since 1991. It emphasizes readability syntax. The latest version is 3.6.1 and its documentation is located at https://docs.python.org/3/

Let's get some basics out of the way.

First of all, you should install Python 3 on your system. Installation instructions are here: https://www.python.org/downloads/. Installing Python 3 on your computer will help you follow along on you computer. If you don't want to install Python, I will post links that allow you to Hack the Code I write about.


You can use the print() function to write out a string.

Figure 1

Let's write some text to the screen

    # Print a simple statement
    print("Hello there, world!")
    # Print out a math expression
    # Assign variable called val the sum of 8 and 7
    val = 8 + 7;
    # Concatenate and print out a statement with the variable containing the math expression
    print("8 + 7 = " + str(val))

Hack the code yourself: https://repl.it/IlZN/0

More on string manipulation

Figure 2

Additional information regarding string concatenation (adding varying pieces of data together to form a string)

    # concatenate strings by using empty spaces between the quoates
    print('This ' 'and ' 'that ...')
    # you can also 
    anotherStringVariable = ('this is the first part of the line' 
                            ' and this is the second part of the line' 
                            ' and this is the third part of the line')
    # get the position of a character in a string
    myString = "O say can you see ..."
    posOfYou = myString[10:13]
    # reverse the string by leaving the begin & end of [begin:end:step] syntax
    # and using -1 to step backwards
    revString = myString[::-1]

Additional information on how to manipulate strings can be found on Python's Doc website

Hack the code yourself at https://repl.it/Il8y