python exam 1

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

How many comparisons are necessary to find the value 86 in the following list using a binary search? 13 25 28 30 39 43 44 58 66 70 78 81 86 88 95

4

Which range is produced by the function call range(4, 10)?

4 5 6 7 8 9

What output is produced by the following code? print(15 + 30)

45

How many times will the following code print the word 'wow'? for val in range(5, 10): print('wow')

5

Which of the following string literals is NOT valid?

""\n""

The base case must eventually be reached. If not, we say that the functions is in a state of infinite recursion

, which is somewhat analogous to an infinite loop.

What value is printed by the following code? my_list = [53, 17, 39, 22, 81, 69] print(my_list[3])

22

What value is printed by the following code?my_list = [53, 17, 39, 22, 81, 69] print(my_list[-3])

22

What value is stored in num after the following code is executed? list = [2, 4, 6, 8, 10] num = 0 for val in list: if val != 6: num = num + val

24

What list of prime values is produced if the prime_sieve program is executed with an input value of 20?

2 3 5 7 11 13 17 19

The parameters to the create_rectangle method represent the upper left corner and lower right corner of the rectangle.

True

The pen color and size determines the color and width of the lines drawn.

True

The position of a circle depends on the current heading of the turtle.

True

The position of text on a Canvas is specified by the first two arguments to the create_text method.

True

The relational operators all return boolean results.

True

The result of a comprehension could always be created using more verbose code.

True

The result of a relational operator can be assigned to a variable.

True

The set method can be used to set the value of a text field.

True

The stop value passed as an argument to the range function is NOT included in the range produced.

True

The subsample method is used to scale an image smaller, but not larger. True

True

The text of a Button can be displayed in various fonts.

True

The turtle circle command can be used to draw a regular polygon.

True

The valid indexes of a tuple run from 0 to one less than the length of the tuple.

True

The value assigned to a variable could be a floating point number.

True

The values stored in a list can be changed.

True

Two functions can have the same name if they are in different modules.

True

Using a while loop to check each input value for correctness is a form of input validation.

True

Using square brackets to retrieve a value will result in a KeyError if the key is not in the dictionary.

True

Variables declared inside a function cannot be accessed from outside that function.

True

When drawing a polygon, the order in which the vertices are listed may matter.

True

When using a dictionary as a record, the name of the attribute is used as the key.

True

Whether text is displayed in bold or italic type is specified in the font descriptor.

True

You can use the is operator to check if a variable contains a certain type of data.

True

Only one radio button displayed in a window can be selected at any time. True False Yes! A window can display multiple sets of radio buttons that are mutually-exclusive within each group. Check My Quick Check Answers Terms of Use

False

Python represents a color using the CMYK color model.

False

Selecting a check button will automatically unselect any other check buttons in its group. True False Yes! Check buttons don't work in formalized groups. They represent individual boolean situations.

False

Text color is determined by the font applied when calling the create_text method.

False

The Die class is part of the Python Standard Library.

False

The Pillow package is part of the Python Standard Library. True False Well done! You need to install the Pillow package before you can use it.

False

The Python programming language was so named after a snake was discovered in the creator's office.

False

The default anchor point for text on a Canvas is the northwest (upper left) corner of the text.

False

The event handler function for a Button must be called handleButton.

False

The leftmost end point of a line segment must be specified as the start point of the line.

False

The maximum number of sides on a Die object is 20.

False

gui

Provides "point and click" interaction with a program

Here's a list of some of the most famous sorting algorithms:

Selection Sort Insertion Sort Bubble Sort Quick Sort Merge Sort Heap Sort

Which of the following identifiers follows the convention for naming Python variables?

Total_Value total_value totalValue TOTAL_VALUE total_value

A Button can display text and an image at the same time.

True

A character string can be used as the condition of an if statement.

True

A check button does not have to have an event handler. True False

True

A class represents a group of similar objects.

True

A comment in a Python program is ignored by the interpreter.

True

A cooperating group of radio buttons is determined by the variable each button updates. True

True

A dash pattern of (8, 3) specifies a series of 8-pixel line segments separated by a 3-pixel gap.

True

A example of a ragged list is a two-dimensional list where each row has a different number of columns.

True

A for loop can be used to compute the sum of all values in a list.

True

A for loop is a good way to access each character in a string.

True

A generator expression has the same basic syntax as a list comprehension.

True

A pass statement can be used as the body of an if statement, for loop, function definition, or class definition.

True

A subclass is a more specific version of its superclass.

True

A two-dimensional list is really a one-dimensional list of one-dimensional lists.

True

A two-dimensional list is suitable for storing tabular data.

True

A while loop affects a program's flow of control.

True

A with statement will automatically close an open file when processing is complete.

True

After a function finishes executing, control returns to the place the function was called.

True

An if statement affects a program's flow of control.

True

An import statement finds a module and binds it to a name you can use in a program.

True

In the palindromes program, a potential palindrome is evaluated by comparing characters at both ends and working inwards.

True

In the palindromes program, the inner loop evaluates one string to see if it is a palindrome.

True

In the palindromes program, the inner loop will not continue comparing characters once the it's determined that the string is not a palindrome.

True

Python comments begin with a hash mark (#) and extend to the end of the line.

True

Python is a general-purpose programming language, appropriate for solving problems in many areas of computing.

True

Python uses the Unicode character set to represent characters.

True

Radio buttons work in a group to provide a set of mutually-exclusive options. True False Exactly! Only one option can be selected at a time.

True

The Greek mathematician Eratosthenes came up with the idea of using a sieve algorithm to find prime numbers.

True

The Pillow package can be used to perform more sophisticated image manipulation than the Tkinter package. True False

True

The Python for loop is what other languages refer to as a for-each loop.

True

The Unicode character set currently represents over 100,000 characters.

True

The best way to read a file line by line is to use a for loop to iterate over the file object itself.

True

The break and continue statements both alter the flow of control in a loop.

True

The event handler for a Button can be specified using a parameter to the Button constructor.

True

The human eye has three types of color receptors that correspond to wavelengths of red, green, and blue.

True

The if clause in a comprehension is optional.

True

The in and is operators both produce boolean results.

True

The in operator can be used to check the contents of a character string or a list.

True

The initializer method of the Person class is called __init__.

True

The input function always returns the read data as a character string.

True

The input, int, and float functions are all built-in functions.

True

The math.pi constant represents pi to 15 decimal places.

True

The open function can be used to open an input file or create an output file.

True

Setting the turtle's speed to 0 turns off the animation of the turtle movement completely. True

true

Swapping two elements in a list requires three assignment statements. True

true

The Python shell has an integrated help system. True

true

The Python shell is great for exploring Python language features. True

true

The Python turtle graphics module is based on the programming language Logo developed in the 1960s.

true

The analysis of the complete I Have a Dream speech shows that four of the top five frequently used letters are vowels.

true

The body of a while loop may never execute.

true

The codes used in Morse Code are influenced by the frequency of letter use in English communication.

true

The content of the dictionary used in the Hello World Translator program is read from an input file

true

The dictionary used in the Hello World Translator program uses the language name as the key.

true

The items method returns a list of key/value tuples for all entries in a dictionary.

true

The math module contains a constant that represents the value pi to several digits.

true

The maximum indexes of a two-dimensional list with 6 rows and 10 columns are 5 and 9, respectively.

true

The output of a Python program run in Thonny appears in the shell window.

true

The pass statement has no effect on the program state.

true

The value of a variable can change throughout a program. True

true

Thonny displays code using syntax highlighting.

true

Thonny has a package manager that lets you install and update external Python packages.

true

When using relational operators to compare character strings, 'Music' comes before 'music'.

true

You can store a value in a variable in the Python shell. True

true

You cannot change the contents of Python character string once it has been created. True

true

Which of the following is NOT a good reason to use a tuple rather than a list?

tuples can hold more elements than lists

Which way would the turtle be facing after executing the command turtle.setheading(135)?

up and left, northwest

If the turtle is currently facing up (north), which way would it be facing after executing the command turtle.right(45)?

up and right (northeast)

Which of the following is a good rule of thumb regarding break and continue statements?

use them sparingly, and only if they make the logic more readable

Which of the following is NOT a principle embraced by the Python programming language?

verbose is better than succint

Given the following line of code, which expression would produce the substring 'ledge'? words = 'Knowledge is power.'

words[4:9]

Given the following line of code, which expression would produce the substring 'snapper'? young = 'whippersnapper'

young[7:14] young[7:] young[-7:] young[7:len(young)] All of the above. All of the above.

What value will the variable stuff hold after the following code is executed?state = 'Mississippi' stuff = {ch.lower() for ch in state if ch != 'i'}

{'m', 's', 'p'}

Strings containing non-alphabetic characters cannot be compared using the relational operators.

false

The Hello World Translator program will produce an error if the language requested is not in the dictionary.

false

The arithmetic operators have a lower precedence than the relational operators.

false

The assignment operator has higher precedence than the arithmetic operators.

false

The body of a for loop cannot contain another for loop.

false

The break statement is essentially the same as a GOTO statement in older programming languages.

false

The continue statement must be executed after a break statement is executed.

false

The effect of the setheading depends on the current heading of the turtle.

false

The expression x ^ y raises the value x to the power y.

false

The from clause of an import statement lets you define an alias for a module or function.

false

The goto command moves the turtle without drawing a line.

false

The input function will produce an error if the value read is not numeric.

false

The less than operator (<) should not be used to compare floating point values.

false

The maximum number of dimensions a Python list can have is 3.

false

The origin point (0, 0) of the turtle coordinate system is in the upper left corner of the graphic screen.

false

The pass statement is useless.

false

The primary difference between lists and tuples is that lists are immutable and tuples are not.

false

The prime_sieve program uses a list of integers and sets the value to 0 when a number is determined not to be prime.

false

The read method of a file object reads the contents of a file one line at a time.

false

The results computed by the standard_deviation program are written out to text data file.

false

The sample function in the random module takes a sample with replacement.

false

The smallest index of any dimension of a two-dimensional list is 1.

false

The standard_deviation program would not work if there were twice as many values in the data file.

false

The start value passed as an argument to the range function cannot be negative.

false

The step value passed as an argument to the range function cannot be negative.

false

The stroke color of a filled turtle shape must be the same as the fill color.

false

The value assigned to a variable must be numeric.

false

The value of the expression len(list) is one less than the number of elements in the list.

false

The values of an object's instance data represent the object's identity.

false

The write method adds a newline character to the end of the output

false

The write method automatically adds line numbers to the output.

false

There is no way to stop an infinite loop.

false

To be sure it has found all possible prime numbers up to a certain number N, the prime_sieve program repeats the sieve algorithm for all values up to N.

false

To change the algorithm for finding a minimum value into one that finds a maximum value, the range used in the for loop would change.

false

Using components from the Python Standard Library is a rare occurrence.

false

When printed, a set containing strings will list the elements in alphabetical order.

false

When using relational operators to compare character strings, 'ZEBRA' comes before 'ALLIGATOR'.

false

You must use a print statement to display the result of an expression in the Python shell.

false

A Python block comment begins with a double slash (//).

fasle

A Python comment cannot appear on a line that contains an executable statement.

fasle

An assignment statement affects a program's flow of control.

fasle

The choice function in the random module lets you choose multiple elements from a list.

fasle

If a variable called user_id refers to the string 'AEinstein12', what is the result of the expression user_id.isalpha()?

faslse

Debugging is the process of:

finding the root cause of an error and fixing it

This is a recursive version of Euclid's Algorithm

for computing GCD, which is particularly efficient compared to other strategies.

Equal contributions of the three components in an RGB color results in various shades of what?

gray

Who developed the Python programming language?

guido van rossum

These are sometimes called logarithmic sorts.

he O(n log n) algorithms require approximately n × log2(n) comparisons.

Of the options given, what values of the variables height, size, and width would cause the following code to set the variable weight to 100? if height < size: weight = 50 if width < 20: print('short') else: if width > 100: weight = 100 println('tall')

height = 15, size = 10, width = 110

Suppose the integer variable hours contains a value that represents a number of hours. Which of the following expressions will compute how many 24-hour periods are represented by that value, without worrying about any leftover hours.

hours // 24

What technique is used to put Unicode characters and strings in order?

lexicographic ordering

What is the default flow of control through a function?

linear

When performing a binary search, how many comparisons are required to find a value in a list of N values, in the worst case?

log2N + 1

Computing the wrong answer is an example of what kind of error?

logic error

What output is produced by the following code? print('oak', 'elm', 'pine', end='!', sep='#')

oak#elm#pine!

The Python type conversion functions are actually what kind of functions?

object constructors

The greatest common divisor (GCD)

of two positive integers is the largest integer that divides both numbers evenly (without producing a remainder).

Python variables are created using an assignment statement. True

true

What operator is used to perform string concatenation in Python?

+

Which of the following is NOT a valid Python identifier? 1stPlace

1stPlace first_place FIRST_PLACE place1 1stPlace

If a variable called address refers to the string '123 Main Street', what is the result of the expression address.find('3')?

2

If the variable str refers to the string 'ABC123XYZ', what does the expression str[3:7] produce?

'123X'

If a variable called business refers to the string 'Time Warner', what is the result of the expression business[6]?

'a'

If the variable machine refers to the string 'computer', what does the expression machine[0:len(machine):2] produce?

'cmue'

If a variable called word refers to the string 'committee', what is the result of the expression word.strip('m')?

'committee'

Which of the following conclusions is NOT true when using relational operators to compare character strings?

'fantastic' comes before 'Great'

If the variable noise refers to the string 'hullaballoo', what does the expression noise[:8] produce?

'hullabal'

If the variable word refers to the string 'programming', what does the expression word[2:] produce?

'ogramming'

Which of the following conclusions is NOT true when using relational operators to compare character strings?

'reset' comes before 'reserve'

If a variable called son refers to the string 'Justin', what is the result of the expression son[-3]?

't'

If the variable blah_blah refers to the string 'gobbledygook', what does the expression blah_blah[-5:] produce?

'ygook'

If the current value of the variable num1 is 2 and the current value of the variable num2 is 3, what value will be stored in num2 after the following line of code is executed? num2 /= num1 * num2

.5

Which range is produced by the function call range(5)?

0 1 2 3 4

If the variable num contains a positive integer, what are the only two possible results of the expression num % 2?

0 and 1

The expression random.randrange(30) will produce a value in what range?

0 to 29

What is the result of the expression math.floor(12.843)?

12

Which range is produced by the function call range(12, 5, -2)?

12 10 8 6

Which value of num will cause the print statement in the following code to be executed? if num < 15: if num + 7 >= 20: print('There you go!')

13

What is the result of the expression max(6, 17)?

17

If a variable called pioneer refers to the string 'Grace Murray Hopper', what is the result of the expression len(pioneer)?

19

What is the result of the expression math.pow(3, 3)?

27

Given the following line of code, what is the value of the expression nums.count(80)? nums = [30, 80, 40, 80, 20, 20, 70, 30, 80]

3

Given the following line of code, what is the value of the expression nums.index(80, 2)? nums = [30, 80, 40, 80, 20, 20, 70, 30, 80]

3

How many comparisons are necessary to find the value 43 in the following list using a binary search? 13 25 28 30 39 43 44 58 66 70 78 81 86 88 95

3

If the value of num is 7 and the value of max is 10, what is the value of num after the following statement is executed? num = max if max < num else max - num

3

What is the result of the expression 43 % 5? 3

3

What is the result of the expression 7 // 2?

3

Given the following line of code, what is the value of the expression nums.index(20)? nums = [30, 80, 40, 80, 20, 20, 70, 30, 80]

4

The expression random.randrange(5, 10) will produce a value in what range?

5 to 9

How many elements can be stored in a two-dimensional list with 5 rows and 10 columns?

50

If the current value of the variable num is 4, what value will be stored in num after the following line of code is executed? num += 2

6

If the current value of the variable size is 2, what value will be stored in size after the following line of code is executed? size *= 3

6

The expression random.randint(6, 12) will produce a value in what range?

6 to 12

If the current value of the variable count is 2, what value will be stored in count after the following line of code is executed? count += count * 3

8

What value is assigned to the variable num by the following statement if the current value of num is 4? num = num * 2

8

Which of the following is a relational operator?

<=

What is a docstring?

A character string used as a comment in a program.

What is the Python Standard Library?

A collection of programming components that can be used in any Python program.

A function can return a boolean result. True

A function can return a boolean result. True

Event Handler

A function that performs an action when the user interacts with a widget

flowchart

A graphical representation of the logic of an algorithm.

natural language

A language that humans use to communicate, such as French or English.

psuedocode

A language that is independent of any particular programming language.

bool

A true or false value.

What causes an infinite loop?

A loop condition that is never false.

What issue must be addressed when printing a long character string?

A regular string literal cannot span across multiple lines.

algorithm

A step-by-step procedure for solving a problem.

What is ASCII?

A subset of Unicode containing primarily English characters and basic symbols.

Why is the input data for the standard_deviation program stored in a list?

Because the data needs to be processed more than once.

Which of the following is an appropriate analogy?

Class: concept of a dog, Object: my dog Fido

widgets

Controls that let the user interact with a program in various ways

What is the output of the following code?die = Die(6) print('Die value:', die)

Die value: 1

A Canvas text string cannot contain a newline (\n) character.

False

A comprehension always produces a list.

False

A polygon or polyline can have at most 10 vertices. True False Excellent! Polygons and polylines can have as many vertices as needed. Check My Quick Check Answers Terms of Use

False

A polyline is created using a call to the create_polyline method. True False Excellent! There is no create_polyline method. You use the same method used to draw a simple line.

False

By default, rectangles and ovals drawn on a Canvas are filled with black.

False

Each check button in a Python program must have its own event handler function. True False Excellent! Multiple check buttons could use the same event handler, or none at all.

False

If left unspecified, the font applied to text displayed on a Canvas is 12-point Lucinda Grande.

False

In Python, a class can only be derived from one parent class

False

The optional argument called mask is used to specify a character that will be displayed in a Text widget instead of the actual characters. True False You got it! The parameter name is called show and it is used in the Entry widget.

False

The size of a Text widget is specified using a string that indicates the width and height in pixels. True False Excellent! That's how the window size is specified. The size of a Text widget is specified using optional parameters.

False

The values passed to the create_polygon method represent the lengths of the edges of the polygon. True You got it! They represent the x and y coordinate values of the polygon's vertices.

False

The variable a radio button updates determines its visual layout. True False Well done! The associated variable has nothing to do with the visual presentation of the button.

False

The webcolors module is part of the Python Standard Library.

False

recursive definition is one that defines something in terms of itself.

For example, we can define a particular series of numbers as follows: t1 = 0 tn = tn-1 + 4

What is the output of the following statement?print('He said \\Expelliarmus\\');

He said \Expelliarmus\

Each call to the factorial function causes a new activation record to be pushed onto the

call stack.

What is the role of the seed value of a random number generator?

It's a number that is the basis of the calculated pseudorandom numbers.

What output is produced by the following code? print('Jan', 'Feb', 'Mar', sep='-')

Jan-Feb-Mar

Which of the following identifiers follows the naming convention for a Python constant?

MAX_PENALTIES

Which of the following would cause a syntax error?

Misspelling a keyword.

Why don't we use natural languages (like English) to program a computer?

Natural languages are semantically ambiguous.

Which image formats are reliably supported by Tkinter? BMP and PNG JPG and PNG PNG and GIF JPG and GIF Right! These are the only two formats you can safely use with the Tkinter package.

PNG and GIF

tkinter

Package that supports GUI development in Python

To display an image on a Canvas, it must be represented using which kind of object? ImageView CanvasImage Image PhotoImage Correct! A PhotoImage can be displayed on a Canvas.

PhotoImage

Python embodies elements of which programming paradigm?

Procedural programming Object-oriented programming Functional programming All of the above

What output does the following code produce? print('Ready', end=' ') print('Set', end='') print('Go')

Ready SetGo

If a variable called greeting refers to the string 'hello', what does the expression greeting.upper() accomplish?

Returns a new string containing the characters 'HELLO'

tcl/tk

Scripting language that supports GUI development

Which Tkinter text field widget allows for multiple lines of input? MLEntry Text Entry MLText Well done! The size of a text widget can include multiple lines of text.

Text

What are the names of the two text field widgets in Tkinter? Entry and TextField EntryField and TextField Text and TextField Text and Entry Yes! The primary difference is the amount of text they accept.

Text and Entry

Which of the following statements is true?

The break statement terminates the loop completely.

Which of the following contribute to the state of a Car object?

The car's color.

input

The data needed by an algorithm to accomplish its task.

output

The data produced by an algorithm.

granularity

The level at which an instruction is expressed.

What is a program's flow of control?

The order in which statements are executed.

What is the syntax of a language?

The rules that determine how words and symbols can be combined.

An object created from a class is called an instance of that class.

True

An object's __str__ method is called automatically when an object is printed.

True

Cropping an Image object does not change the original image file. True

True

Defining a class is an alternative to using a dictionary as a record.

True

Each Person object has its own last name.

True

Each object has its own instance data.

True

Finding a minimum value requires that every element in the list be examined.

True

If an invalid number of sides is provided when a Die object is created, a die with 6 sides is created.

True

If either or both operands to the division operator (//) are floating-point values, then the result will be a floating-point value.

True

In Python, the relational operators can be used to put character strings in alphabetical order.

True

In a programming language, a syntactically valid statement has only one meaning.

True

In some cases, a sentinel value can be used to signal the end of input.

True

Python is dynamically typed, meaning each variable can only store one type of value.

false

Which of the following is NOT an arc type for a Tkinter Canvas? PIESLICE ARC CHORD WEDGE Excellent! This is not an arc type defined in Tkinter.

WEDGE

Overriding occurs in which of the following situations?

When a subclass redefines a method it inherits from a superclass.

Which of the following creates a horizontal line?

Which of the following creates a horizontal line? canvas.create_line(25, 70, 125, 70)

Python variables that represent integers are NOT object reference variables.

false

If a variable called jedi refers to the string 'Yoda', what is the result of the expression jedi * 3?

YodaYodaYoda

Given the following line of code, which list is produced by the expression states[-4:]? states = ['CA', 'WY', 'DE', 'MD', 'VA', 'FL', 'TX']

['MD', 'VA', 'FL', 'TX']

What does the list states contain after the following code is executed? states = ['NJ', 'TN', 'WI', 'UT'] states.extend(['PA', 'KY', 'NY']) states.remove('UT') states.sort(reverse=True)

['WI', 'TN', 'PA', 'NY', 'NJ', 'KY']

What does list contain after the following code is executed?list = [77, 41, 92, 30, 38, 12, 63] list.sort() list.insert(2, 88) list.pop(5)

[12, 30, 88, 38, 41, 77, 92]

What output will the following code produce? list1 = [2, 9, 5, 7] list2 = [1, 4, 2, 3] print(list1 + list2)

[2, 9, 5, 7, 1, 4, 2, 3]

What value will the variable my_list hold after the following line of code is executed? my_list = [num for num in range(1, 20) if num % 3 == 0]

[3, 6, 9, 12, 15, 18]

Given the following line of code, which list is produced by the expression values[3:8]? values = [79, 40, 18, 32, 95, 66, 58, 81, 20, 62]

[32, 95, 66, 58, 81]

Given the following line of code, which list is produced by the expression values[:8]?values = [79, 40, 18, 32, 95, 66, 58, 81, 20, 62]

[79, 40, 18, 32, 95, 66, 58, 81]

What does list contain after the following code is executed?list = [82, 27, 66, 18, 40, 93, 85, 29] list.append(50) list.insert(3, 99) list.pop()

[82, 27, 66, 99, 18, 40, 93, 85, 29]

Given the following line of code, which list is produced by the expression values[4:]?values = [79, 40, 18, 32, 95, 66, 58, 81, 20, 62]

[95, 66, 58, 81, 20, 62]

Which of the following expressions could be used to determine if a is not less than b?

a >= b

str

a character string

What does the Hello World Translator program use to look up the language used given a phrase?

a list comprehension

list

a list of values

What is the output of the following code? die = Die(20) die.roll() die.roll() print(die.value)

a random number between 1 and 20

int

a whole number

What is the Python shell?

a window in which python statements and expressions are executed immediatley

insertion sort

algorithm works by repeatedly inserting a new value into a portion of the overall list that is already sorted. One element at a time, the sorted sublist grows until the entire list is sorted.

selection sort

algorithm works by repeatedly selecting an element from the unsorted list and putting it into its final, sorted position. The element selected is typically the smallest (least) element.

tuple

an immutable list of values

dict

an unordered collected of key or value pairs

set

an unordered collection of unique values

What output does the following code produce? print('apple', 'banana')

apple bannana

How do you read an integer from a text file?

by reading it as a string and converting it to an integer

Which of the following arcs is the same as this one?canvas.create_arc(200, 220, 280, 270, start=40, extent=140) canvas.create_arc(100, 200, 180, 250, start=40, extent=140) canvas.create_arc(200, 220, 280, 270, start=-40, extent=-140) canvas.create_arc(200, 220, 280, 270, start=-180, extent=-140) canvas.create_arc(200, 220, 270, 280, start=40, extent=140) Good! This arc spans the same area of the ellipse, but is defined using negative angle values. Check My Quick Check Answers Terms of Use

canvas.create_arc(200, 220, 280, 270, start=-180, extent=-140)

Which of the following ovals is also a circle?

canvas.create_oval(100, 200, 155, 255)

Which of the following ovals is thinner than it is tall?

canvas.create_oval(140, 100, 160, 150)

Which of the following creates the largest circle? canvas.create_oval(150, 175, 195, 220) canvas.create_oval(30, 80, 55, 105) canvas.create_oval(50, 50, 150, 150) canvas.create_oval(20, 100, 50, 130)

canvas.create_oval(50, 50, 150, 150)

Which of the following rectangles extends furthest down?

canvas.create_rectangle(50, 85, 120, 160)

For Python, the term data type can be used interchangeably with what other term?

class

Which of the following is NOT a reason to use a constant?

constants minimzie the need for input validation

Which of the following does the input function NOT do when it is called?

convert the user input to an integer

Towers of Hanoi is a puzzle

created in the 1880s by Edouard Lucas, a French mathematician.

Which line of code is equivalent to the following? depth += 50 * offset

depth = depth + (50 * offset)

Which of the following would cause a runtime error?

dividing by zero

Running a program that contains errors will cause the Thonny development environment to terminate.

false

Which direction would the following arc "point"? That is, where is the center point of the oval relative to the arc?canvas.create_arc(200, 200, 270, 230, start=45, extent=90) up down right left Good! The center point is below the arc.

down

Which way would the turtle be facing after executing the following code?turtle.setheading(270) turtle.right(20) turtle.left(65)

down and right (southeast)

Which of the following operations cannot be performed on tuples?

element slicing

A Python function must have at least one parameter.

false

A Python list cannot contain a list as an element.

false

A Python program must be enclosed in curly braces { } to be executed.

false

A Python program must compiled into an executable form before it can be run.

false

A binary search only works if the number of elements to search is odd.

false

A binary search works best on an unsorted list of values.

false

A character encoding is the list of all characters used by a programming language.

false

A dictionary is bidirectional — values can be used to look up keys and vice versa.

false

A dictionary key must be a character string.

false

A for loop can be used to traverse a dictionary's keys, but not its values.

false

A linear search examines every element in the list.

false

A nested loop is required to draw a squared-corner spiral.

false

A program that runs without generating a runtime error will produce correct results.

false

A turtle draws a filled circle using the fill_circle command.

false

All Python data types are immutable.

false

All elements in a Python list must have the same data type.

false

All mathematical functions in Python are part of the math module.

false

All values stored in a Python dictionary must be unique.

false

An if statement cannot have both an elif and an else clause.

false

Constants automatically convert between units of measure.

false

Functions of the math module are used to compute the mean of the data values in the standard_deviation program.

false

Functions of the math module do not have to be imported.

false

If a == b is true, then a is b will also be true.

false

If both operands to the remainder operator (%) are positive, a divisor of n will produce a result in the range 1 to n.

false

In Python, the assignment statement is also an expression.

false

In dynamically typed languages, variables are declared to store a specific type of data.

false

In the Counting Letters examples, the dictionary used to keep track of letter frequencies uses the count as the key.

false

Python 3 is backwards compatible to Python 2.

false

Python constants cannot be created for floating-point values.

false

Which of the following is NOT a repetition statement in Python? if statement

if statement

Which of the following methods can be called on a tuple?

index

Deriving one class from another establishes what kind of relationship between the two classes?

is-a

Thonny is best described as which of the following?

itegrated development environment

Which direction would the following arc "point"? That is, where is the center point of the oval relative to the arc?canvas.create_arc(170, 100, 220, 160, start=-20, extent=40) up down right left Well done! The center point is to the left of the arc.

left

Which of the following is NOT a constant from the Python Standard Library?

math.e math.pi conversions.KILOMETERS_PER_MILE tkinter.NE conversions.KILOMETERS_PER_MILE

What output is printed by the following code if it is executed when appetizer is 3 and entree is 12? if appetizer > 1: if entree < 7: print('ketchup') else: print('mustard') else: if appetizer < 0: print('mayonnaise') else: print('relish')

mustard

What output does the following code produce? print('Total: ' + 100 + 20)

no output, it would produce an error

What output is printed by the following code? str = 'Rephactor Python' index = 0 num = 0 while index < len(str): if str[index] == 'o': num += 1 index += 1 print('Num:', num)

num : 2

Which assignment statement is functionally equivalent to the following if statement? if num1 > total: num1 = total else num1 = 0

num = total if num1> total else 0

What is lexicographic ordering?

ordering characters based on a character set

Which statement would produce the following output? "Oom Pah Pah Oom Pah Pah," that's how it goes.

print("\"Oom Pah Pah Oom Pah Pah,\" that's how it goes.");

Which statement would produce the following output? Eeny Meeny Miny Moe

print('Eeny\n\tMeeny\nMiny\n\tMoe');

What is text that requests user input called?

prompt

Which of the following expressions would produce a value in the range 1 to 10? random.randrange(1, 11)

random.randrange(1, 11)

Which of the following is NOT an appropriate use case for a Python dictionary?

representing an ordered sequence of values

Which of the following statements is true when using a dictionary for counting?

the ket is the item counted, the value is the count

Which direction would the following arc "point"? That is, where is the center point of the oval relative to the arc?canvas.create_arc(150, 250, 250, 400, start=160, extent=40) up down right left Good! The center point is to the right of the arc.

right

Which category of data types represents an ordered collection of values?

sequence

What is syntax coloring?

showing certain elements of program code in different colors

iterative

solution to a problem is one that uses loops instead of recursion.

geometry manager

specifies how gui elements are laid out visually in a window

Which of the following statements is true?

statements of the body of an if must be indented

Given the following line of code, which expression would produce the list ['DE', 'MD', 'VA']? states = ['CA', 'WY', 'DE', 'MD', 'VA', 'FL', 'TX']

states[2:5]

Which Python function can be used to call a method of a superclass?

super

Which two terms mean the same thing?

superclass and parent class

What does the term case sensitive mean?

the difference between uppercase and lowercase letters matters

What do the characters in a Unicode escape sequence represent?

the hexadecimal code for a particular unicode character

Which of the following would be most appropriate to choose with a set of check buttons? your age range (0-12, 13-18, 19-29, etc.) the highest educational level a person achieved your favorite ice cream flavor the languages a person speaks Exactly! A person may speak multiple languages. Check My Quick Check Answers Terms of Use

the languages a person speaks

Which of the following is NOT true regarding the return statement?

the last statement in the function must be a return statement

Which of the following statements is true?

the print statement is a call to a function

What does the following statement print? print('Invalid' if count <= 0 else count)

the value of count, or 'invlid' if count is negative

If the value of weight is 7, what does the following statement print? print('The weight is ' + ('even' if weight % 2 == 0 else 'odd'))

the weight is odd

What will happen if the variable total has the value 5 when the following code is executed? if total > 8: print('collywobbles')

the word collywobbles is not printed and processing continues

Big O notation (pronounced "big oh")

to put sorting algorithms into categories. Big O notation eliminates the irrelevant details of a particular algorithm and focuses on how fast the algorithm solves the problem in terms of n These are also referred to as quadratic sorts

A dictionary is designed for efficient value retrieval. True

true

A function parameter ceases to exist when the function returns to the caller. True

true

Built-in functions of the Python Standard Library can be used without being imported.

true

Checking to see if an element is in a set is an efficient operation in Python.

true

Full documentation about the Python Standard Library can be found online.

true

If a filled shape drawn by a turtle is not fully enclosed, Python fills the shape as if the starting point is connected to the end point. True

true

If a is b is true, then a == b will also be true.

true

In the Counting Letters examples, only letters found in the analyzed text have entries in the dictionary.

true

What set is stored in set3 by the following code? set1 = {1, 2, 3, 4, 5} set2 = {3, 4, 5, 6, 7, 8, 9} set3 = set1 | set2

{1, 2, 3, 4, 5, 6, 7, 8, 9}

What set is stored in set3 by the following code? set1 = {1, 2, 3, 4, 5} set2 = {3, 4, 5, 6, 7, 8, 9} set3 = set1 - set2

{1,2}

What set is stored in set3 by the following code? set1 = {1, 2, 3, 4, 5} set2 = {3, 4, 5, 6, 7, 8, 9} set3 = set1 & set2

{3, 4, 5}


Set pelajaran terkait

Convection Currents, Plate Tectonics

View Set

Chapter 7: Annotating, Summarizing, Responding

View Set

Principles of Marketing Chapter 7

View Set

050 - Chapter 50 - Mass Media and Politics

View Set

Chapter 13: Intrusion Detection Systems and Network Security

View Set

Postpartum & Newborn Discharge Teaching BREASTFEEDING 4th semester maternity nursing

View Set

CARBOHYDRATES, FATS, AND PROTEINS

View Set