100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached 4.2 TrustPilot
logo-home
Exam (elaborations)

Python Final Exam ALL ANSWERS 100% CORRECT LATEST SOLUTION.

Rating
-
Sold
-
Pages
28
Grade
A+
Uploaded on
02-11-2022
Written in
2022/2023

Python Final Exam ALL ANSWERS 100% CORRECT LATEST SOLUTION Python Final Exam ALL ANSWERS 100% CORRECT LATEST SOLUTION Who developed the Python programming language? - Guido van Rossum T/F: Python is a general-purpose programming language, appropriate for solving problems in many areas of computing. - True (You might use Python for web development, business applications, and artificial intelligence, among many others.) T/F: The Python programming language was so named after a snake was discovered in the creator's office. - False T/F: Python 3 is backwards compatible to Python 2. - False Python embodies elements of which programming paradigm? - Procedural programming Object-oriented programming Functional programming Which of the following is NOT a principle embraced by the Python programming language? - Verbose is better than succinct Thonny is best described as which of the following? - Integrated Development Environment (IDE) T/F: The output of a Python program run in Thonny appears in the shell window. - True T/F: Thonny displays code using syntax highlighting. - True T/F: Running a program that contains errors will cause the Thonny development environment to terminate. - True T/F: The Thonny debugger lets you trace the value of variables while your program is executing. - True T/F: A Python program must be enclosed in curly braces { } to be executed. - False Which of the following statements is true? - The print statement is a call to a function T/F: A Python program must compiled into an executable form before it can be run. - False What is syntax coloring? - Showing certain elements of a program code in different colors What does the term case sensitive mean? - The difference between uppercase and lowercase letters matters What output does the following code produce? print('apple', 'banana') - apple banana What output is produced by the following code? print(15 + 30) - 45 What output does the following code produce? print('Ready', end=' ') print('Set', end='') print('Go') - Ready SetGo What output is produced by the following code? print('Jan', 'Feb', 'Mar', sep='-') - Jan-Feb-Mar What output is produced by the following code? print('oak', 'elm', 'pine', end='!', sep='#') - oak#elm#pine! T/F: Python variables are created using an assignment statement. - True T/F: The value of a variable can change throughout a program. - True Which of the following is NOT a valid Python identifier? - 1stPlace Which of the following identifiers follows the convention for naming Python variables? - total_value T/F: In dynamically typed languages, variables are declared to store a specific type of data. - False T/F: Python variables that represent integers are NOT object reference variables. - False T/F: The assignment operator has higher precedence than the arithmetic operators. - False What value is assigned to the variable num by the following statement if the current value of num is 4? num = num * 2 - 8 T/F: The value assigned to a variable must be numeric. - False In Python, the assignment statement is also an expression. - False The value assigned to a variable could be a floating point number. - True T/F: Python comments begin with a hash mark (#) and extend to the end of the line. - True T/F: A comment in a Python program is ignored by the interpreter. - True T/F: A Python comment cannot appear on a line that contains an executable statement. - False (helps explain it) T/F: A Python block comment begins with a double slash (//). - False (starts with #) What is a docstring? - A character string used as a comment in a program T/F: If either or both operands to the division operator (//) are floating-point values, then the result will be a floating-point value. - True T/F: If both operands to the remainder operator (%) are positive, a divisor of n will produce a result in the range 1 to n. - False (produce a range 0 to n-1) T/F: The math module contains a constant that represents the value pi to several digits. - True What is the result of the expression 7 // 2? - 3 What is the result of the expression 43 % 5 - 3 If the variable num contains a positive integer, what are the only two possible results of the expression num % 2? - 0 and 1 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 is the Python Standard Library? - A collection of programming components that can be used in any python program T/F: Using components from the Python Standard Library is a rare occurrence. - False T/F: Built-in functions of the Python Standard Library can be used without being imported. - True T/F: Full documentation about the Python Standard Library can be found online. - True T/F: All mathematical functions in Python are part of the math module. - False (several built-in functions) T/F: The constant represents pi to 15 decimal places. - True What is the result of the expression max(6, 17) - 17 What is the result of the expression (3, 3) - 27 What is the result of the expression (12.843) - 12 Why don't we use natural languages (like English) to program a computer? - Natural languages are semantically ambiguous (have more than one meaning) What is the syntax of a language? - The rules that determine how words and symbols can be combined. T/F: In a programming language, a syntactically valid statement has only one meaning. - True T/F: A program that runs without generating a runtime error will produce correct results. - False Which of the following would cause a syntax error? - Mispelling a word Which of the following would cause a runtime error? - Diving by 0 Computing the wrong answer is an example of what kind of error? - Logic error Debugging is the process of: - Finding the root cause of an error and fixing it. 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 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 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 - 0.5 Which line of code is equivalent to the following? depth += 50 * offset - depth = depth + (50 * offset) T/F: The Python turtle graphics module is based on the programming language Logo developed in the 1960s. - True If the turtle is currently facing up (north), which way would it be facing after executing the command (45)? - up and right (northeast) T/F: The pen color and size determines the color and width of the lines drawn. - True T/F: The effect of the setheading depends on the current heading of the turtle. - False Which way would the turtle be facing after executing the command ading(135)? - up and left (northwest) Which way would the turtle be facing after executing the following code? ading(270) (20) (65) - down and right (southeast) T/F: The position of a circle depends on the current heading of the turtle. - True T/F: The turtle circle command can be used to draw a regular polygon. - True T/F: The origin point (0, 0) of the turtle coordinate system is in the upper left corner of the graphic screen. - False T/F: The goto command moves the turtle without drawing a line. - False T/F: A turtle draws a filled circle using the fill_circle command. - False (no such command) T/F: The stroke color of a filled turtle shape must be the same as the fill color. - False T/F: 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 T/F: Setting the turtle's speed to 0 turns off the animation of the turtle movement completely. - True Which of the following does the input function NOT do when it is called? - Convert the user input to an integer. What is text that requests user input called? - prompt T/F: The input function always returns the read data as a character string. - True T/F: The input, int, and float functions are all built-in functions. - True T/F: The input function will produce an error if the value read is not numeric. - False (wil produce error if int or float used) What operator is used to perform string concatenation in Python? - + What output does the following code produce? print('Total: ' + 100 + 20) - No output, would produce error because you cannot concatenate a string and an integer What issue must be addressed when printing a long character string? - A regular string literal cannot span across multiple lines. If a variable called pioneer refers to the string 'Grace Murray Hopper', what is the result of the expression len(pioneer)? - 19 If a variable called business refers to the string 'Time Warner', what is the result of the expression business[6]? - 'a' If a variable called son refers to the string 'Justin', what is the result of the expression son[-3]? - 't' T/F: You cannot change the contents of Python character string once it has been created. - True If a variable called jedi refers to the string 'Yoda', what is the result of the expression jedi * 3? - YodaYodaYoda 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. 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 Which of the following statements is true? - The statements in the body of an if must be indented. T/F: An if statement cannot have both an elif and an else clause. - False T/F: The relational operators all return boolean results - True T/F: The result of a relational operator can be assigned to a variable. - True T/F: The arithmetic operators have a lower precedence than the relational operators. - False Which of the following is a relational operator? - <= Which of the following expressions could be used to determine if a is not less than b? - a >= b T/F: In Python, the relational operators can be used to put character strings in alphabetical order. - True T/F: The less than operator (<) should not be used to compare floating point values. - False T/F: The not operator requires two operands. - False (only had one opperand) T/F: If A and B are both false, then the expression A and B is false. - True T/F: If A is true and B is false, then the expression A or B is true. - True T/F: If A is false, then the B operand in the expression A and B is not evaluated. - True T/F: If A is false, then the B operand in the expression A or B is not evaluated. - False What is lexicographic ordering? - Ordering characters based on a chracter set T/F: When using relational operators to compare character strings, 'Music' comes before 'music'. - True T/F: When using relational operators to compare character strings, 'ZEBRA' comes before 'ALLIGATOR'. - False Which of the following conclusions is NOT true when using relational operators to compare character strings? - 'fantastic' comes before 'Great' Which of the following conclusions is NOT true when using relational operators to compare character strings? - 'reset' comes before 'reserve' T/F: Strings containing non-alphabetic characters cannot be compared using the relational operators. - False T/F: A syntactically valid program is not necessarily a good program. - True What is a programming convention? - A guideline about program style that makes code easier to read. T/F: The Python interpreter requires all indentation levels to be four spaces. - False Which of the following adheres to the naming convention for a Python variable? - total_value Which of the following is the preferred way to embed a quotation mark into a Python string? - 'Alice said "Hi" to Bob.' What is an argument? - A list of all values passed into a function. T/F: A function can be called multiple times with different arguments. - True T/F: By default, the first argument passed to a function is assigned to the first parameter. - True T/F: An argument can be assigned to a particular parameter when a function is called. - True T/F: If an argument has a default value, it is optional in the function call. - True What is a program's flow of control? - The order in which statements are executed. What is the default flow of control through a function? - Linear T/F: An assignment statement affects a program's flow of control. - False T/F: An if statement affects a program's flow of control. - True T/F: A while loop affects a program's flow of control. - True (loop determines which statement is executed next) T/F: After a function finishes executing, control returns to the place the function was called. - True If a variable called greeting refers to the string 'hello', what does the expression () accomplish? - Returns a new string containing the characters 'HELLO' If a variable called word refers to the string 'committee', what is the result of the expression ('m')? 'committee' - 'committee' (only strips leading or trialing characters) T/F: If a variable called user_id refers to the string 'AEinstein12', what is the result of the expression user_ha()? - False If a variable called address refers to the string '123 Main Street', what is the result of the expression ('3')? - 2 (string index) What output would be produced when the following code is executed? state = 'Mississippi' print(ce('is', 'was)) - Mwasswassippi Given the following line of code, which expression would produce the substring 'ledge'? words = 'Knowledge is power.' - words[4:9] If the variable str refers to the string 'ABC123XYZ', what does the expression str[3:7] produce? - '123X' If the variable word refers to the string 'programming', what does the expression word[2:] produce? - 'ogramming' If the variable noise refers to the string 'hullaballoo', what does the expression noise[:8] produce? - 'hullabal' If the variable blah_blah refers to the string 'gobbledygook', what does the expression blah_blah[-5:] produce? - 'ygook' 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)] If the variable machine refers to the string 'computer', what does the expression machine[0:len(machine):2] produce? - 'cmue' T/F: Python uses the Unicode character set to represent characters. - True T/F: A character encoding is the list of all characters used by a programming language. - False T/F: The Unicode character set currently represents over 100,000 characters. - True What is ASCII? - A subset of Unicode containing primarily English characters and basic symbols. What technique is used to put Unicode characters and strings in order? - lexicographic ordering T/F: The body of a while loop may never execute. - True (The condition is checked first, and if it's false right away, the body of the loop is never executed.) T/F: There is no way to stop an infinite loop. - False (The program must be interrupted by pressing Ctrl-C or Ctrl-Break or by closing the run window.) T/F: In some cases, a sentinel value can be used to signal the end of input. - True (Each input value is compared to the sentinel value to know when the loop should terminate.) T/F: Using a while loop to check each input value for correctness is a form of input validation. - True (The loop won't allow processing to proceed until a valid value is entered.) Which of the following is NOT a repetition statement in Python? if statement - if statement (conditional statement) What causes an infinite loop - A loop condition that is never false. T/F: In the High-Low program, it's impossible for the user to guess the target value in one guess. - False T/F: In the High-Low program, the number of times the while loop will be executed can be calculated before the loop begins. - False (depends how long it takes the user to guess_ T/F: The High-Low program would still work if the initial value of guess were set to -1 instead of -999. - True T/F: The if statement in the High-Low program had to be written so that it checks for the correct guess last. - False (The logic of the if statement could be written to check any of the possibilities in any order.) T/F: In the palindromes program, the inner loop evaluates one string to see if it is a palindrome. - True (the outer loop allows multiple strings to be evaluated) T/F: In the palindromes program, a potential palindrome is evaluated by comparing characters at both ends and working inwards. - True (The indexes in the variables left and right determine which characters are compared.) T/F: In the palindromes program, the inner loop will stop immediately if the string is determined not to be a palindrome. - True (The variable palindrome keeps track of that.) T/F: The string 'i prefer pi' would be considered a palindrome by the original version of the palindromes program. - False (Even though it's in all lower case letters, the spaces would throw it off.) T/F: A for loop is a good way to access each character in a string. - True (A string is a sequence of characters that the for loop processes one at a time.) T/F: The Python for loop is what other languages refer to as a for-each loop. - True (The "regular" for loop in other languages behaves differently.) How many times will the following code print the word 'wow'? for val in range(5, 10): print('wow') - 5 (range contains 5 values 5-9) T/F: The body of a for loop cannot contain another for loop. - False(It's called a nested loop. The inner loop executes fully on each iteration of the outer loop.) T/F: The stop value passed as an argument to the range function is NOT included in the range produced. - True (The range runs up to but doesn't include the stop value.) T/F: The start value passed as an argument to the range function cannot be negative. - False(Sure it can. A range can include negative values.) T/F: The step value passed as an argument to the range function cannot be negative. - False (A negative step value creates a descending range of values.) Which range is produced by the function call range(5)? - 0 1 2 3 4 Which range is produced by the function call range(4, 10)? - 4 5 6 7 8 9 Which range is produced by the function call range(12, 5, -2)? - 12 10 8 6 T/F: The loop in the star program controls how long each line in the star is. - False (controls how many lines is drawn) T/F: A nested loop is required to draw a squared-corner spiral. - False T/F: The loop in the curved spiral program controls both how many lines are drawn and how long each one is. - True T/F: In the random turtle walk program, the loop control variable is used to determine whether the turtle turns right or left. - False (e) T/F: The open function can be used to open an input file or create an output file. - True T/F: The read method of a file object reads the contents of a file one line at a time. - False (The read method reads the entire contents of a file, or a specific number of characters.) T/F: The best way to read a file line by line is to use a for loop to iterate over the file object itself. - True How do you read an integer from a text file? - By reading it as a string and converting it to an integer. T/F: The write method adds a newline character to the end of the output. - False (You can add newline characters to the output wherever appropriate.) T/F: The write method automatically adds line numbers to the output. - False T/F: An output file should be closed explicitly when you're done writing to it. - True T/F: A Python function must have at least one parameter. - False (some have no parameters) Which of the following is NOT true regarding the return statement? - The last statement in a function must be a return statement. T/F: A function parameter ceases to exist when the function returns to the caller. - True T/F: A function can return a boolean result. - True T/F: Variables declared inside a function cannot be accessed from outside that function. - True (That's called a local variable, and its scope is limited to the function.) T/F: All elements in a Python list must have the same data type. - False (A list can contain elements with differing types) A Python list cannot contain a list as an element. - False (The nested list is sometimes called a sublist) 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 T/F: The value of the expression len(list) is one less than the number of elements in the list. - False (That expression returns the length of the list (the number of elements)) T/F: The values stored in a list can be changed. - True (mutable) 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] T/F: A for loop can be used to compute the sum of all values in a list. - True Finding a minimum value requires that every element in the list be examined. - True T/F: 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 (The for loop could stay the same — the condition of the if statement would change to find the biggest element.) T/F: A linear search examines every element in the list. - False (Once the target element is found, there is no need to keep searching the list.) T/F: Swapping two elements in a list requires three assignment statements. - True 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. The expression ange(30) will produce a value in what range? - 0-29 The expression ange(5, 10) will produce a value in what range? - 5 to 9 The expression nt(6, 12) will produce a value in what range? - 6 to 12 Which of the following expressions would produce a value in the range 1 to 10? - ange(1,11) T/F: The choice function in the random module lets you choose multiple elements from a list. - False (The choice function returns only one element from the sequence.) T/F: The sample function in the random module takes a sample with replacement. - False (The sample function takes a sample without replacement, which means all elements in the sample will be unique.) 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 of the following string literals is NOT valid? - ""n"" What is the output of the following statement?print('He said Expelliarmus'); - He said Expelliarmus Which statement would produce the following output? Eeny Meeny Miny Moe - print('EenyntMeenynMinyntMoe'); What do the characters in a Unicode escape sequence represent? - the hexadecimal code for a particular Unicode character T/F: Functions of the math module do not have to be imported. - False (not a built in function) T/F: An import statement finds a module and binds it to a name you can use in a program. - True T/F: An entire module can be imported using one import statement. - True T/F: Two functions can have the same name if they are in different modules. - True 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] 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[4:]? values = [79, 40, 18, 32, 95, 66, 58, 81, 20, 62] - [95, 66, 58, 81, 20, 62] 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] 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 list contain after the following code is executed? list = [82, 27, 66, 18, 40, 93, 85, 29] d(50) t(3, 99) () - [82, 27, 66, 99, 18, 40, 93, 85, 29] What does list contain after the following code is executed? list = [77, 41, 92, 30, 38, 12, 63] () t(2, 88) (5) - [12, 30, 88, 38, 41, 77, 92] What does the list states contain after the following code is executed? states = ['NJ', 'TN', 'WI', 'UT'] d(['PA', 'KY', 'NY']) e('UT') (reverse=True) - ['WI', 'TN', 'PA', 'NY', 'NJ', 'KY'] Given the following line of code, what is the value of the expression (20)? nums = [30, 80, 40, 80, 20, 20, 70, 30, 80] - 4 Given the following line of code, what is the value of the expression (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 (80, 2)? nums = [30, 80, 40, 80, 20, 20, 70, 30, 80] - 3 (That's the index of the first occurrence of 80 when starting the search at index 2.) T/F: The standard_deviation program would not work if there were twice as many values in the data file. - False (file could potentially be huge since no limit) Why is the input data for the standard_deviation program stored in a list? - Because the data needs to be processed more than once. T/F: Functions of the math module are used to compute the mean of the data values in the standard_deviation program. - False (No math module functions are needed to compute the mean.) T/F: The results computed by the standard_deviation program are written out to text data file. - False T/F: The Greek mathematician Eratosthenes came up with the idea of using a sieve algorithm to find prime numbers. - True T/F: 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 (The program only uses the sieve algorithm up to the square root of N, which is sufficient.) T/F: 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 program uses a list of boolean values, whose index values are determined to be prime or not.) 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 T/F: A binary search works best on an unsorted list of values. - False (For binary search to work at all, the list of values must already be sorted.) T/F: A binary search only works if the number of elements to search is odd. - False (A binary search can be performed on any number of elements.) 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 How many comparisons are necessary to find the value 86 in the following list using a binary search? - 4 How many comparisons are necessary to find the value 43 in the following list using a binary search? - 3 T/F: A two-dimensional list is suitable for storing tabular data. - True (The two dimensions of the list correspond to the row and column layout of the table.) T/F: A two-dimensional list is really a one-dimensional list of one-dimensional lists. - True T/F: The smallest index of any dimension of a two-dimensional list is 1. - False (The indexes of each dimension begin at 0.) T/F: The maximum indexes of a two-dimensional list with 6 rows and 10 columns are 5 and 9, respectively. - True (Each dimension is indexed from 0 to N-1, where N represents the number of elements in that dimension.) How many elements can be stored in a two-dimensional list with 5 rows and 10 columns? - 50 T/F: A example of a ragged list is a two-dimensional list where each row has a different number of columns. - True (Ragged lists have at least one dimension of non-uniform length.) T/F: The maximum number of dimensions a Python list can have is 3. - False (The concept of a multidimensional list can be extended to any number of dimensions.) T/F: The primary difference between lists and tuples is that lists are immutable and tuples are not. - False (It's the other way around. You can change the contents of a list but not of a tuple) Which of the following operations cannot be performed on tuples? - Element removal (immutable) T/F: The valid indexes of a tuple run from 0 through one less than the length of the tuple - True Which of the following methods can be called on a tuple? - Index Which of the following is NOT a good reason to use a tuple rather than a list? - Tuples can hold more elements than lists. (this is not true! generally no limit) T/F: When printed, a set containing strings will list the elements in alphabetical order. - False (The elements of a set are unordered. You should NOT assume the elements can be accessed or printed in any particular order.) Checking to see if an element is in a set is an efficient operation in Python. - 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} 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 - {3, 4, 5} (intersection) T/F: All values stored in a Python dictionary must be unique. - False (The dictionary keys must be unique, but the values could be duplicated.) T/F: A dictionary key must be a character string. - False (A key can be any immutable type, including, for instance, an integer.) T/F: A dictionary is designed for efficient value retrieval. - True (The internal representation of a dictionary is designed to find a value quickly given its key.) T/F: Using the index operator to retrieve a value will result in a KeyError if the key is not in the dictionary. - True (You can use the in operator to check for a key's existence if you're not sure.) T/F: A for loop can be used to traverse a dictionary's keys, but not its values. - False (The values method returns a list of values you can traverse using a for loop.) T/F: The items method returns a list of key/value tuples for all entries in a dictionary. - True (It can be used for efficient traversal of the entire dictionary.) T/F: The dictionary used in the Hello World Translator program uses the language name as the key. - True (The phrase "Hello World!" in the appropriate language is the value for each key.) T/F: The content of the dictionary used in the Hello World Translator program is read from an input file. - True (Each line in the file contains a language name and the phrase in that language.) What does the Hello World Translator program use to look up the language used given a phrase? - A list comprehension T/F: The Hello World Translator program will produce an error if the language requested is not in the dictionary. - False Widgets - Controls that let the user interact with a program in various ways Event handler - A function that performs an action when the user interacts with a widget Graphical User Interface (GUI) - Provides "point and click" interaction with a program Tcl/Tk - Scripting language that supports GUI development Geometry Manager - Specifies how GUI elements are laid out visually in a window Tkinter - Package that supports GUI development in Python T/F: The event handler function for a Button must be called handleButton. - False T/F: The event handler for a Button can be specified using a parameter to the Button constructor. - True (The event handler is set using the command keyword parameter.) T/F: The text of a Button can be displayed in various fonts. - True (The font can be specified when the button is created or using the configure method.) T/F: A Button can display text and an image at the same time. - True What are the names of the two text field widgets in Tkinter? - Text and Entry Which Tkinter text field widget allows for multiple lines of input? - Text T/F: The optional argument called mask is used to specify a character that will be displayed in a Text widget instead of the actual characters. - False (The parameter name is called show and it is used in the Entry widget.) T/F: The size of a Text widget is specified using a string that indicates the width and height in pixels. - False (That's how the window size is specified. The size of a Text widget is specified using optional parameters.) T/F: The set method can be used to set the value of a text field. - True Check Button - A widget that allows the user to turn an option on or off Label - A widget that displays text, an image, or both Scale - A slider used to select a numeric value within a range Notebook - A set of tabbed frames with one visible at a time List Box - A widget that displays a list of selectable elements Progress bar - A widget that displays the status of long-running operations Entry - A field in which the user can type text input Canvas - An area in which graphics are drawn Radio Button - A widget that, when used in a group, provide a set of mutually-exclusive options Option Menu - A widget that displays a pop-up list of selectable options Combo Box - A widget that combines a text entry field with a dropdown list of selectable options T/F: Each check button in a Python program must have its own event handler function. - False (Multiple check buttons could use the same event handler, or none at all.) T/F: A check button does not have to have an event handler. - True T/F: Selecting a check button will automatically unselect any other check buttons in its group - False (Check buttons don't work in formalized groups. They represent individual boolean situations.) Which of the following would be most appropriate to choose with a set of check buttons? - The language a person speaks T/F: Radio buttons work in a group to provide a set of mutually-exclusive options - True T/F: A cooperating group of radio buttons is determined by the variable each button updates. - True T/F: The variable a radio button updates determines its visual layout. - False (The associated variable has nothing to do with the visual presentation of the button.) T/F: Only one radio button displayed in a window can be selected at any time. - False (A window can display multiple sets of radio buttons that are mutually-exclusive within each group.) T/F: A color chooser is a specialized dialog box that lets the user select a color. - True T/F: The askcolor method is defined in the webcolors module. - False (It's defined in the colorchooser module.) T/F: The askcolor method returns a tuple that specifies the color in two ways. - True (It returns the color as an RGB value and as a hex value.) T/F: When a color chooser is first displayed, the initial color selected is black. - False (The default color is white, but you can specify the initial color to be any color you'd like.) T/F: A file chooser is a specialized dialog box for selecting files in a directory structure. - True T/F: The function askopenfilename returns a file object. - False (It returns a string that represents the file name.) T/F: The function askopenfiles returns a list of file objects. - True T/F: The file chooser dialogs may look different on different types of computers. - True T/F: The file chooser functions accept optional parameters that let you specify, for instance, the initial directory or file selected - True T/F: A class represents a group of similar objects. - True T/F: An object created from a class is called an instance of that class. - True T/F: The values of an object's instance data represent the object's identity. - False (could be the same) Which of the following contribute to the state of a Car object? - The car's color Which of the following is an appropriate analogy? - Class: concept of a dog, Object: my dog Fido T/F: Each object has its own instance data. - True T/F: Each Person object has its own last name. - True (Each has its own instance variable) T/F: The initializer method of the Person class is called __init__. - True (For any class, the name of the special method that initializes instance data is called __init__.) T/F: An object's __str__ method is called automatically when an object is printed. - True (It's also called when an object is concatenated with a string.) T/F: The Die class is part of the Python Standard Library. - False (The Die class was written specifically for this example.) T/F: The maximum number of sides on a Die object is 20. - False (There is no maximum value for the number of sides on a Die.) T/F: If an invalid number of sides is provided when a Die object is created, a die with 6 sides is created. - True (Any value less than 2 is considered invalid.) What is the output of the following code? die = Die(6) print('Die value:', die) - Die value: 1 What is the output of the following code? die = Die(20) () () print() - A random number between 1 and 20 T/F: The initial balance of a BankAccount is $0 unless otherwise specified. - True (The balance parameter of the __init__ method defaults to 0 if not provided.) T/F: The amount deposited into a BankAccount is held as instance data of the BankAccount class. - False (It's just passed in as a parameter to the deposit method. Only the account number and balance are instance data.) T/F: The __str__ method of the BankAccount class calls the print function to produce the output. - False (The __str__ method doesn't print anything. It formats and returns a string summary of the bank account.) T/F: The withdraw method of the BankAccount class ensures that the amount withdrawn is less than the balance. - False (It could be written that way, but in this example no validation of the arguments is performed.) What is the output of the following code? account1 = BankAccount(1234, 100.0) account2 = BankAccount(5678, 50.0) transfer = 25.00 raw(transfer) it(transfer) print(account1) print(account2) - 1234: $75.00 5678: $75.00 What is the output of the following code: account = BankAccount(1234) raw(1.0) print(account) - 1234: $-1.00 T/F: The Card class represents a complete Python program. - False T/F: The __str__ method of the Card class prints a text representation of the card. - False What type of object is used to store the cards in the DeckOfCards class? - List What are the top four cards in the deck right after a DeckOfCards object is created? - 2 of Clubs, 2 of Diamonds, 2 of Hearts, 2 of Spades T/F: The shuffle method in the DeckOfCards class relies on a method from the Python Standard Library. - True T/F: Dealing a card removes the Card object from the DeckOfCards object. - True (It removes the card from the list and returns it. In that sense, it mimics a real deck of cards.) T/F: If an attempt is made to deal a card from an empty DeckOfCards, an error is generated. - False (a value of none is returned) Which two terms mean the same thing? - superclass and parent class (This is the class from which a subclass (or child class) is derived.) Deriving one class from another establishes what kind of relationship between the two classes? - is-a A subclass is a more specific version of its superclass. - True (Inheritance should create an is-a relationship.) Which Python function can be used to call a method of a superclass? - super (The super function gives access to the parent class.) Overriding occurs in which of the following situations? - When a subclass redefines a method it inherits from a superclass. T/F: In Python, a class can only be derived from one parent class. - False (Python supports multiple inheritance.) One solution is to use an escape sequence, which is a technique for representing a character in situations where the traditional manner would cause problems or simply be less convenient. - -

Show more Read less
Institution
Python
Course
Python










Whoops! We can’t load your doc right now. Try again or contact support.

Written for

Institution
Python
Course
Python

Document information

Uploaded on
November 2, 2022
Number of pages
28
Written in
2022/2023
Type
Exam (elaborations)
Contains
Questions & answers

Subjects

Get to know the seller

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
PatrickHaller Walden University
View profile
Follow You need to be logged in order to follow users or courses
Sold
1380
Member since
3 year
Number of followers
1164
Documents
1769
Last sold
2 days ago
ONLINE STUDY HELP FOR NURSING STUDENTS

ACE YOUR EXAMS WITH OUR A+ GRADED STUDY HELPS

4.1

228 reviews

5
133
4
39
3
25
2
6
1
25

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Frequently asked questions