Pitt computer programming final

0.0(0)
studied byStudied by 0 people
0.0(0)
full-widthCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/68

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

69 Terms

1
New cards

What will the following code output?

def my_function(x): x = x * 10

return x

answer = my_function(3)

print(answer)

30

2
New cards

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'])

3
New cards

A CSV consists of only one value, 50. When imported as a Data Frame, it would have rows and columns.

True

4
New cards

A query function selects ____ from a data frame.

a subset of rows

5
New cards

Which of the following is FALSE?

A function in Python can have multiple return values.

6
New cards

How do you EDIT the cell at column 'PQR' and row 27?

df.loc[27, 'PQR'] = value

7
New cards

When using a query() method for a data frame, the column names can sometimes be used without quotes of any kind.

True

8
New cards

df[column].isna() will return you ____.

Series of Booleans

9
New cards

A(n) _____ name is followed by parentheses in Python.

function

10
New cards

If df is a data frame with multiple columns, df['id'] will be expected to be a ____.

one series of values

11
New cards

Which is the correct way to specify keyword arguments?

method(arg1= 1, arg2 = 2)

12
New cards

Which of the following can be considered one column of data in Python?

Series

13
New cards

Which of these is a valid way to use a method?

method( id = "234" )

14
New cards

Which is the correct way to calculate the mean of a column Quiz1?

df[ 'Quiz1' ].mean()

15
New cards

Create a new method using the keyword ____.

def

16
New cards

To do a case-sensitive replace, use the ____ kwarg.

regex

17
New cards

Which of the following can be used to replace an NA value with a zero?

fillna()

18
New cards

A query with a condition is run on a DataFrame. This query is most likely to return ____.

fewer records than the data frame

19
New cards

A blank string is counted as a null value when reported by the info() method of a DataFrame.

False

20
New cards

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

21
New cards

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

22
New cards

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.

23
New cards

Which method call correctly can be used to remove a row (with value 1 ) from the DataFrame?

df.drop(index=1)

24
New cards

In python functions, we create a new method using the keyword ____.

def

25
New cards

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.

26
New cards

To see ONE row of data at index 25, you could use ___.

df.loc[index= 25]

27
New cards

In conditional testing using if statements, which keyword should be used to handle all the cases which do not match conditions being tested?

else

28
New cards

name = "Mary"

print(name[2])

What is the output of the code above?

"r"

29
New cards

Which of the following creates a tuple?

numbers = (1, 2, 3)

30
New cards

Which of the following is a correct way of using format strings or f-strings?

print(f"Hello {name}")

31
New cards

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")

32
New cards

A dictionary is meant for storing ___

series of values, where each value is paired with a name or description

33
New cards

If Julio wants to find out if two TUPLES have duplicate items, he could use the ___ function.

intersection function from SETS

34
New cards

% is the ____ operator.

remainder

35
New cards

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

36
New cards

list_of_numbers = [34, 56, 67, 53, 24]print(list_of_numbers[2:])

67, 53, 24

37
New cards

def my_function(x):

return x + 5

print(my_function(10))

15

38
New cards

What does the return statement do in a function?

Terminates the function and returns execution to the calling line.

39
New cards

phrase = "AZ AR AK CO IL WA PA"

The __ function call returns a total of 3 elements.

phrase.partition(" ")

40
New cards

state = "Colorado"

Which of the following will return the substring "Co" ?

state[:2]

41
New cards

person = {

"name": "John",

"city": "Chicago",

}

To get a list containing "name" and "city", use ___.

person.keys()

42
New cards

person = {

"name": "John",

"city": "Chicago",

}

To get a list containing "John" and "Chicago", use ___.

person["keys"]

43
New cards

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

44
New cards

What will be the output of the following lines of code?

ssn="982-23-2324"

print(ssn.replace(" " , ""))

982-23-2324

45
New cards

number_list = [5, 10, 15, 20]

print(number_list[3] + 1)

What would be the output of the statements above?

21

46
New cards

What numbers would be generated by range(5, 11, 2)?

5, 7, 9

47
New cards

What numbers would be generated by range(11, 4, -3)?

11, 8, 5

48
New cards

Dictionaries can have duplicate keys.

false

49
New cards

An append method typically adds a value to ____.

the end of a list

50
New cards

By default, when looping through a dictionary, each item in a dictionary is a(n) ____.

key

51
New cards

Peter wants to check if the string "PA" is present in an address, located in cell B5. He should use the __ function.

find

52
New cards

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

53
New cards

A function in excel typically returns ___ value(s).

1

54
New cards

To find out how many characters a cell text value has, use ___.

len()

55
New cards

A function with 3 arguments must return three values.

false

56
New cards

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

57
New cards

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

58
New cards

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

59
New cards

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

60
New cards

Select ALL the valid ranges in which the first column within the range is specified as an absolute reference.

$C3:G3

$C3:G$3

61
New cards

If you use COUNT, and use cells from A1 to A4, the return value will be ______.

1 : Mike

2 :

3 : 30

4 : 20

2

62
New cards

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

63
New cards

Select ALL the valid ranges in which the ending column within the range is specified as an absolute reference.

C$3:$G3

64
New cards

list_of_numbers = [ 34, 56, 67, 53, 24]

print(list_of_numbers[ :2])

Which numbers would be selected?

34,56

65
New cards

Which of the following would result in an error in Python?

my_tuple = (1, 3,2)

my_tuple.append(5)

66
New cards

What numbers would be generated by range(5, 11, 2)?

5, 7, 9

67
New cards

name = "Smurfette"

print (name[4:])

What will the output be for the following lines of code in Python?

fette

68
New cards

state = "Pennsylvania"

Which of the following will return the substring "Penn" in Python?

state[0:4]

69
New cards

name = "Smurfette"

print (name[4:6])

What will the output be for the following lines of code in Python?

fe