Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

Dictionaries store connections between pieces of

List comprehensions information. Each item in a dictionary is a key-value pair.


A simple dictionary
Slicing a list

Accessing a value

Variables are used to store values. A string is a series of Copying a list


characters, surrounded by single or double quotes. Adding a new key-value pair
Hello world
Looping through all key-value pairs
Hello world with a variable Tuples are similar to lists, but the items in a tuple can't be
modified.
Making a tuple
Concatenation (combining strings) Looping through all keys

If statements are used to test for particular conditions and


respond appropriately. Looping through all the values
Conditional tests

A list stores a series of items in a particular order. You


access items using an index, or within a loop.
Make a list
Your programs can prompt the user for input. All input is
stored as a string.
Get the first item in a list Conditional test with lists Prompting for a value

Get the last item in a list


Assigning boolean values Prompting for numerical input
Looping through a list

A simple if test
Adding items to a list

If-elif-else statements

Making numerical lists

You might also like