Home arrow Python arrow Page 4 - Python Conditionals, Lists, Dictionaries, and Operators

Tuples - Python

In our last article we learned how to get input from the user, store data in a variable, and work with some basic operators to manipulate that data. In this article we will learn to use Conditional Statements and possibly create functions. So wipe that mustard off your chin, clean the dishes, and let's get to work.

TABLE OF CONTENTS:
  1. Python Conditionals, Lists, Dictionaries, and Operators
  2. Elif
  3. Lists
  4. Tuples
  5. Dictionaries
  6. Operators
By: James Payne
Rating: starstarstarstarstar / 5
November 26, 2007

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

Another way to store more than one piece of data is through tuples. Tuples work exactly like lists, except the data within them cannot be changed. And you assign value with parentheses instead of brackets. Observe!


#!/usr/local/bin/python


suess = ('I', 'like', 'green', 'eggs', 'and', 'spam')


print suess

print suess[1]

Resulting in:

  I like green eggs and spam

  like

You will notice that you still access an element with the brackets.



 
 
>>> More Python Articles          >>> More By James Payne
 

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

PYTHON ARTICLES

- Python Big Data Company Gets DARPA Funding
- Python 32 Now Available
- Final Alpha for Python 3.2 is Released
- Python 3.1: String Formatting
- Python 3.1: Strings and Quotes
- Python 3.1: Programming Basics and Strings
- Tuples and Other Python Object Types
- The Dictionary Python Object Type
- String and List Python Object Types
- Introducing Python Object Types
- Mobile Programming using PyS60: Advanced UI ...
- Nested Functions in Python
- Python Parameters, Functions and Arguments
- Python Statements and Functions
- Statements and Iterators in Python

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: