codecademy Python Answers Advanced topics in Python

Contents

Also Read :   Codecademy Python Answers Lists And Dictionaries

codecademy-advanced-topics-python

Advanced Topics in Python 1/18 – Iterators for dictionaries

my_dict = { 
    "Name":"prathap",
    "age":21,
    "sex":"M"
    }
print my_dict.items()

Advanced Topics in Python 2/18 – Iterators for dictionaries

my_dict = { 
    "Name":"prathap",
    "age":21,
    "sex":"M"
    }
print my_dict.keys()
print my_dict.values()

Advanced Topics in Python 3/18 – Iterators for dictionaries

my_dict = { 
    "Name":"prathap",
    "age":21,
    "sex":"M"
    }
print my_dict.keys()
print my_dict.values()
for key in my_dict:
    print key,my_dict[key]

Advanced Topics in Python 4/18 – Iterators for dictionaries

evens_to_50 = [i for i in range(51) if i % 2 == ]
print evens_to_50

Advanced Topics in Python 5/18 – Iterators for dictionaries

doubles_by_3 = [x*2 for x in range(1,6) if (x*2) % 3 == ]

# Complete the following line. Use the line above for help.
even_squares = [x**2 for x in range(1,11) if x % 2 == ]

print even_squares

Advanced Topics in Python 6/18 – Iterators for dictionaries

cubes_by_four = [ x**3 for x in range(1,11) if (x**3)%4 ==  ]
print cubes_by_four

Advanced Topics in Python 7/18 – Iterators for dictionaries

Also Read :   Codecademy Python Answers Practice Makes Perfect
l = [i ** 2 for i in range(1, 11)]
# Should be [1, 4, 9, 16, 25, 36, 49, 64, 81, 100]

print l[:10]
print l[:10:3]

Advanced Topics in Python 8/18 – Iterators for dictionaries

my_list = range(1, 11) # List of numbers 1 - 10
print my_list

# Add your code below!
print my_list[::2]

Advanced Topics in Python 9/18 – Iterators for dictionaries

my_list = range(1, 11)

# Add your code below!
backwards = my_list[::-1]
print backwards

Advanced Topics in Python 10/18 – Iterators for dictionaries

to_one_hundred = range(101)
# Add your code below!
backwards_by_tens = to_one_hundred[::-10]
print backwards_by_tens

Advanced Topics in Python 11/18 – Iterators for dictionaries

to_21 = range(1,22)
odds = to_21[::2]
middle_third = to_21[7:14]

Advanced Topics in Python 12/18 – Iterators for dictionaries

my_list = range(16)
print filter(lambda x: x % 3 == , my_list)

Advanced Topics in Python 13/18 – Iterators for dictionaries

languages = ["HTML", "JavaScript", "Python", "Ruby"]
print filter(lambda x: x == "Python",languages)

Advanced Topics in Python 14/18 – Iterators for dictionaries

squares = [ x**2 for x in range(1,11)]
print filter(lambda x: x>=30 and x<=70,squares)

Advanced Topics in Python 15/18 – Iterators for dictionaries

movies = {
	"Monty Python and the Holy Grail": "Great",
	"Monty Python's Life of Brian": "Good",
	"Monty Python's Meaning of Life": "Okay"
}
print movies.items()

Advanced Topics in Python 16/18 – Iterators for dictionaries

threes_and_fives = [ x for x in range(1,16) if(x%3== or x%5==)]
print threes_and_fives

Advanced Topics in Python 17/18 – Iterators for dictionaries

garbled = "!XeXgXaXsXsXeXmX XtXeXrXcXeXsX XeXhXtX XmXaX XI"
ptp = garbled[::-1]
message = ptp[::2]
print message

Advanced Topics in Python 18/18 – Iterators for dictionaries

garbled = "IXXX aXXmX aXXXnXoXXXXXtXhXeXXXXrX sXXXXeXcXXXrXeXt mXXeXsXXXsXaXXXXXXgXeX!XX"
message = filter(lambda x: x!="X",garbled)
print message

Leave a Reply

Your email address will not be published. Required fields are marked *