id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

arrayIntro


Up until now, you've only had to access one piece of data at a time. But what if you wanted to access a whole bunch of data in a list, such as a list of wavelengths in a galaxy's spectrum? Creating a variable for each wavelength would take forever! Luckily, Python allows you to create just one variable to store an ARRAY (or list) of items! Arrays can be declared and initialized as ARRAY_NAME = ["item 1", "item 2", etc....]. You can access individual elements of an array by their INDEX. In Python, the very first element is actually at index 0 and the next is at index 1, and so on... If I wanted to return "item 1" in the previous example, I would write "return ARRAY_NAME[0]". Click on the "hint" button and copy the code from there into the function "arrayIntro". Then return the word "array" by accessing the right index of myArray!


arrayIntro() → 'array'

...Save, Compile, Run (ctrl-enter)

def arrayIntro():

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Python Help

Post-solution available

Copyright Nick Parlante 2017 - privacy