Deck 1: Python Programming: Output and Data Types
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/48
Play
Full screen (f)
Deck 1: Python Programming: Output and Data Types
1
What is the output of the following code :
Print 9//2
A)4.5
B)4.0
C)4
D)Error
Print 9//2
A)4.5
B)4.0
C)4
D)Error
4
2
Which function overloads the >> operator?
A)more()
B)gt()
C)ge()
D)rshift()
A)more()
B)gt()
C)ge()
D)rshift()
rshift()
3
What is the output of the following program :
I = 0
While i < 3:
Print i
Print i+1
A)0 2 1 3 2 4
B)0 1 2 3 4 5
C)0 1 1 2 2 3
D)1 0 2 4 3 5
I = 0
While i < 3:
Print i
Print i+1
A)0 2 1 3 2 4
B)0 1 2 3 4 5
C)0 1 1 2 2 3
D)1 0 2 4 3 5
0 1 1 2 2 3
4
Which module in Python supports regular expressions?
A)re
B)regex
C)pyregex
D)None of the above
A)re
B)regex
C)pyregex
D)None of the above
Unlock Deck
Unlock for access to all 48 flashcards in this deck.
Unlock Deck
k this deck
5
What is the output of the following program :
Print 0.1 + 0.2 == 0.3
A)True
B)False
C)Machine dependent
D)Error
Print 0.1 + 0.2 == 0.3
A)True
B)False
C)Machine dependent
D)Error
Unlock Deck
Unlock for access to all 48 flashcards in this deck.
Unlock Deck
k this deck
6
Which of these is not a core data type?
A)Lists
B)Dictionary
C)Tuples
D)Class
A)Lists
B)Dictionary
C)Tuples
D)Class
Unlock Deck
Unlock for access to all 48 flashcards in this deck.
Unlock Deck
k this deck
7
What data type is the object below?
L = [1, 23, „hello?, 1]
A)List
B)Dictionary
C)Tuple
D)Array
L = [1, 23, „hello?, 1]
A)List
B)Dictionary
C)Tuple
D)Array
Unlock Deck
Unlock for access to all 48 flashcards in this deck.
Unlock Deck
k this deck
8
What is the output of the following program :
Def myfunc(a):
A = a + 2
A = a * 2
Return a
Print myfunc(2)
A)8
B)16
C)Indentation Error
D)Runtime Error
Def myfunc(a):
A = a + 2
A = a * 2
Return a
Print myfunc(2)
A)8
B)16
C)Indentation Error
D)Runtime Error
Unlock Deck
Unlock for access to all 48 flashcards in this deck.
Unlock Deck
k this deck
9
What is the output of the expression : 3*1**3
A)27
B)9
C)3
D)1
A)27
B)9
C)3
D)1
Unlock Deck
Unlock for access to all 48 flashcards in this deck.
Unlock Deck
k this deck
10
What is the output of the following program :
Print '{0:.2}'.format(1.0 / 3)
A)0.333333
B)0.33
C)0.333333:-2
D)Error
Print '{0:.2}'.format(1.0 / 3)
A)0.333333
B)0.33
C)0.333333:-2
D)Error
Unlock Deck
Unlock for access to all 48 flashcards in this deck.
Unlock Deck
k this deck
11
What is the output of the following program :
Print '{0:-2%}'.format(1.0 / 3)
A)0.33
B)0.33%
C)33.33%
D)33%
Print '{0:-2%}'.format(1.0 / 3)
A)0.33
B)0.33%
C)33.33%
D)33%
Unlock Deck
Unlock for access to all 48 flashcards in this deck.
Unlock Deck
k this deck
12
What is the output of the following program :
I = 0
While i < 3:
Print I
I += 1
Else:
Print 0
A)0 1 2 3 0
B)0 1 2 0
C)0 1 2
D)Error
I = 0
While i < 3:
Print I
I += 1
Else:
Print 0
A)0 1 2 3 0
B)0 1 2 0
C)0 1 2
D)Error
Unlock Deck
Unlock for access to all 48 flashcards in this deck.
Unlock Deck
k this deck
13
What is the output of the following program :
I = 0
While i < 5:
Print(i)
I += 1
If i == 3:
Break
Else:
Print(0)
A)0 1 2 0
B)0 1 2
C)Error
D)None of the above
I = 0
While i < 5:
Print(i)
I += 1
If i == 3:
Break
Else:
Print(0)
A)0 1 2 0
B)0 1 2
C)Error
D)None of the above
Unlock Deck
Unlock for access to all 48 flashcards in this deck.
Unlock Deck
k this deck
14
What is the output of the following program :
Print 'cd'.partition('cd')
A)(„cd?)
B)(")
C)(„cd?, ", ")
D)(", „cd?, ")
Print 'cd'.partition('cd')
A)(„cd?)
B)(")
C)(„cd?, ", ")
D)(", „cd?, ")
Unlock Deck
Unlock for access to all 48 flashcards in this deck.
Unlock Deck
k this deck
15
What is the output of the following program :
Print 'abcefd'.replace('cd', '12')
A)ab1ef2
B)abcefd
C)ab1efd
D)ab12ed2
Print 'abcefd'.replace('cd', '12')
A)ab1ef2
B)abcefd
C)ab1efd
D)ab12ed2
Unlock Deck
Unlock for access to all 48 flashcards in this deck.
Unlock Deck
k this deck
16
What will be displayed by the following code?
Def f(value, values):
V = 1
Values[0] = 44
T = 3
V = [1, 2, 3]
F(t, v)
Print(t, v[0])
A)1 1
B)1 44
C)3 1
D)3 44
Def f(value, values):
V = 1
Values[0] = 44
T = 3
V = [1, 2, 3]
F(t, v)
Print(t, v[0])
A)1 1
B)1 44
C)3 1
D)3 44
Unlock Deck
Unlock for access to all 48 flashcards in this deck.
Unlock Deck
k this deck
17
Predict the output of following python programs
Dictionary1 = {'Google' : 1,'Facebook' : 2,'Microsoft' : 3}
Dictionary2 = {'GFG' : 1,'Microsoft' : 2,'Youtube' : 3}
Dictionary1.update(dictionary2);
For key, values in dictionary1.items():
Print(key, values)
A)Compilation error
B)Runtime error
C)(„Google?, 1)
(„Facebook?, 2)
(„Youtube?, 3)
(„Microsoft?, 2)
(„GFG?, 1)
D)None of these
Dictionary1 = {'Google' : 1,'Facebook' : 2,'Microsoft' : 3}
Dictionary2 = {'GFG' : 1,'Microsoft' : 2,'Youtube' : 3}
Dictionary1.update(dictionary2);
For key, values in dictionary1.items():
Print(key, values)
A)Compilation error
B)Runtime error
C)(„Google?, 1)
(„Facebook?, 2)
(„Youtube?, 3)
(„Microsoft?, 2)
(„GFG?, 1)
D)None of these
Unlock Deck
Unlock for access to all 48 flashcards in this deck.
Unlock Deck
k this deck
18
What is the output of the following program?
Dictionary1 = {'GFG' : 1,'Google' : 2,'GFG' : 3}
Print(dictionary1['GFG']);
A)Compilation error due to duplicate keys
B)Runtime time error due to duplicate keys
C)3
D)1
Dictionary1 = {'GFG' : 1,'Google' : 2,'GFG' : 3}
Print(dictionary1['GFG']);
A)Compilation error due to duplicate keys
B)Runtime time error due to duplicate keys
C)3
D)1
Unlock Deck
Unlock for access to all 48 flashcards in this deck.
Unlock Deck
k this deck
19
What is the output of the following program?
Temp = dict()
Temp['key1'] = {'key1' : 44, 'key2' : 566}
Temp['key2'] = [1, 2, 3, 4]
For (key, values) in temp.items():
Print(values, end = "")
A)Compilation error
B){„key1?: 44, „key2?: 566}[1, 2, 3, 4]
C)Runtime error
D)None of the above
Temp = dict()
Temp['key1'] = {'key1' : 44, 'key2' : 566}
Temp['key2'] = [1, 2, 3, 4]
For (key, values) in temp.items():
Print(values, end = "")
A)Compilation error
B){„key1?: 44, „key2?: 566}[1, 2, 3, 4]
C)Runtime error
D)None of the above
Unlock Deck
Unlock for access to all 48 flashcards in this deck.
Unlock Deck
k this deck
20
What is the output of the following program?
Data = [2, 3, 9]
Temp = [[x for x in[data]]
For x in range(3)]
Print (temp)
A)[[[2, 3, 9]], [[2, 3, 9]], [[2, 3, 9]]]
B)[[2, 3, 9], [2, 3, 9], [2, 3, 9]]
C)[[[2, 3, 9]], [[2, 3, 9]]]
D)None of these
Data = [2, 3, 9]
Temp = [[x for x in[data]]
For x in range(3)]
Print (temp)
A)[[[2, 3, 9]], [[2, 3, 9]], [[2, 3, 9]]]
B)[[2, 3, 9], [2, 3, 9], [2, 3, 9]]
C)[[[2, 3, 9]], [[2, 3, 9]]]
D)None of these
Unlock Deck
Unlock for access to all 48 flashcards in this deck.
Unlock Deck
k this deck
21
What is the output of the following program?
Data = [x for x in range(5)]
Temp = [x for x in range(7) if x in data and x%2==0]
Print(temp)
A)[0, 2, 4, 6]
B)[0, 2, 4]
C)[0, 1, 2, 3, 4, 5]
D)Runtime error
Data = [x for x in range(5)]
Temp = [x for x in range(7) if x in data and x%2==0]
Print(temp)
A)[0, 2, 4, 6]
B)[0, 2, 4]
C)[0, 1, 2, 3, 4, 5]
D)Runtime error
Unlock Deck
Unlock for access to all 48 flashcards in this deck.
Unlock Deck
k this deck
22
What is the output of the following program?
L1 = [1, 2, 3, 4]
L2 = L1
L3 = L1.copy()
L4 = list(L1)
L1[0] = [5]
Print(L1, L2, L3, L4)
A)[5, 2, 3, 4] [5, 2, 3, 4] [1, 2, 3, 4] [1, 2, 3, 4]
B)[[5], 2, 3, 4] [[5], 2, 3, 4] [[5], 2, 3, 4] [1, 2, 3, 4]
C)[5, 2, 3, 4] [5, 2, 3, 4] [5, 2, 3, 4] [1, 2, 3, 4]
D)[[5], 2, 3, 4] [[5], 2, 3, 4] [1, 2, 3, 4] [1, 2, 3, 4]
L1 = [1, 2, 3, 4]
L2 = L1
L3 = L1.copy()
L4 = list(L1)
L1[0] = [5]
Print(L1, L2, L3, L4)
A)[5, 2, 3, 4] [5, 2, 3, 4] [1, 2, 3, 4] [1, 2, 3, 4]
B)[[5], 2, 3, 4] [[5], 2, 3, 4] [[5], 2, 3, 4] [1, 2, 3, 4]
C)[5, 2, 3, 4] [5, 2, 3, 4] [5, 2, 3, 4] [1, 2, 3, 4]
D)[[5], 2, 3, 4] [[5], 2, 3, 4] [1, 2, 3, 4] [1, 2, 3, 4]
Unlock Deck
Unlock for access to all 48 flashcards in this deck.
Unlock Deck
k this deck
23
What is the output of the following program?
Import sys
L1 = tuple()
Print(sys.getsizeof(L1), end = " ")
L1 = (1, 2)print(sys.getsizeof(L1), end = " ")
L1 = (1, 3, (4, 5))
Print(sys.getsizeof(L1), end = " ")
L1 = (1, 2, 3, 4, 5, [3, 4], 'p', '8', 9.777, (1, 3))
Print(sys.getsizeof(L1))
A)0 2 3 10
B)32 34 35 42
C)48 64 72 128
D)48 144 192 480
Import sys
L1 = tuple()
Print(sys.getsizeof(L1), end = " ")
L1 = (1, 2)print(sys.getsizeof(L1), end = " ")
L1 = (1, 3, (4, 5))
Print(sys.getsizeof(L1), end = " ")
L1 = (1, 2, 3, 4, 5, [3, 4], 'p', '8', 9.777, (1, 3))
Print(sys.getsizeof(L1))
A)0 2 3 10
B)32 34 35 42
C)48 64 72 128
D)48 144 192 480
Unlock Deck
Unlock for access to all 48 flashcards in this deck.
Unlock Deck
k this deck
24
What is the output of the following program?
T = (1, 2, 3, 4, 5, 6, 7, 8)
Print(T[T.index(5)], end = " ")
Print(T[T[T[6]-3]-6])
A)4 0
B)5 8
C)5 IndexError
D)4 1
T = (1, 2, 3, 4, 5, 6, 7, 8)
Print(T[T.index(5)], end = " ")
Print(T[T[T[6]-3]-6])
A)4 0
B)5 8
C)5 IndexError
D)4 1
Unlock Deck
Unlock for access to all 48 flashcards in this deck.
Unlock Deck
k this deck
25
What is the output of the following program?
L = [1, 3, 5, 7, 9]
Print(L.pop(-3), end = ' ')
Print(L.remove(L[0]), end = ' ')
Print(L)
A)5 None [3, 7, 9]
B)5 1 [3, 7, 9]
C)5 1 [3, 7, 9].
D)5 None [1, 3, 7, 9]
L = [1, 3, 5, 7, 9]
Print(L.pop(-3), end = ' ')
Print(L.remove(L[0]), end = ' ')
Print(L)
A)5 None [3, 7, 9]
B)5 1 [3, 7, 9]
C)5 1 [3, 7, 9].
D)5 None [1, 3, 7, 9]
Unlock Deck
Unlock for access to all 48 flashcards in this deck.
Unlock Deck
k this deck
26
What is the output of the following program?
Def REVERSE(L):
(L)reverse()
Return(L)
Def YKNJS(L):
List = list()
List.extend(REVERSE(L))
Print(List)
L = [1, 3.1, 5.31, 7.531]
YKNJS(L )
A)[1, 3.1, 5.31, 7.531]
B)[7.531, 5.31, 3.1, 1]
C)IndexError
D)AttributeError: „NoneType? object has no attribute „REVERSE?
Def REVERSE(L):
(L)reverse()
Return(L)
Def YKNJS(L):
List = list()
List.extend(REVERSE(L))
Print(List)
L = [1, 3.1, 5.31, 7.531]
YKNJS(L )
A)[1, 3.1, 5.31, 7.531]
B)[7.531, 5.31, 3.1, 1]
C)IndexError
D)AttributeError: „NoneType? object has no attribute „REVERSE?
Unlock Deck
Unlock for access to all 48 flashcards in this deck.
Unlock Deck
k this deck
27
What is the output of the following program?
From math import sqrt
L1 = [x**2
For x in range(10)].pop()
L1 + = 19print(sqrt(L1), end = " ")
L1 = [x**2 for x in reversed(range(10))].pop()
L1 + = 16
Print(int(sqrt(L1)))
A)10.0 4.0
B)4.3588 4
C)10 .0 4
D)10.0 0
From math import sqrt
L1 = [x**2
For x in range(10)].pop()
L1 + = 19print(sqrt(L1), end = " ")
L1 = [x**2 for x in reversed(range(10))].pop()
L1 + = 16
Print(int(sqrt(L1)))
A)10.0 4.0
B)4.3588 4
C)10 .0 4
D)10.0 0
Unlock Deck
Unlock for access to all 48 flashcards in this deck.
Unlock Deck
k this deck
28
What is the output of the following program?
D = dict()
For x in enumerate(range(2)):
D[x[0]] = x[1]
D[x[1]+7] = x[0]
Print(D)
A)KeyError
B){0: 1, 7: 0, 1: 1, 8: 0}
C){0: 0, 7: 0, 1: 1, 8: 1}
D){1: 1, 7: 2, 0: 1, 8: 1}
D = dict()
For x in enumerate(range(2)):
D[x[0]] = x[1]
D[x[1]+7] = x[0]
Print(D)
A)KeyError
B){0: 1, 7: 0, 1: 1, 8: 0}
C){0: 0, 7: 0, 1: 1, 8: 1}
D){1: 1, 7: 2, 0: 1, 8: 1}
Unlock Deck
Unlock for access to all 48 flashcards in this deck.
Unlock Deck
k this deck
29
What is the output of the following program?
D = {1 : 1, 2 : '2', '1' : 1, '2' : 3}
D['1'] = 2
Print(D[D[D[str(D[1])]]])
A)2
B)3
C)„2?
D)KeyError
D = {1 : 1, 2 : '2', '1' : 1, '2' : 3}
D['1'] = 2
Print(D[D[D[str(D[1])]]])
A)2
B)3
C)„2?
D)KeyError
Unlock Deck
Unlock for access to all 48 flashcards in this deck.
Unlock Deck
k this deck
30
What is the output of the following program?
D = dict()
For i in range (3):
For j in range(2):
D[i] = j
Print(D)
A){0: 0, 1: 0, 2: 0}
B){0: 1, 1: 1, 2: 1}
C){0: 0, 1: 0, 2: 0, 0: 1, 1: 1, 2: 1}
D)TypeError: Immutable object
D = dict()
For i in range (3):
For j in range(2):
D[i] = j
Print(D)
A){0: 0, 1: 0, 2: 0}
B){0: 1, 1: 1, 2: 1}
C){0: 0, 1: 0, 2: 0, 0: 1, 1: 1, 2: 1}
D)TypeError: Immutable object
Unlock Deck
Unlock for access to all 48 flashcards in this deck.
Unlock Deck
k this deck
31
What is the output of the following program?
From math import *
A = 2.13b = 3.7777
C = -3.12
Print(int(a), floor(b), ceil(c), fabs(c))
A)2 3 -4 3
B)2 3 -3 3.12
C)2 4 -3 3
D)2 3 -4 3.12
From math import *
A = 2.13b = 3.7777
C = -3.12
Print(int(a), floor(b), ceil(c), fabs(c))
A)2 3 -4 3
B)2 3 -3 3.12
C)2 4 -3 3
D)2 3 -4 3.12
Unlock Deck
Unlock for access to all 48 flashcards in this deck.
Unlock Deck
k this deck
32
What is the output of the following program?
Import string
Line1 = "And Then There Were None"
Line2 = "Famous In Love"
Line3 = "Famous Were The Kol And Klaus"
Line4 = Line1 + Line2 + Line3
Print(string.find(Line1, 'Were'), string.count((Line4), 'And'))
A)True 1
B)15 2
C)(15, 2)
D)True 2
Import string
Line1 = "And Then There Were None"
Line2 = "Famous In Love"
Line3 = "Famous Were The Kol And Klaus"
Line4 = Line1 + Line2 + Line3
Print(string.find(Line1, 'Were'), string.count((Line4), 'And'))
A)True 1
B)15 2
C)(15, 2)
D)True 2
Unlock Deck
Unlock for access to all 48 flashcards in this deck.
Unlock Deck
k this deck
33
What is the output of the following program?line = "What will have so will"L = line.split('a')for i in L:print(i, end=' ')
A)[„What?, „will?, „have?, „so?, „will?]
B)Wh t will h ve so will
C)What will have so will
D)[„Wh?, „t will h?, „ve so will?]
A)[„What?, „will?, „have?, „so?, „will?]
B)Wh t will h ve so will
C)What will have so will
D)[„Wh?, „t will h?, „ve so will?]
Unlock Deck
Unlock for access to all 48 flashcards in this deck.
Unlock Deck
k this deck
34
What is the type of each element in sys.argv?
A)set
B)list
C)tuple
D)string
A)set
B)list
C)tuple
D)string
Unlock Deck
Unlock for access to all 48 flashcards in this deck.
Unlock Deck
k this deck
35
What is the length of sys.argv?
A)number of arguments
B)number of arguments + 1
C)number of arguments - 1
D)none of the mentioned
A)number of arguments
B)number of arguments + 1
C)number of arguments - 1
D)none of the mentioned
Unlock Deck
Unlock for access to all 48 flashcards in this deck.
Unlock Deck
k this deck
36
What is the output of the following code?
Def foo(k):
K[0] = 1
Q = [0]
Foo(q)
Print(q)
A)[0].
B)[1].
C)[1, 0].
D)[0, 1].
Def foo(k):
K[0] = 1
Q = [0]
Foo(q)
Print(q)
A)[0].
B)[1].
C)[1, 0].
D)[0, 1].
Unlock Deck
Unlock for access to all 48 flashcards in this deck.
Unlock Deck
k this deck
37
What is the output of the following code?
Def foo(fname, val):
Print(fname(val))
Foo(max, [1, 2, 3])
Foo(min, [1, 2, 3])
A)3 1
B)1 3
C)error
D)none of the mentioned
Def foo(fname, val):
Print(fname(val))
Foo(max, [1, 2, 3])
Foo(min, [1, 2, 3])
A)3 1
B)1 3
C)error
D)none of the mentioned
Unlock Deck
Unlock for access to all 48 flashcards in this deck.
Unlock Deck
k this deck
38
What is the output of the following?
Elements = [0, 1, 2]
Def incr(x):
Return x+1
Print(list(map(elements, incr)))
A)[1, 2, 3].
B)[0, 1, 2].
C)error
D)none of the mentioned
Elements = [0, 1, 2]
Def incr(x):
Return x+1
Print(list(map(elements, incr)))
A)[1, 2, 3].
B)[0, 1, 2].
C)error
D)none of the mentioned
Unlock Deck
Unlock for access to all 48 flashcards in this deck.
Unlock Deck
k this deck
39
What is the output of the following?
Elements = [0, 1, 2]
Def incr(x):
Return x+1
Print(list(map(incr, elements)))
A)[1, 2, 3].
B)[0, 1, 2].
C)error
D)none of the mentioned
Elements = [0, 1, 2]
Def incr(x):
Return x+1
Print(list(map(incr, elements)))
A)[1, 2, 3].
B)[0, 1, 2].
C)error
D)none of the mentioned
Unlock Deck
Unlock for access to all 48 flashcards in this deck.
Unlock Deck
k this deck
40
What is the output of the following?
Def to_upper(k):
Return k.upper()
X = ['ab', 'cd']
Print(list(map(to_upper, x)))
A)[„AB?, „CD?].
B)[„ab?, „cd?].
C)none of the mentioned
D)error
Def to_upper(k):
Return k.upper()
X = ['ab', 'cd']
Print(list(map(to_upper, x)))
A)[„AB?, „CD?].
B)[„ab?, „cd?].
C)none of the mentioned
D)error
Unlock Deck
Unlock for access to all 48 flashcards in this deck.
Unlock Deck
k this deck
41
What is the output of the following?
X = ['ab', 'cd']
Print(len(list(map(list, x))))
A)2
B)4
C)error
D)none of the mentioned
X = ['ab', 'cd']
Print(len(list(map(list, x))))
A)2
B)4
C)error
D)none of the mentioned
Unlock Deck
Unlock for access to all 48 flashcards in this deck.
Unlock Deck
k this deck
42
Program code making use of a given module is called a ______ of the module.
A)Client
B)Docstring
C)Interface
D)Modularity
A)Client
B)Docstring
C)Interface
D)Modularity
Unlock Deck
Unlock for access to all 48 flashcards in this deck.
Unlock Deck
k this deck
43
What is the output of the following piece of code?
#mod1
Def change(a):
B=[x*2 for x in a]
Print(b)
#mod2
Def change(a):
B=[x*x for x in a]
Print(b)
From mod1 import change
From mod2 import change
#mains=[1,2,3]
Change(s)
A)[2,4,6].
B)[1,4,9].
C)[2,4,6]
D)There is a name clash
#mod1
Def change(a):
B=[x*2 for x in a]
Print(b)
#mod2
Def change(a):
B=[x*x for x in a]
Print(b)
From mod1 import change
From mod2 import change
#mains=[1,2,3]
Change(s)
A)[2,4,6].
B)[1,4,9].
C)[2,4,6]
D)There is a name clash
Unlock Deck
Unlock for access to all 48 flashcards in this deck.
Unlock Deck
k this deck
44
What is the output of the following program?
Tday=datetime.date.today()
Print(tday.month())
A)August
B)Aug
C)08
D)8
Tday=datetime.date.today()
Print(tday.month())
A)August
B)Aug
C)08
D)8
Unlock Deck
Unlock for access to all 48 flashcards in this deck.
Unlock Deck
k this deck
45
Which of the following formatting options can be used in order to add „n? blank spaces after a given string „S??
A)print("-ns"%S)
B)print("-ns"%S).
C)print("%ns"%S)
D)print("%-ns"%S)
A)print("-ns"%S)
B)print("-ns"%S).
C)print("%ns"%S)
D)print("%-ns"%S)
Unlock Deck
Unlock for access to all 48 flashcards in this deck.
Unlock Deck
k this deck
46
What is the output of the following program?
F = None
For i in range (5):
With open("data.txt", "w") as f:
If i > 2:break
Print(f.closed)
A)True
B)False
C)None
D)Error
F = None
For i in range (5):
With open("data.txt", "w") as f:
If i > 2:break
Print(f.closed)
A)True
B)False
C)None
D)Error
Unlock Deck
Unlock for access to all 48 flashcards in this deck.
Unlock Deck
k this deck
47
To read the entire remaining contents of the file as a string from a file object infile, we use
A)infile.read(2)
B)infile.read()
C)infile.readline()
D)infile.readlines()
A)infile.read(2)
B)infile.read()
C)infile.readline()
D)infile.readlines()
Unlock Deck
Unlock for access to all 48 flashcards in this deck.
Unlock Deck
k this deck
48
Suppose t = (1, 2, 4, 3), which of the following is incorrect?
A)print(t[3])
B)t[3] = 45
C)print(max(t))
D)print(len(t))
A)print(t[3])
B)t[3] = 45
C)print(max(t))
D)print(len(t))
Unlock Deck
Unlock for access to all 48 flashcards in this deck.
Unlock Deck
k this deck