Help shape GoConqr. What should we add next?

Quiz

Week 11 - Quiz

hassy saade 15 questions

Take the quiz

Questions in this quiz (15)

  1. 1
    [Python] Consider the following function definition. Which one is correct output?

    >>> def place_stuff(x = 10, y = 20, z = 30):
    return x, y, z
    >>> place_stuff()
    1. A(10, 20, 30)
    2. B{10, 20, 30}
    3. C[1, 2, 3]
    4. D10
    5. E(1, 2, 3)
    6. FAn error message
  2. 2
    [Python] The ___ module allows you to store an object in a file in a standard format for later use by the same or a different program.
    1. AIOlib
    2. BSTDlib
    3. Cpickle
    4. Dmelon
    5. EPyLib
  3. 3[Python] Which one of the following is correct given the code segment below?

    >>> A = ['a', 'b', 'c']
    >>> B = ['1', '2', '3']
    >>> all = [x + y for x in A for y in B]
    >>> print all
    1. A['a', 'b', 'c', '1', '2', '3']
    2. B['a1', 'a2', 'a3', 'b1', 'b2', 'b3', 'c1', 'c2', 'c3']
    3. C['a1', 'b2', 'c3']
    4. D['1a', '1b', '1c', '2a', '2b', '2c', '3a', '3b', '3c']
    5. E['1a', '2a', '3a', '1b', '2b', '3b', '1c', '2c', '3c']
  4. 4[Python] Consider the following code segment. Which one of the following statements is correct?

    import random
    random.sample(range(10), 10)
    1. AThis will generate a range of numbers from 1 to 10, listed in random order.
    2. BThis will generate a range of numbers from 0 to 9, listed in random order
    3. CThis will generate 10 random numbers.
    4. DThis will generate a range of random numbers from -10 to 10.
    5. EAn error message
  5. 5
    [Python] Consider the following function definition. Which one is correct output?

    >>> def place_stuff(x = 10, y = 20, z = 30):
    return x, y, z
    >>> place_stuff(1,2,3)
    1. A(1, 2, 3)
    2. B{1, 2, 3}
    3. C[1, 2, 3]
    4. D1
    5. E1, 2, 3
    6. FAn error message
  6. 6
    [Python] Consider a file "gm.py" listed below. Which of the following is incorrect to run this python file?

    #!/usr/bin/local/python
    print 'Good morning!'
    1. A./gm.py
    2. Bpython gm.py
    3. Cpython < gm.py
    4. Dcat gm.py | python
    5. Eecho gm.py | python
  7. 7
    [Python] One of the simplest re (for regular expression) methods is ___ returns a list that holds matches with a regular expression over a string
    1. Aindex
    2. Bmatch
    3. Cfindall
    4. Dsearchall
    5. Eglobal
  8. 8
    [Python] Which one of the following examples uses a list comprehension to fill a list with powers of 2.
    1. A[2**x for x : range(1, 10)]
    2. B[x*2 in range(1, 10)]
    3. C[x*x for x :: range(1, 10)]
    4. D[2**x for x in range(1, 10)]
    5. E[2**x for x in random.range(1, 10)]
  9. 9[Python] Which one of the code segments makes each element of "items" to be squared, and printed?
    1. Afor x in items : print(x*x)
    2. Bfor x in items { print(x*x) }
    3. Cfor items AS x : print(x*x)
    4. Dfor x : items => print(x*x)
    5. Efor (x in items) print(x*x)
  10. 10
    [Python] Which one of the following statements is incorrect?
    1. APython supports Lambda functions.
    2. BLambda functions in Python might not be bound to a name.
    3. CLambda functions are referred to as anonymous functions.
    4. DLambda functions are more flexible than other functions because they can use an extensive functional features.
    5. EIn its most basic form, Lambda is another syntax for defining a function.

Information

Description
test 2 UNIX Quiz on Week 11 - Quiz, created by hassy saade on 19/11/2018.
Language
English
Views
24
Tags
unixtest 2
Rating
No ratings yet
Rate this quiz
Rate this quiz

More on Python Basics

Feedback

What is it about?

What should we add next?