1/68
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
|---|
No study sessions yet.
What will the following code output?
def my_function(x): x = x * 10
return x
answer = my_function(3)
print(answer)
30
Name and ID are columns to be removed from a data frame, df1. Which of the following is the proper way to do it?
.drop(columns = ['ID', 'Name'])
A CSV consists of only one value, 50. When imported as a Data Frame, it would have rows and columns.
True
A query function selects ____ from a data frame.
a subset of rows
Which of the following is FALSE?
A function in Python can have multiple return values.
How do you EDIT the cell at column 'PQR' and row 27?
df.loc[27, 'PQR'] = value
When using a query() method for a data frame, the column names can sometimes be used without quotes of any kind.
True
df[column].isna() will return you ____.
Series of Booleans
A(n) _____ name is followed by parentheses in Python.
function
If df is a data frame with multiple columns, df['id'] will be expected to be a ____.
one series of values
Which is the correct way to specify keyword arguments?
method(arg1= 1, arg2 = 2)
Which of the following can be considered one column of data in Python?
Series
Which of these is a valid way to use a method?
method( id = "234" )
Which is the correct way to calculate the mean of a column Quiz1?
df[ 'Quiz1' ].mean()
Create a new method using the keyword ____.
def
To do a case-sensitive replace, use the ____ kwarg.
regex
Which of the following can be used to replace an NA value with a zero?
fillna()
A query with a condition is run on a DataFrame. This query is most likely to return ____.
fewer records than the data frame
A blank string is counted as a null value when reported by the info() method of a DataFrame.
False
Will the following line of code work to change the name at index 13?
df[13, 'Name'] = "Preeti"
No, this won't work because of another error
After running the following code, what is the output?
df.loc[10, 'Name'] = 'John'
df.loc[10, 'ID'] = 200
df = df['Name'].replace('John', 'Mike')
print(df.loc[10, 'ID'])
N/A - Error
By default, if the to_numeric() function encounters a string, it will do which of the following?
Is unable to do the conversion and the function crashes with an error.
Which method call correctly can be used to remove a row (with value 1 ) from the DataFrame?
df.drop(index=1)
In python functions, we create a new method using the keyword ____.
def
A method or function could be made to return multiple values.
Kind of True - a method can never return multiple values, but one variable can have multiple values within it.
To see ONE row of data at index 25, you could use ___.
df.loc[index= 25]
In conditional testing using if statements, which keyword should be used to handle all the cases which do not match conditions being tested?
else
name = "Mary"
print(name[2])
What is the output of the code above?
"r"
Which of the following creates a tuple?
numbers = (1, 2, 3)
Which of the following is a correct way of using format strings or f-strings?
print(f"Hello {name}")
Which of the following is a correct formulation of an if statement that tests if x is greater than 10?
if (x > 10):
print("x is greater than 10")
A dictionary is meant for storing ___
series of values, where each value is paired with a name or description
If Julio wants to find out if two TUPLES have duplicate items, he could use the ___ function.
intersection function from SETS
% is the ____ operator.
remainder
What will the following code print?
def sum(*args):
return 3
def my_function(*args):
return sum(args)
print(my_function(1, 2, 3, 4))
3
list_of_numbers = [34, 56, 67, 53, 24]print(list_of_numbers[2:])
67, 53, 24
def my_function(x):
return x + 5
print(my_function(10))
15
What does the return statement do in a function?
Terminates the function and returns execution to the calling line.
phrase = "AZ AR AK CO IL WA PA"
The __ function call returns a total of 3 elements.
phrase.partition(" ")
state = "Colorado"
Which of the following will return the substring "Co" ?
state[:2]
person = {
"name": "John",
"city": "Chicago",
}
To get a list containing "name" and "city", use ___.
person.keys()
person = {
"name": "John",
"city": "Chicago",
}
To get a list containing "John" and "Chicago", use ___.
person["keys"]
my_list = [2, 4, 6, 8]
my_list.append(10)
for i in range( len( my_list ) ):
print( my_list[i] , end = " ")
2 4 6 8 10
What will be the output of the following lines of code?
ssn="982-23-2324"
print(ssn.replace(" " , ""))
982-23-2324
number_list = [5, 10, 15, 20]
print(number_list[3] + 1)
What would be the output of the statements above?
21
What numbers would be generated by range(5, 11, 2)?
5, 7, 9
What numbers would be generated by range(11, 4, -3)?
11, 8, 5
Dictionaries can have duplicate keys.
false
An append method typically adds a value to ____.
the end of a list
By default, when looping through a dictionary, each item in a dictionary is a(n) ____.
key
Peter wants to check if the string "PA" is present in an address, located in cell B5. He should use the __ function.
find
Within Excel, to convert a cell to capitalize each word in the cell text (convert the first letter of each word to uppercase), use function ___.
Proper
A function in excel typically returns ___ value(s).
1
To find out how many characters a cell text value has, use ___.
len()
A function with 3 arguments must return three values.
false
If you use the function COUNTA, and use cells from A1 to A4 as the range, the return value will be ______ ?
1 : 30
2 : 0
3 : Susan
4 : 20
4
Assume the following is the information of a function: ABC ( number1 , number2 [,number3] [, number4] ) How many arguments must be given to this function at minimum?
2
Assume a formula in a cell B2 has the cell reference A$3. The formula is copied over to the cell C4. The formula in C4 will be ____.
B$3
If you use the function COUNT, and use cells from A1 to A4 as the range, the return value will be ______.
1 : 30
2 : 0
3 : Susan
4 : 20
3
Select ALL the valid ranges in which the first column within the range is specified as an absolute reference.
$C3:G3
$C3:G$3
If you use COUNT, and use cells from A1 to A4, the return value will be ______.
1 : Mike
2 :
3 : 30
4 : 20
2
If you use the function COUNTA, and use cells from A1 to A4 as the range, the return value will be ______.
1 : Mike
2 :
3 : 30
4 : 20
3
Select ALL the valid ranges in which the ending column within the range is specified as an absolute reference.
C$3:$G3
list_of_numbers = [ 34, 56, 67, 53, 24]
print(list_of_numbers[ :2])
Which numbers would be selected?
34,56
Which of the following would result in an error in Python?
my_tuple = (1, 3,2)
my_tuple.append(5)
What numbers would be generated by range(5, 11, 2)?
5, 7, 9
name = "Smurfette"
print (name[4:])
What will the output be for the following lines of code in Python?
fette
state = "Pennsylvania"
Which of the following will return the substring "Penn" in Python?
state[0:4]
name = "Smurfette"
print (name[4:6])
What will the output be for the following lines of code in Python?
fe