QUESTION 11. Which of these is not a core datatypeLists.docx
IRESH3
45 views
12 slides
Oct 31, 2022
Slide 1 of 12
1
2
3
4
5
6
7
8
9
10
11
12
About This Presentation
QUESTION 1
1. Which of these is not a core datatype?
Lists
Dictionary
Tuples
Class
4 points
QUESTION 2
1. Given a function that does not return any value, What value is returned by default when executed in shell.
int
bool
void
None
4 points
QUESTION 3
1. Given the commands ...
QUESTION 1
1. Which of these is not a core datatype?
Lists
Dictionary
Tuples
Class
4 points
QUESTION 2
1. Given a function that does not return any value, What value is returned by default when executed in shell.
int
bool
void
None
4 points
QUESTION 3
1. Given the commands below, what will be the output?
str="hello"
str[:2]
str
he
lo
olleh
hello
4 points
QUESTION 4
1. Choose the answers below that will run without errors.
round(45.8)
round(6352.898,2)
round()
round(7463.123,2,1)
4 points
QUESTION 5
1. What does the function 'id' return?
int
float
bool
dict
4 points
QUESTION 6
1. Choose the modified the statement(s) below that will serve to make sure x has a integer value.
x = 13 ? 2
x = 13 // 2
x = int(13 / 2)
x = 13 / 2
x = 13 % 2
4 points
QUESTION 7
1. Based on the following statement, which error will be thrown?
apple = mango
SyntaxError
NameError
ValueError
TypeError
4 points
QUESTION 8
1. Based on the code, and example input, choose the expected output.
def example(a):
a = a + '2'
a = a*2
return a
example("hello")
indentation Error
cannot perform mathematical operation on strings
hello2
hello2hello2
4 points
QUESTION 9
1. Identify the datatype assigned to L.
L = [1, 23, 'hello', 1]
dictionary
4 points
QUESTION 11
1. Choose the statements that will result in SyntaxError.
‘”Once upon a time…”, she said.’
“He said, “Yes!”"
’3\’
”’That’s okay”’
4 points
QUESTION 12
1. Choose the code that produced the following output.
tom
dick
harry
Select all of the function calls that result in this output
print(”’tom
\ndick
\nharry”’)
print(”’tom
dick
harry”’)
print(‘tom\ndick\nharry’)
print(‘tom
dick
harry’)
4 points
QUESTION 13
1. 13. Choose the output of the code below.
grade1 = 80
grade2 = 90
average = (grade1 + grade2) / 2
85
85.0
95
95.0
4 points
QUESTION 14
1. Choose the statement(s) that will produce the following output.
hello-how-are-you
print(‘hello’, ‘how’, ‘are’, ‘you’)
print(‘hello’, ‘how’, ‘are’, ‘you’ + ‘-’ * 4)
print(‘hello-’ + ‘how-are-you’)
print(‘hello’ + ‘-’ + ‘how’ + ‘-’ + ‘are’ + ‘-’ + ‘you’)
4 points
QUESTION 15
1. What is the return value of trunc() ?
int
bool
float
None
4 points
QUESTION 16
1. Choose the output for the following statement.
"a"+"bc"
a
bc
bca
abc
4 points
QUESTION 17
1. Choose the output for the following statement.
"abcd"[2:]
a
ab
cd
dc
4 points
QUESTION 18
1. Choose an alternate way to execute string.ascii_letters.
string.ascii_lowercase_string.digits
string.ascii_lowercase+string.ascii_upercase
string.letters
string.lowercase_string.upercase
4 points
QUESTION 19
1. Choose the output for the following code.
str1 = 'hello'
str2 = ','
str3 = 'world'
str1[-1:]
olleh
hello
h
o
4 points
QUESTION 20 ...
Size: 305.18 KB
Language: en
Added: Oct 31, 2022
Slides: 12 pages
Slide Content
QUESTION 1
1. Which of these is not a core datatype?
Lists
Dictionary
Tuples
Class
4 points
QUESTION 2
1. Given a function that does not return any value, What value
is returned by default when executed in shell.
int
bool
void
None
4 points
QUESTION 3
1. Given the commands below, what will be the output?
str="hello"
str[:2]
str
he
lo
olleh
hello
4 points
QUESTION 4
1. Choose the answers below that will run without errors.
round(45.8)
round(6352.898,2)
round()
round(7463.123,2,1)
4 points
QUESTION 5
1. What does the function 'id' return?
int
float
bool
dict
4 points
QUESTION 6
1. Choose the modified the statement(s) below that will serve to
make sure x has a integer value.
x = 13 ? 2
x = 13 // 2
x = int(13 / 2)
x = 13 / 2
x = 13 % 2
4 points
QUESTION 7
1. Based on the following statement, which error will be
thrown?
apple = mango
SyntaxError
NameError
ValueError
TypeError
4 points
QUESTION 8
1. Based on the code, and example input, choose the expected
output.
def example(a):
a = a + '2'
a = a*2
return a
example("hello")
indentation Error
cannot perform mathematical operation on strings
hello2
hello2hello2
4 points
QUESTION 9
1. Identify the datatype assigned to L.
L = [1, 23, 'hello', 1]
dictionary
4 points
QUESTION 11
1. Choose the statements that will result in SyntaxError.
‘”Once upon a time…”, she said.’
“He said, “Yes!”"
’3\’
”’That’s okay”’
4 points
QUESTION 12
1. Choose the code that produced the following output.
tom
dick
harry
Select all of the function calls that result in this output
print(”’tom
\ndick
\nharry”’)
print(”’tom
dick
harry”’)
print(‘tom\ndick\nharry’)
print(‘tom
dick
harry’)
4 points
QUESTION 13
1. 13. Choose the output of the code below.
grade1 = 80
grade2 = 90
average = (grade1 + grade2) / 2
85
85.0
95
95.0
4 points
QUESTION 14
1. Choose the statement(s) that will produce the following
output.
hello-how-are-you
print(‘hello’, ‘how’, ‘are’, ‘you’)
print(‘hello’, ‘how’, ‘are’, ‘you’ + ‘-’ * 4)
print(‘hello-’ + ‘how-are-you’)
print(‘hello’ + ‘-’ + ‘how’ + ‘-’ + ‘are’ + ‘-’ + ‘you’)
4 points
QUESTION 15
1. What is the return value of trunc() ?
int
bool
float
None
4 points
QUESTION 16
1. Choose the output for the following statement.
"a"+"bc"
a
bc
bca
abc
4 points
QUESTION 17
1. Choose the output for the following statement.
"abcd"[2:]
a
ab
cd
dc
4 points
QUESTION 18
1. Choose an alternate way to execute string.ascii_letters.
string.ascii_lowercase_string.digits
string.ascii_lowercase+string.ascii_upercase
string.letters
string.lowercase_string.upercase
4 points
QUESTION 19
1. Choose the output for the following code.
str1 = 'hello'
str2 = ','
str3 = 'world'
str1[-1:]
olleh
hello
h
o
4 points
QUESTION 20
1. Which of the following operators cannot be used with strings
?
+
*
-
**
4 points
QUESTION 21
1. Choose the output for the following statement.
print r"\nhello"
a new line and hello
\nhello
the letter r and then hello
Error
4 points
QUESTION 22
1. Choose the output for the following statement.
print 'new' 'line'
Error
Output equivalent to print ‘new\nline’
newline
new line
4 points
QUESTION 23
1. Choose the output for the following statement.
print '\x97\x98'
Error
97
98
\x97\x98
4 points
QUESTION 24
1. Choose the output for the following statement.
str1="helloworld"
str1[::-1]
dlrowolleh
hello
world
helloworld
4 points
QUESTION 25
1. Choose the output for the following statement.
print 0xA + 0xB + 0xC :