Python Forum
Intro to Python for Data Science with Datacamp
Thread Rating:
  • 1 Vote(s) - 1 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Intro to Python for Data Science with Datacamp
#1
Hi all,

I am currently following the course Intro to Python for Data Science with Datacamp.com. It is pretty challenging for me as someone who does not know much about coding and such things. But it is interesting to learn more about Python.

My exercise is this:
(1)Print out the second element from the areas list, so 11.25.
(2)Subset and print out the last element of areas, being 9.50. Using a negative index makes sense here!
(3)Select the number representing the area of the living room and print it out.

This is my script based on the exercise:
# Create the areas list
areas = ["hallway", 11.25, "kitchen", 18.0, "living room", 20.0, "bedroom", 10.75, "bathroom", 9.50]

# Print out second element from areas
print(areas[11.25])

# Print out last element from areas
print(areas[9.50])

# Print out the area of the living room
print(areas[20.0])
I get an error on line 5, but I don't really understand what I am doing wrong. Or if I might misunderstood the exercise.

Thanks in advance
Reply


Messages In This Thread
Intro to Python for Data Science with Datacamp - by Sabrusura - Aug-15-2018, 10:55 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
Star Interesting Intro to python problem I can't solve. Honestworker 5 12,394 Mar-04-2021, 02:05 AM
Last Post: BashBedlam
  Intro python using lists Rustypotatoes 2 3,870 Sep-17-2020, 08:30 PM
Last Post: jefsummers
  Python Assignment 3 - Applied Data Science - 2.3 eyavuz21 8 5,016 Jun-06-2020, 08:59 AM
Last Post: eyavuz21
  Applied Data Science with Python - homework 2.2 (Weather plotting) eyavuz21 4 3,411 Jun-03-2020, 07:09 PM
Last Post: eyavuz21
  Foundations of Data Science Data 8.2x tryingtolearnpython 2 3,677 Jul-23-2018, 02:48 AM
Last Post: tryingtolearnpython
  Question code from datacamp I don't understand fad3r 3 3,960 Feb-04-2018, 08:44 PM
Last Post: buran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020