Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Path: blob/master/17-Advanced Python Objects and Data Structures/07-Advanced Python Objects Test - Solutions.ipynb
Views: 648
Kernel: Python 3
Advanced Python Objects Test
Advanced Numbers
Problem 1: Convert 1024 to binary and hexadecimal representation
In [1]:
Out[1]:
0b10000000000
0x400
Problem 2: Round 5.23222 to two decimal places
In [2]:
Out[2]:
5.23
Advanced Strings
Problem 3: Check if every letter in the string s is lower case
In [3]:
Out[3]:
False
Problem 4: How many times does the letter 'w' show up in the string below?
In [4]:
Out[4]:
12
Advanced
Problem 5: Find the elements in set1 that are not in set2:
In [5]:
Out[5]:
{2}
Problem 6: Find all elements that are in either set:
In [6]:
Out[6]:
{1, 2, 3, 5, 6, 7, 8}
Advanced Dictionaries
Problem 7: Create this dictionary: {0: 0, 1: 1, 2: 8, 3: 27, 4: 64} using a dictionary comprehension.
In [7]:
Out[7]:
{0: 0, 1: 1, 2: 8, 3: 27, 4: 64}
Advanced Lists
Problem 8: Reverse the list below:
In [8]:
Out[8]:
[4, 3, 2, 1]
Problem 9: Sort the list below:
In [9]:
Out[9]:
[1, 2, 3, 4, 5]