Working With Lists In Python
The importance of variables in any programming language can’t be emphasised enough. Even if you are a novice, the chances are good that you will have been using variables for quite a while now.
They are the cornerstone of any language and without them we would not be able to accomplish much of anything. However, most of you up until this point have probably only been working with standard variables, variables which can hold single values such as an integer, a single character, or a string of text.
In this tutorial we are going to take a look at a more special type of variable called an array. Arrays can seem quite daunting at first glance but once you get used to working with them you will wonder how you ever managed to program without them.
The reason arrays are special is because they can hold more than one value. Think about this: say you create a variable which contains a line of text like the code below:
myString = “This is a string”
Python makes it easy for us to work with strings as single entities but under the hood your computer treats strings like an array. It sets aside space for each character in memory, and when your application needs to use that string, it will retrieve each character to recreate the whole string.
In other languages an array can be referred to under different names such as an object or a collection. In python it is known as a list, and the best way to get a feel for these special variables is to actually use them.
myList = [‘a’, “string ”,1]
print myList[0]
If you’re feeling a little confused by the code above, don’t worry here is how it works. On the first line we create a variable called myList which contains three different elements; a single character, a string and an integer. The square brackets are important because without them Python would not know that you wanted to create a list.
The second line is where things get interesting because you will notice that we use the print statement and then our variable with the number zero in square brackets next to it.
If you look again at the first line of code you will notice that we create three elements. When working with lists and arrays in general you always start counting from 0. So if you had a list with say ten elements, then you would count from 0 to 9. This is an important concept to keep in mind, especially when you start to use lists within loops which will be covered in another tutorial.
So, you have had a brief introduction to working with lists in Python and although it was only two lines of code, you should see how they can be very useful in your future projects. As you become more advanced you will find that you simply cannot perform certain actions without the use of lists.
other blog entries
Course Directory [training on all levels]
- .NET Classes
- Agile/Scrum Classes
- Ajax Classes
- Android and iPhone Programming Classes
- Blaze Advisor Classes
- C Programming Classes
- C# Programming Classes
- C++ Programming Classes
- Cisco Classes
- Cloud Classes
- CompTIA Classes
- Crystal Reports Classes
- Design Patterns Classes
- DevOps Classes
- Foundations of Web Design & Web Authoring Classes
- Git, Jira, Wicket, Gradle, Tableau Classes
- IBM Classes
- Java Programming Classes
- JBoss Administration Classes
- JUnit, TDD, CPTC, Web Penetration Classes
- Linux Unix Classes
- Machine Learning Classes
- Microsoft Classes
- Microsoft Development Classes
- Microsoft SQL Server Classes
- Microsoft Team Foundation Server Classes
- Microsoft Windows Server Classes
- Oracle, MySQL, Cassandra, Hadoop Database Classes
- Perl Programming Classes
- Python Programming Classes
- Ruby Programming Classes
- Security Classes
- SharePoint Classes
- SOA Classes
- Tcl, Awk, Bash, Shell Classes
- UML Classes
- VMWare Classes
- Web Development Classes
- Web Services Classes
- Weblogic Administration Classes
- XML Classes
- Microsoft Azure AI Fundamentals (AI-900T00)
25 November, 2024 - 25 November, 2024 - Ruby Programming
2 December, 2024 - 4 December, 2024 - VMware vSphere 8.0 with ESXi and vCenter
9 December, 2024 - 13 December, 2024 - RHCSA EXAM PREP
18 November, 2024 - 22 November, 2024 - RED HAT ENTERPRISE LINUX AUTOMATION WITH ANSIBLE
2 December, 2024 - 5 December, 2024 - See our complete public course listing
did you know? HSG is one of the foremost training companies in the United States
Our courses focus on two areas: the most current and critical object-oriented and component based tools, technologies and languages; and the fundamentals of effective development methodology. Our programs are designed to deliver technology essentials while improving development staff productivity.
An experienced trainer and faculty member will identify the client's individual training requirements, then adapt and tailor the course appropriately. Our custom training solutions reduce time, risk and cost while keeping development teams motivated. The Hartmann Software Group's faculty consists of veteran software engineers, some of whom currently teach at several Colorado Universities. Our faculty's wealth of knowledge combined with their continued real world consulting experience enables us to produce more effective training programs to ensure our clients receive the highest quality and most relevant instruction available. Instruction is available at client locations or at various training facilities located in the metropolitan Denver area.
Upcoming Classes
- Microsoft Azure AI Fundamentals (AI-900T00)
25 November, 2024 - 25 November, 2024 - Ruby Programming
2 December, 2024 - 4 December, 2024 - VMware vSphere 8.0 with ESXi and vCenter
9 December, 2024 - 13 December, 2024 - RHCSA EXAM PREP
18 November, 2024 - 22 November, 2024 - RED HAT ENTERPRISE LINUX AUTOMATION WITH ANSIBLE
2 December, 2024 - 5 December, 2024 - See our complete public course listing
consulting services we do what we know ... write software
The coaching program integrates our course instruction with hands on software development practices. By employing XP (Extreme Programming) techniques, we teach students as follows:
Configure and integrate the needed development tools
MOntitor each students progress and offer feedback, perspective and alternatives when needed.
Establish an Action plan to yield a set of deliverables in order to guarantee productive learning.
Establish an Commit to a deliverable time line.
Hold each student accountable to a standard that is comparable to that of an engineer/project manager with at least one year's experience in the field.
These coaching cycles typically last 2-4 weeks in duration.
Business Rule isolation and integration for large scale systems using Blaze Advisor
Develop Java, .NET, Perl, Python, TCL and C++ related technologies for Web, Telephony, Transactional i.e. financial and a variety of other considerations.
Windows and Unix/Linux System Administration.
Application Server Administration, in particular, Weblogic, Oracle and JBoss.
Desperate application communication by way of Web Services (SOAP & Restful), RMI, EJBs, Sockets, HTTP, FTP and a number of other protocols.
Graphics Rich application development work i.e. fat clients and/or Web Clients to include graphic design
Performance improvement through code rewrites, code interpreter enhancements, inline and native code compilations and system alterations.
Mentoring of IT and Business Teams for quick and guaranteed expertise transfer.
Architect both small and large software development systems to include: Data Dictionaries, UML Diagrams, Software & Systems Selections and more