Exam 1: Basic Python Programming

arrow
  • Select Tags
search iconSearch Question
flashcardsStudy Flashcards
  • Select Tags

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

(Multiple Choice)
4.7/5
(47)

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

(True/False)
4.9/5
(36)

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

(Multiple Choice)
4.9/5
(41)

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

(True/False)
4.9/5
(32)

Which of the following correctly defines a function named myFunc?

(Multiple Choice)
4.9/5
(28)

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

(Multiple Choice)
4.7/5
(39)

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

(Multiple Choice)
4.8/5
(35)

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

(Multiple Choice)
4.7/5
(37)

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

(Multiple Choice)
4.9/5
(35)

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

(True/False)
4.9/5
(40)

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

(Multiple Choice)
4.9/5
(40)

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

(True/False)
4.7/5
(39)

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

(Multiple Choice)
4.7/5
(44)

Python programs require two or more modules.

(True/False)
4.9/5
(36)

What can you use a docstring for?

(Multiple Choice)
4.9/5
(30)

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)

(Multiple Choice)
4.8/5
(35)

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

(True/False)
4.7/5
(40)

How do you describe a function that calls itself?

(Multiple Choice)
4.9/5
(38)

The input function returns a numeric value by default.

(True/False)
4.9/5
(40)

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

(True/False)
4.8/5
(43)
Showing 21 - 40 of 51
close modal

Filters

  • Essay(0)
  • Multiple Choice(0)
  • Short Answer(0)
  • True False(0)
  • Matching(0)