Looking for 1 on 1 Python Programming tutoring?

Get private Python Programming help from one of our highly-trained tutors.

Python is a popular programming language dating back to the early 90s.  It is designed to maximize code readability and is supported by a large number of frameworks, particularly in the web sphere.  The most recent version is Python 3, which differs from Python 2 in that it has a number of improvements to make code easier to write.  As a language, Python is largely used as dynamically typed, object oriented and procedural, but it is multi-paradigm and also supports functional programming and strong typing.  It is also reflective, which means Python programs are able to modify themselves during execution. 

Python programs are usually written in .py files.  The language is split into a number of implementations, including CPython, Jython and IronPython written in C, Java and C# respectively.  These different interpretations add extra pieces of functionality and quirks - such as IronPython is able to make use of the .NET Framework, and JPython integrates with Java classes.  The core concepts remain the same.

Having set up your environment or installed an IDE, you are ready to start writing Python applications.  You can follow the tutorial below to learn some core operations that can be performed in Python.  Note that the lines beginning with # are comments, which means they do not get executed in your application.  The best way to learn is to type out these programs yourself (rather than copy-paste) as you’ll get a better feel for what it means to write Python.

# First, let's do a basic print operation

print ("Hello, world!")

If you run this application you’ll see the text string in the brackets gets output to the console.  This is because ‘print()’ is a method, and we are calling it with an argument (our text).

We can make this a bit more advanced by introducing variables.

# Create a variable and print it

name = "Dave"

print ("Hello " + name)

The + operator when used on text strings concatenates them.  As a result, we will see an output based on the constant “Hello “ being joined with the name in the variable.  If, however, we add numbers together we will instead perform a mathematical operation:

# Let's do some sums

print (1 + 2)

print (1 - 2)

print (9 / 3)

print (2 * 5)

# Two *s raises the number before to the power of the number after

print ((2 * 5) ** 2)

One thing you’ll notice is that the division operator converts the result to a floating point number (3.0) whereas the other operations remain as integers.  If, however, you use a floating point number in the calculation you’ll create a floating point result, as in this example:

# Output will be 10.0, not 10

print (2.0 * 5)

We briefly touched on variables before.  It is important to assign values to a variable before you use it, or you will receive an error:

# This is OK

myVariable = 3

print (myVariable)

# This is not

print (aNewVariable)

We can also do conditional operations on our variables.  Note that the indentation is used to separate code blocks, and until we de-indent our program, we continue to operate inside the ‘if’ block.

# The interior statements will execute as myVariable (3) is

# greater than or equal to 3

if myVariable >= 3:

    print ("Condition passed")

    print ("myVariable is more than 2")

# As a result, this won't execute

else:

    print ("Condition failed")

    print ("myVariable is less than 3")

In this next example we’ll create a list by using square brackets and then iterate over it by using the ‘for’ keyword.  This extracts each value in the list, and puts it in the variable ‘number’ before executing the block of code within the 'for' loop.  Then the code moves on to the next item in the list:

# Let's count!

for number in [1,2,3,4,5]:

    print(number)

The Python code you encounter in the world will be comprised of these elements - methods, loops, conditions and variables.  Understanding these fundamentals is core to being able to move on to more advanced concepts and frameworks, as well as being able to read and write your own Python applications.

Whether you're just starting out or you're an advanced python programmer, we have a tutor that can help you master your python programming coursework. If you're stuck on a question, submit your homework and one of our tutors will help you solve it! If you just want some extra help, contact a python programming tutor for a live tutoring session. We also have a homework library so that you can get some extra homework practice whenever you need it. 

To fulfill our tutoring mission of online education, our college homework help and online tutoring centers are standing by 24/7, ready to assist college students who need homework help with all aspects of Python programming. Our computer science tutors can help with all your projects, large or small, and we challenge you to find better online Python programming tutoring anywhere.

 

Latest News

Read All News
September 16, 2019

Question of the Week

If an address bus needs to be able to address four devices, how many conductors will be required?  What if each of those devices also needs to be able to talk back to the I/O control device? The solution of the previous question of the week can be seen below. The maximum aggregate I/O transfer rate of the system is equal to: 700Kbystes/s + 700 Kbytes...
READ MORE
August 16, 2019

Machine Learning

24HourAnswers now offers college homework help and online tutoring in Machine Learning. To learn more about the subject or request a session with one of our tutors, please view our subject page Machine Learning  
READ MORE
Live Chats