Quiz Time
Python

No Short Description Present

Course Related Quiz

# Quiz
1
Discuss
How to install Python ?
Is Python case sensitive when dealing with identifiers?
  • 1] yes
  • 2] no
  • 3] machine dependent
  • 4] none of the mentioned
Solution
2
Discuss
How to install Python ?
What is the maximum possible length of an identifier?
  • 1] 31 characters
  • 2] 63 characters
  • 3] 79 characters
  • 4] none of the mentioned
Solution
3
Discuss
How to install Python ?
Which of the following is invalid?
  • 1] _a = 1
  • 2] __a = 1
  • 3] __str__ = 1
  • 4] none of the mentioned
Solution
4
Discuss
How to install Python ?
Which of the following is an invalid variable?
  • 1] my_string_1
  • 2] 1st_string
  • 3] foo
  • 4] _
Solution
5
Discuss
How to install Python ?
Why are local variable names beginning with an underscore discouraged?
  • 1] they are used to indicate a private variables of a class
  • 2] they confuse the interpreter
  • 3] they are used to indicate global variables
  • 4] they slow down execution
Solution
6
Discuss
How to install Python ?
Which of the following is not a keyword?
  • 1] eval
  • 2] assert
  • 3] nonlocal
  • 4] pass
Solution
7
Discuss
How to install Python ?
All keywords in Python are in _________
  • 1] lower case
  • 2] UPPER CASE
  • 3] Capitalized
  • 4] None of the mentioned
Solution
8
Discuss
How to install Python ?
Which of the following is true for variable names in Python?
  • 1] unlimited length
  • 2] all private members must have leading and trailing underscores
  • 3] underscore and ampersand are the only two special characters allowed
  • 4] none of the mentioned
Solution
9
Discuss
How to install Python ?

Which of the following is an invalid statement?

  • 1] abc = 1,000,000
  • 2] a b c = 1000 2000 3000
  • 3] a,b,c = 1000, 2000, 3000
  • 4] a_b_c = 1,000,000
Solution
10
Discuss
How to install Python ?
Which of the following cannot be a variable?
  • 1] __init__
  • 2] in
  • 3] it
  • 4] on
Solution
11
Discuss
How to install Python ?

What is the output of print 0.1 + 0.2 == 0.3?

  • 1] True
  • 2] False
  • 3] Machine dependent
  • 4] Error
Solution
12
Discuss
How to install Python ?

Which of the following is not a complex number?

  • 1] k = 2 + 3j
  • 2] k = complex(2, 3)
  • 3] k = 2 + 3l
  • 4] k = 2 + 3J
Solution
13
Discuss
How to install Python ?

What is the type of inf?

  • 1] Boolean
  • 2] Integer
  • 3] Float
  • 4] Complex
Solution
14
Discuss
How to install Python ?

What does ~4 evaluate to?

  • 1] -5
  • 2] -4
  • 3] -3
  • 4] +3
Solution
15
Discuss
How to install Python ?

What does ~~~~~~5 evaluate to?

  • 1] +5
  • 2] -11
  • 3] +11
  • 4] -5
Solution
16
Discuss
How to install Python ?

Which of the following is incorrect?

  • 1] x = 0b101
  • 2] x = 0x4f5
  • 3] x = 19023
  • 4] x = 03964
Solution
17
Discuss
How to install Python ?

What is the result of cmp(3, 1)?

  • 1] 1
  • 2] 0
  • 3] True
  • 4] False
Solution
18
Discuss
Variable

Which of these in not a core data type?

  • 1]

    Lists

  • 2]

    Dictionary

  • 3]

    Tuples

  • 4]

    Class

Solution
19
Discuss
Variable

Given a function that does not return any value, What value is thrown by default when executed in shell.

  • 1]

    int

  • 2]

    bool

  • 3]

    void

  • 4]

    None

Solution
20
Discuss
Variable

What will be the output of the following Python code?

>>>str="hello"
>>>str[:2]
>>>

 

  • 1]

    he

  • 2]

    olleh

  • 3]

    lo

  • 4]

    hello

Solution
21
Discuss
Variable

Which of the following will run without errors?

  • 1]

    round(45.8)

  • 2]

    round(7463.123,2,1)

  • 3]

    round()

  • 4]

    round(6352.898,2,5)

Solution
22
Discuss
Variable

What is the return type of function id?

  • 1]

    int

  • 2]

    float

  • 3]

    dict

  • 4]

    bool

Solution
23
Discuss
Variable

In python we do not specify types, it is directly interpreted by the compiler, so consider the following operation to be performed.

>>>x = 13 ? 2

the objective is to make sure x has an integer value, select all that apply

  • 1]

    x = 13 // 2

  • 2]

    x = int(13 / 2)

  • 3]

    x = 13 % 2

  • 4]

    All of the mentioned

Solution
24
Discuss
Variable

What error occurs when you execute the following Python code snippet?

apple = mango

 

  • 1]

    SyntaxError

  • 2]

    NameError

  • 3]

    ValueError

  • 4]

    TypeError

Solution
25
Discuss
Variable

What will be the output of the following Python code snippet?

def example(a):
    a = a + '2'
     a = a*2
    return a
>>>example("hello")

 

  • 1]

    indentation Error

  • 2]

    cannot perform mathematical operation on strings

  • 3]

    hello2

  • 4]

    hello2hello2

Solution
26
Discuss
Variable

What data type is the object below?

L = [1, 23, 'hello', 1]

 

  • 1]

    list

  • 2]

    dictionary

  • 3]

    array

  • 4]

    tuple

Solution
27
Discuss
Variable

In order to store values in terms of key and value we use what core data type.

  • 1]

    tuple

  • 2]

    list

  • 3]

    class

  • 4]

    dictionary

Solution
28
Discuss
Variable

Which of the following results in a SyntaxError?

  • 1]

     ‘”Once upon a time…”, she said.’

  • 2]

    “He said, ‘Yes!'”

  • 3]

    ‘3\’

  • 4]

     ”’That’s okay”’

Solution
29
Discuss
Variable

The following is displayed by a print function call. Select all of the function calls that result in this output.

tom
dick
harry

 

  • 1]

    print(”’tomdickharry”’)

  • 2]
    print('''tom
    \ndick
    \nharry''')
  • 3]
    print('tom
    dick
    harry')
  • 4]

    print(‘tom\ndick\nharry’)

Solution
30
Discuss
Variable

What is the average value of the following Python code snippet?

>>>grade1 = 80
>>>grade2 = 90
>>>average = (grade1 + grade2) / 2

 

  • 1]

    85.0

  • 2]

    85.1

  • 3]

    95.0

  • 4]

    95.1

Solution
31
Discuss
Variable

What is the return value of trunc()?

  • 1]

    int

  • 2]

    bool

  • 3]

    float

  • 4]

    None

Solution
32
Discuss
Variable

Which is the correct operator for power(xy)?

  • 1]

    X^y

  • 2]

    X**y

  • 3]

    X^^y

  • 4]

    None of the mentioned

Solution
33
Discuss
Variable

Which one of these is floor division?

  • 1]

    /

  • 2]

    %

  • 3]

    //

  • 4]

    None of the mentioned

Solution
34
Discuss
Variable

What is the order of precedence in python?

i) Parentheses
ii) Exponential
iii) Multiplication
iv) Division
v) Addition
vi) Subtraction

  • 1]

    i,ii,iii,iv,v,vi

  • 2]

    ii,i,iii,iv,v,vi

  • 3]

    ii,i,iv,iii,v,vi

  • 4]

    i,ii,iii,iv,vi,v

Solution
35
Discuss
Variable

What is the answer to this expression, 22 % 3 is?

  • 1]

    8

  • 2]

    1

  • 3]

    0

  • 4]

    2

Solution
36
Discuss
Variable

Mathematical operations can be performed on a string.

  • 1]

    True

  • 2]

    False

Solution
37
Discuss
Variable

Operators with the same precedence are evaluated in which manner?

  • 1]

    Left to Right

  • 2]

    Right to Left

  • 3]

    Can’t say

  • 4]

    None of the mentioned

Solution
38
Discuss
Variable

What is the output of this expression, 3*1**3?

  • 1]

    23

  • 2]

    13

  • 3]

    1

  • 4]

    3

Solution
39
Discuss
Variable

Which one of the following has the same precedence level?

  • 1]

    Addition and Subtraction

  • 2]

    Multiplication, Division and Addition

  • 3]

    Multiplication, Division, Addition and Subtraction

  • 4]

    Addition and Multiplication

Solution
40
Discuss
Variable

The expression Int(x) implies that the variable x is converted to integer.

  • 1]

    True

  • 2]

    False

Solution
41
Discuss
Variable

Which one of the following has the highest precedence in the expression?

  • 1]

    Exponential

  • 2]

    Addition

  • 3]

    Parentheses

  • 4]

    Multiplication

Solution
42
Discuss
Variable

The value of the expressions 4/(3*(2-1)) and 4/3*(2-1) is the same.

  • 1]

    True

  • 2]

    False

Solution
43
Discuss
Variable

What will be the value of the following Python expression?

4 + 3 % 5

 

  • 1]

    4

  • 2]

    7

  • 3]

    2

  • 4]

    0

Solution
44
Discuss
Variable

 Evaluate the expression given below if A = 16 and B = 15.

A % B // A

 

  • 1]
    0.0
  • 2]

    0

  • 3]

    1.0

  • 4]

    1

Solution
45
Discuss
Variable

Which of the following operators has its associativity from right to left?

  • 1]

    +

  • 2]

    //

  • 3]

    %

  • 4]

    **

Solution
46
Discuss
Variable

What will be the value of x in the following Python expression?

x = int(43.55+2/2)

 

  • 1]

    43

  • 2]

    44

  • 3]

    22

  • 4]

    23

Solution
47
Discuss
Variable

What is the value of the following expression?

2+4.00, 2**4.0

 

  • 1]

    (6.0, 16.0)

  • 2]

    (6.00, 16.00)

  • 3]

    (6, 16)

  • 4]

    (6.00, 16.0)

Solution
48
Discuss
Variable

Which of the following is the truncation division operator?

  • 1]

    /

  • 2]

    %

  • 3]

    //

  • 4]

    |

Solution
49
Discuss
Variable

What are the values of the following Python expressions?

 2**(3**2)
 (2**3)**2
 2**3**2

 

  • 1]

    64, 512, 64

  • 2]

    512, 512, 512

  • 3]

    512, 64, 512

  • 4]

    64, 64, 64

Solution
50
Discuss
Variable

What is the value of the following expression?

8/4/2, 8/(4/2)

 

  • 1]

    (1.0, 4.0)

  • 2]

    (1.0, 1.0)

  • 3]

    (4.0. 1.0)

  • 4]

    (4.0, 4.0)

Solution
51
Discuss
Variable

What is the value of the following expression?

float(22//3+3/3)

 

  • 1]

    8

  • 2]

    8.0

  • 3]

    8.3

  • 4]

    8.33

Solution
52
Discuss
Variable

It is not possible for the two’s complement value to be equal to the original value in any case.

  • 1]

    True

  • 2]

    False

Solution
53
Discuss
Variable

The one’s complement of 110010101 is:

  • 1]

    001101010

  • 2]

    110010100

  • 3]

    110010101

  • 4]

    001101011

Solution
54
Discuss
Keyword

What will be the output of the following Python code snippet?

X=”hi”
print(“05d”%X)

 

  • 1]

    error

  • 2]

    hi000

  • 3]

    000hi

  • 4]

    00000hi

Solution
55
Discuss
Keyword

What will be the output of the following Python expression if x=456?

print("%-06d"%x)

 

  • 1]

    000456

  • 2]

    456

  • 3]

    456000

  • 4]

    error

Solution
56
Discuss
Keyword

What will be the output of the following Python expression if X=345?

print(“%06d”%X)

 

  • 1]

    000000345

  • 2]

    000345

  • 3]

    345000

  • 4]

    345000000

Solution
57
Discuss
Keyword

Which of the following formatting options can be used in order to add ‘n’ blank spaces after a given string ‘S’?

  • 1]

    print(“-ns”%S)

  • 2]

    print(“-ns”%S)

  • 3]

    print(“%ns”%S)

  • 4]

    print(“%-ns”%S)

Solution
58
Discuss
Keyword

What will be the output of the following Python expression if X = -122?

print("-%06d"%x)

 

  • 1]

    -00122

  • 2]

    –00122

  • 3]

    000122

  • 4]

    -000122

Solution
59
Discuss
Keyword

What will be the output of the following Python expression if the value of x is 34?

print(“%f”%x)

 

  • 1]

    34.00000000

  • 2]

    34.000000

  • 3]

    34.0000

  • 4]

    34.00

Solution
60
Discuss
Keyword

What will be the output of the following Python expression if x=56.236?

print("%.2f"%x)

 

  • 1]

    0056.236

  • 2]

    56.23

  • 3]

    56.24

  • 4]

    56.00

Solution
61
Discuss
Keyword

What will be the output of the following Python expression if x=22.19?

print("%5.2f"%x)

 

  • 1]

    22.20

  • 2]

    22.19

  • 3]

    22.00000

  • 4]

    22.1900

Solution
62
Discuss
Keyword

The expression shown below results in an error.

print("-%5d0",989)

 

  • 1]

    True

  • 2]

    False

Solution
63
Discuss
Syntax ( Indentation, Comments )

Bitwise _________ gives 1 if either of the bits is 1 and 0 when both of the bits are 1.

  • 1]

    OR

  • 2]

    AND

  • 3]

    XOR

  • 4]

    NOT

Solution
64
Discuss
Syntax ( Indentation, Comments )

What will be the output of the following Python expression?

4^12

 

  • 1]

    2

  • 2]

    4

  • 3]

    8

  • 4]

    12

Solution
65
Discuss
Syntax ( Indentation, Comments )

Any odd number on being AND-ed with ________ always gives 1. Hint: Any even number on being AND-ed with this value always gives 0.

  • 1]

    10

  • 2]

    2

  • 3]

    1

  • 4]

    0

Solution
66
Discuss
Syntax ( Indentation, Comments )

What will be the value of the following Python expression?

 bin(10-2)+bin(12^4)

 

  • 1]

    0b10000b1000

  • 2]

    0b1000b1000

  • 3]

    0b10001000

  • 4]

    0b10000

Solution
67
Discuss
Syntax ( Indentation, Comments )

Which of the following expressions can be used to multiply a given number ‘a’ by 4?

  • 1]

    a>>4

  • 2]

    a>>2

  • 3]

    a<<4

  • 4]

    a<<2

Solution
68
Discuss
Syntax ( Indentation, Comments )

What will be the output of the following Python code if a=10 and b =20?

a=10
b=20
a=a^b
b=a^b
a=a^b
print(a,b)

 

  • 1]

    20 20

  • 2]

    20 10

  • 3]

    10 10

  • 4]

    10 20

Solution
69
Discuss
Syntax ( Indentation, Comments )

What is the two’s complement of -44?

  • 1]

    10110011

  • 2]

    11101011

  • 3]

    11010100

  • 4]

    1011011

Solution
70
Discuss
Syntax ( Indentation, Comments )

What will be the output of the following Python expression?

~100?

 

  • 1]

    -100

  • 2]

    100

  • 3]

    -101

  • 4]

    101

Solution
71
Discuss
Syntax ( Indentation, Comments )

What will be the output of the following Python expression?

print(4.00/(2.0+2.0))

 

  • 1]

    1

  • 2]

    1.00

  • 3]

    1.0

  • 4]

    Error

Solution
72
Discuss
Syntax ( Indentation, Comments )

What will be the value of X in the following Python expression?

X = 2+9*((3*12)-8)/10

 

  • 1]

    27.2

  • 2]

    28.4

  • 3]

    30.8

  • 4]

    30.0

Solution
73
Discuss
Syntax ( Indentation, Comments )

Which of the following expressions involves coercion when evaluated in Python?

  • 1]

    3.4 + 4.6

  • 2]

    1.7 % 2

  • 3]

    7.9 * 6.3

  • 4]

    4.7 – 1.5

Solution
74
Discuss
Syntax ( Indentation, Comments )

What will be the output of the following Python expression?

24//6%3, 24//4//2

 

  • 1]

    (3,1)

  • 2]

    (1,0)

  • 3]

    (0,3)

  • 4]

    (1,3)

Solution
75
Discuss
Syntax ( Indentation, Comments )

Which among the following list of operators has the highest precedence?

 +, -, **, %, /, <<, >>, |

 

  • 1]

    %

  • 2]

    |

  • 3]

    **

  • 4]

    <<, >>

Solution
76
Discuss
Syntax ( Indentation, Comments )

What will be the value of the following Python expression?

float(4+int(2.39)%2)

 

  • 1]

    4

  • 2]

    4.0

  • 3]

    5

  • 4]

    5.0

Solution
77
Discuss
Syntax ( Indentation, Comments )

Which of the following expressions is an example of type conversion?

  • 1]

    3 + 7

  • 2]

    5.0 + 3

  • 3]

    5.3 + 6.3

  • 4]

    4.0 + float(3)

Solution
78
Discuss
Syntax ( Indentation, Comments )

Which of the following expressions results in an error?

  • 1]

    int(’10.8’)

  • 2]

    float(’10.8’)

  • 3]

    int(‘10’)

  • 4]

    float(‘10’)

Solution
79
Discuss
Syntax ( Indentation, Comments )

What will be the value of the following Python expression?

4+2**5//10

 

  • 1]

    0

  • 2]

    77

  • 3]

    7

  • 4]

    3

Solution
80
Discuss
Syntax ( Indentation, Comments )

The expression 2**2**3 is evaluates as: (2**2)**3.

  • 1]

    True

  • 2]

    False

Solution
81
Discuss
Syntax ( Indentation, Comments )

What will be the output of the following Python code snippet?

bool(‘False’)
bool()

 

  • 1]
    True
    True
  • 2]

    False
    True

  • 3]

    True
    False

  • 4]

    False
    False

Solution
82
Discuss
Syntax ( Indentation, Comments )

What will be the output of the following Python code snippet?

['hello', 'morning'][bool('')]

 

  • 1]

    morning

  • 2]

    hello

  • 3]

    no output

  • 4]

    error

Solution
83
Discuss
Syntax ( Indentation, Comments )

What will be the output of the following Python code snippet?

not(3>4)
not(1&1)

 

  • 1]
    True
    True
  • 2]
    True
    False
  • 3]
    False
    True
  • 4]
    False
    False
Solution
84
Discuss
Syntax ( Indentation, Comments )

What will be the output of the following Python code?

['f', 't'][bool('spam')]

 

  • 1]

    Error

  • 2]

    No output

  • 3]

    f

  • 4]

    t

Solution
85
Discuss
Syntax ( Indentation, Comments )

What will be the output of the following Python code?

l=[1, 0, 2, 0, 'hello', '', []]
list(filter(bool, l))

 

  • 1]

    [1, 2, ‘hello’]

  • 2]

    [1, 0, 2, ‘hello’, ”, []]

  • 3]

    [1, 0, 2, 0, ‘hello’, ”, []]

  • 4]

    Error

Solution
86
Discuss
Syntax ( Indentation, Comments )

What will be the output of the following Python code?

class Truth:
	pass
x=Truth()
bool(x)

 

  • 1]

    error

  • 2]

    false

  • 3]

    true

  • 4]

    pass

Solution
87
Discuss
Syntax ( Indentation, Comments )

What will be the output of the following Python code?

if (9 < 0) and (0 < -9):
    print("hello")
elif (9 > 0) or False:
    print("good")
else:
    print("bad")

 

  • 1]

    bad

  • 2]

    good

  • 3]

    hello

  • 4]

    error

Solution
88
Discuss
Syntax ( Indentation, Comments )

Which of the following Boolean expressions is not logically equivalent to the other three?

  • 1]

    not(-6>10 or-6==10)

  • 2]

    not(-6<10 or-6==10)

  • 3]

    -6>=0 and -6<=10

  • 4]

    not(-6<0 or-6>10)

Solution
89
Discuss
Syntax ( Indentation, Comments )

What will be the output of the following Python code snippet?

not(10<20) and not(10>30)

 

  • 1]

    Error

  • 2]

    No output

  • 3]

    True

  • 4]

    False

Solution
90
Discuss
Syntax ( Indentation, Comments )

What will be the output of the following Python code snippet if x=1?

x<<2

 

  • 1]

    4

  • 2]

    2

  • 3]

    1

  • 4]

    8

Solution
91
Discuss
Syntax ( Indentation, Comments )

What will be the output of the following Python expression?

bin(29)

 

  • 1]

    ‘0b11011’

  • 2]

    ‘0b11111’

  • 3]

    ‘0b11101’

  • 4]

    ‘0b10111’

Solution
92
Discuss
Syntax ( Indentation, Comments )

What will be the value of x in the following Python expression, if the result of that expression is 2?

x>>2

 

  • 1]

    1

  • 2]

    2

  • 3]

    4

  • 4]

    8

Solution
93
Discuss
Syntax ( Indentation, Comments )

What will be the output of the following Python expression?

int(1011)?

 

  • 1]

    1101

  • 2]

    13

  • 3]

    11

  • 4]

    1011

Solution
94
Discuss
Syntax ( Indentation, Comments )

To find the decimal value of 1111, that is 15, we can use the function:

  • 1]

    int(‘1111’,2)

  • 2]

    int(1111,2)

  • 3]

    int(‘1111’,10)

  • 4]

    int(1111,10)

Solution
95
Discuss
Syntax ( Indentation, Comments )

What will be the output of the following Python expression if x=15 and y=12?

x & y

 

  • 1]

    1101

  • 2]

    12

  • 3]

    0b1101

  • 4]

    b1101

Solution
96
Discuss
Syntax ( Indentation, Comments )

Which of the following expressions results in an error?

  • 1]

    int(‘1011’)

  • 2]

    int(1011,2)

  • 3]

    int(‘1011’,23)

  • 4]

    int(1011)

Solution
97
Discuss
Syntax ( Indentation, Comments )

Which of the following represents the bitwise XOR operator?

  • 1]

    !

  • 2]

    |

  • 3]

    ^

  • 4]

    &

Solution
98
Discuss
Syntax ( Indentation, Comments )

What is the value of the following Python expression?

bin(0x8)

 

  • 1]

    ‘0b1000’

  • 2]

    1000

  • 3]

    8

  • 4]

    ‘0bx1000’

Solution
99
Discuss
Syntax ( Indentation, Comments )

What will be the output of the following Python expression?

0x35 | 0x75

 

  • 1]

    118

  • 2]

    117

  • 3]

    119

  • 4]

    116

Solution
# Quiz