curriculum/challenges/english/blocks/quiz-python-basics/67f41242431cbf3db8ca79c7.md
To pass the quiz, you must correctly answer at least 18 of the 20 questions below.
Which of the following functions is used to check if a variable matches a specific data type?
istype()
isdata()
isvariable()
isinstance()
Which of the following is NOT a form of string concatenation?
greeting = 'My name is '
developer = 'Jessica'
greeting += developer
developer = 'Jessica'
greeting = 'My name is ' + developer + '.'
developer = 'Jessica'
age = 30
greeting = 'My name is ' + developer + ' and I am ' + str(age) + ' years old.'
developer = 'Jessica'
greeting = x'My name is {developer}.'
Which of the following functions is used to return the number of the characters in the string?
counting()
length()
iscount()
len()
What will result be in this example?
developer = 'Naomi'
result = developer.endswith('N') # ?
Undefined
True
None
False
What happens when you add a float and an integer?
The result will be an error message.
The result will be None.
The result will be an integer.
The result will be a float.
Which of the following is the correct way to define a function?
define get_sum(num_1, num_2) {
return num_1 + num_2
}
set get_sum(num_1, num_2):
return num_1 + num_2
function get_sum(num_1, num_2) {
return num_1 + num_2
}
def get_sum(num_1, num_2):
return num_1 + num_2
What will be printed to the console?
def greet():
pass
print(greet()) # ?
TypeError
RangeError
Null
None
Which of the following statements is false when naming variables?
Variable names can only start with a letter or an underscore (_), not a number.
Variable names can only contain alphanumeric characters (a-z, A-Z, 0-9) and underscores (_).
Variable names cannot be one of Python's reserved keywords such as if, class, or def.
Variable names must have a max length of 10 characters, otherwise Python will throw an error.
Which of the following is NOT a supported data type in Python?
None
int
float
Generic
Which of the following will return a new string with all characters converted to uppercase?
developer = 'Jessica'
print(developer.isupper()) # JESSICA
developer = 'Jessica'
print(developer.up()) # JESSICA
developer = 'Jessica'
print(developer.toUpper()) # JESSICA
developer = 'Jessica'
print(developer.upper()) # JESSICA
Which of the following functions is used to get input from a user?
read()
cout()
prompt()
input()
What will be the result for the following code?
message = 'Python is fun!'
print(message[0:6]) # ?
'Py'
'fun'
'is'
'Python'
What does the split() method do?
This method is used to split a tuple into a list of substrings.
This method is used to split a float into a list of substrings.
This method is used to split a dictionary into a list of substrings.
This method is used to split a string into a list of substrings.
What will the following print to the console?
example_list = ['example', 'dashed', 'name']
joined_str = ' '.join(example_list)
print(joined_str) # ?
TypeError
'dashed name'
None
'example dashed name'
Which of the following functions is used to create a table of 1 to 1 character mappings for translation?
str.translations()
str.gettranslate()
str.tran()
str.maketrans()
What will be the result for the following code?
int_1 = 4
int_2 = 2
print(int_1 ** int_2) # ?
8
2
4
16
What will be returned from the find() method if no substring occurrences are found in a string?
-2
1
0
-1
Which of the following functions is used to count the times a substring appears in a string?
counter()
hascount()
counting()
count()
What does floor division do in Python?
This operator is used to multiply two numbers and round up the result to the nearest whole number.
This operator is used to convert a float to an integer.
This operator is used to raise a number to the power of another.
This operator is used to divide two numbers and round down the result to the nearest whole number.
Which of the following functions is used to round a number to the nearest whole integer?
floor()
ceil()
float()
round()