Filters
Question type

Study Flashcards

You can use the slice operator to obtain a substring from a string.

A) True
B) False

Correct Answer

verifed

verified

What is the name of the function that contains the starting point of program execution?


A) start
B) main
C) begin
D) enter

E) C) and D)
F) A) and C)

Correct Answer

verifed

verified

Which statement allows a programmer to run a module as a standalone program or import it from the shell?


A) do _module(main)
B) while main != _module
C) if self == "main() ":
D) if __name__ == "__main__":

E) B) and D)
F) B) and C)

Correct Answer

verifed

verified

How do you describe a function that calls itself?


A) self_calling function
B) iterative function
C) derivative function
D) recursive function

E) B) and D)
F) None of the above

Correct Answer

verifed

verified

What is the last line of the output when the following code is executed? X = 2 For exp in range (5) : Print ("%2d.0" % x**exp)


A) 8.0
B) 16
C) 32
D) 16.0

E) B) and C)
F) B) and D)

Correct Answer

verifed

verified

Python programs require two or more modules.

A) True
B) False

Correct Answer

verifed

verified

The while statement uses the syntax while : and is the preferred control statement to iterate over a definite range of sequences.

A) True
B) False

Correct Answer

verifed

verified

The input function returns a numeric value by default.

A) True
B) False

Correct Answer

verifed

verified

A tuple is an immutable sequence of items and does not have mutator methods.

A) True
B) False

Correct Answer

verifed

verified

Which of the following statements creates a tuple containing four items?


A) t = [ 1: 2: 3: 4 ]
B) t = {1, 2, 3, 4}
C) t =t = < 1; 2; 3; 4 >
D) t = (1, 2, 3, 4)

E) A) and B)
F) None of the above

Correct Answer

verifed

verified

What is the last line of output of the following code? Pres = {1:"Washington", 16:"Lincoln", 35: "Kennedy", 40:"Reagan"} For nth in pres: Print("%2d:" % nth,pres[ nth ])


A) 35: Kennedy
B) 40: Reagan
C) 03: Kennedy
D) 04: Reagan

E) A) and D)
F) All of the above

Correct Answer

verifed

verified

What is the output of the following code? sum = 0 Value = 3 While value <= 5: Sum += value Value += 1 Print(sum)


A) 15
B) 10
C) 12
D) 18

E) A) and D)
F) All of the above

Correct Answer

verifed

verified

What is the value of z after the following code is run? Y = 0 Z = 0 For x in range(5,8) : Z = max(x, y) Y = y + x


A) 18
B) 11
C) 7
D) 13

E) C) and D)
F) A) and B)

Correct Answer

verifed

verified

What can you use a docstring for?


A) to hold the name of a document file
B) to create a large string variable
C) to hold data of type string
D) to create a multiline comment

E) A) and C)
F) A) and B)

Correct Answer

verifed

verified

If you print the string "Hello, it is a very \nice day", there will be two lines of output.

A) True
B) False

Correct Answer

verifed

verified

You can use the # symbol to create a multiline comment.

A) True
B) False

Correct Answer

verifed

verified

A dictionary object contains zero or more entries where each entry associates a unique key with a value.

A) True
B) False

Correct Answer

verifed

verified

Which of the following correctly defines a function named myFunc?


A) def myFunc() :
B) func myfunc:
C) myfunc() #
D) int myFunc:

E) B) and D)
F) A) and B)

Correct Answer

verifed

verified

What is the output of the following code? Sum = 0 For value in range(1,4) : Sum += value Print(sum)


A) 5
B) 10
C) 4
D) 6

E) A) and D)
F) A) and C)

Correct Answer

verifed

verified

Which comparison operation returns True if variable x is not equal to variable y?


A) x .ne. y
B) x neq y
C) x <> y
D) x != y

E) B) and C)
F) A) and B)

Correct Answer

verifed

verified

Showing 21 - 40 of 51

Related Exams

Show Answer