Creating and accessing a Tuple

Creating and accessing a Tuple

Lesson Details:
June 29, 2020


I: Introduction

A: Learn basic python programming for beginners

The first class of computer programming that people learn is the language Python. Python is an easy to learn, powerful programming language that has been around since 1991. It was invented by a Dutch programmer named Guido van Rossum who was working at the time for the National Research Institute for Mathematics and Computer Science in The Netherlands. Van Rossum had originally created the programming language as a means for students to write educational games. What he didn’t predict was that his language would soon become one of the most widely used languages in the world. Today, Python is widely used in many different industries, especially in the field of software development. It has also been adapted to be used in the field of machine learning and artificial intelligence.

As you can see, Python is a very versatile language with many practical applications. However, it is not always the easiest language for beginners to learn. That’s why we will be taking this time to focus on some of the basics of how Python works and how you can use it to create your very own “Hello World” program.

II: Body

A: Creating and accessing a tuple

In order to create a simple “Hello World” program in Python, you need to know some basics about coding and how to access information. In Python, information is stored in several different ways, one of which is called a tuple. Tuple is a group of data values that can be accessed together. In order to create a tuple, you need to use the parentheses and specify what data you want included in the tuple. For example: (‘John’, 20, ‘Doe’) This means that you have created a tuple named “myTuple” and it consists of three pieces of information: John, 20 and Doe. You can then access each piece of information separately by using the abbreviation for the variable name followed by a number in parenthesis. For example: myTuple[0] would output John, myTuple[1] would output 20 and myTuple[2] would output Doe.

B: Accessing a list

In addition to tuples, there are also lists. Lists are a bit more complicated than tuples because they contain a collection of tuples. A list in Python can be accessed by using square brackets instead of parentheses. For example: [myTuple[0], myTuple[5], myTuple[9]] would return John, … Continue reading

loader
Course content