You are on page 1of 4

12/28/21, 3:39 PM Coderbyte

You can share this report with people via the URL above Save PDF

Juan Pablo Vila Automated skill ratings


vilajp@gmail.com
Joined on 12/23/21 Python3
Python 1 - LATAM Beginner

Final score 21%


Data Structures
Code challenge score 0% Beginner

Multiple choice score 36%


Algorithms
Beginner
Cheating score No issues

Copying Not detected

Reference search Low amount

Leaving tab None


Learn more about the skill ratings and chart

Your scorecard Your private notes

Algorithm skills Normal

Code quality & documentation Private notes to share with your team...

Python3 skills

Recommendation

Learn more about how the scorecard works Save

Challenge solutions Expand all details

. Python Age Counting Python3 0/10

Video recordings
Python Age Counting Video 1

Multiple choice answers


1. Which magic/dunder methods allows a class to be used as context manager?

X __iter__, __next__ and raising StopIteration exception when ends

2. An object of type set can be described as…

X ...a mutable collection of unique items


https://coderbyte.com/report/userxdwmukfmv:python-assessment-k05k07jde2 1/4
12/28/21, 3:39 PM Coderbyte

3. We need to Execute a function wrapped with a logger that prints ‘hi’ before the execution
You and ‘bye’ after
can share it. Thewith
this report execution prints
people via something
the URL above on Save
its runtime
PDF
too.
The expected result is:

Hi!
Here is your coffee.
Bye!

Which of these snippets achieves that result, without raising errors?

// Option A

def logger():

   def inner(*args,**kwargs):

       print('Hi!')

       f(*args, **kwargs)

       print('Bye!')

   return inner

@logger

def f1():

   print('Here is your coffee.')

f1()

// Option B

def logger(f):

   def inner():

       print('Hi!')

       f(*args,**kwargs)

       print('Bye!')

       return inner

@logger

def f1():

   print('Here is your coffee.')

f1()

// Option C

def logger(f):

   def inner(*args,**kwargs):

       print('Hi!')

       f(*args, **kwargs)

       print('Bye!')

   return inner

@logger

def f1():

   print('Here is your coffee.')

f1()

// Option D

def logger(f):

   def inner(*args,**kwargs):

       print('Hi!')

       f(*args,**kwargs)

       print('Bye!')

       return inner

@logger

def f1():

   print('Here is your coffee.')

f1()

X Option B

4. We have the following function. We expect to retrieve only comma-separated values, the first being a string, containing the name of the user, the second,
being the highest number of session actions per user.

def high_sess( datafile ):

m = {}

for line in open( datafile ):

// CODE TO FILL

return m

Which code should replace “//CODE TO FILL” line in order to achieve this?

// Option A

Try:

    s, f = line.split(“,”)

Except:

    Continue

If s not in m:

    m[s]= 0

https://coderbyte.com/report/userxdwmukfmv:python-assessment-k05k07jde2 2/4
12/28/21, 3:39 PM Coderbyte
m[s] = max( int(f), m[s])

You can share this report with people via the URL above Save PDF
// Option B

Try:

    s,f = line.split()

Except:

    Break

// Option C

Try:

    s,f = line.split(“,”)

Except:

    If s not in m:

        M[s] = 0

    m[s] = max(int(f), m[s])

// Option D

Try:

    s,f = line.split(“,”)

Except:

    m[s] = max(int(f), m[s])

    Return m

✔ Option A

5. Which is the difference between tuple and list

✔ A list is mutable, whereas a tuple is not

6.  Which of these data types CAN’T be used as a dict key?

✔ List

7. Given this module:


class A:

    x = 1

class B(A):

    pass

class C(A):

    pass

We do 3 executions as follows:
// First exec

>>> print(A.x, B.x, C.x)

// Second exec

>>> B.x = 2

>>> print(A.x, B.x, C.x)

// Third Exec

>>> A.x = 3

>>> print(A.x, B.x, C.x)

Which are gonna be the returns on every execution?

X 1st exec: 1 1 1; 2nd exec: 1 2 1; 3rd exec: 3 3 3

8. Given this  function:


def funct_1(a, b=None, *args, **kwargs):

   print(a, b, args, kwargs)

Which one of these calls is going to print without errors?

X funct_1(3,3,3,k=3, b=3)

9. What happens if I call this function twice?


def foo(a=[]):

a.append(5)

return a

X [5]

10. Given this class A that you import from an external library:

https://coderbyte.com/report/userxdwmukfmv:python-assessment-k05k07jde2 3/4
12/28/21, 3:39 PM Coderbyte

def __init__(self, x, y):

self.x = 1

self._y = y + 10

You can share this report with people via the URL above Save PDF

def _my_method(self, num):

return self.x * num

def my_other_method(self):

self.x * 2

Which one of the following is the right one?

X It’s ok to use any method and attr.

11. Which one of these is not a possible use of single underscore in Python (“_”):

✔ Create dataclasses

12. Given snippets A and B, if someone asks you which is better, what do you say?

# Snippet A:

def f(x):

return 2*x

# Snippet B:

f = lambda x: 2*x

X «Both return the same, so both are right.»

13. This is my code and I need to open the file and append to the end the content of my_row.
Which should the value of OPENING_MODE be?

import csv

my_row = [1, 2, 3]

OPENING_MODE = ??

with open('my_file.csv', OPENING_MODE) as f:

f.write(my_row)

✔ 'a'

14. What is an not a use of an Ellipsis in python (“...”)

X Use it as an alternative to “pass”

Help Guides Blog Privacy Terms Contact What's New

https://coderbyte.com/report/userxdwmukfmv:python-assessment-k05k07jde2 4/4

You might also like