Skip to main content

Python Programming Final Test Solutions - 533 Verified Questions

Page 1


Python Programming

Final Test Solutions

Course Introduction

Python Programming introduces students to the fundamentals of programming using the Python language. The course covers topics such as variables, data types, control structures, functions, modules, file input/output, and error handling. Emphasis is placed on problem-solving techniques, algorithm development, and writing clear, maintainable code. Through hands-on exercises and projects, students gain practical experience in developing, testing, and debugging Python programs, preparing them for more advanced coursework in software development and data science.

Recommended Textbook

Starting Out with Python 4th Edition by Tony Gaddis

Available Study Resources on Quizplus

13 Chapters

533 Verified Questions

533 Flashcards

Source URL: https://quizplus.com/study-set/2419

Page 2

Chapter 1: Introduction to Computers and Programming

Available Study Resources on Quizplus for this Chatper

39 Verified Questions

39 Flashcards

Source URL: https://quizplus.com/quiz/48072

Sample Questions

Q1) Which of the following is considered to be the world's first programmable electronic computer?

A) IBM

B) Dell

C) ENIAC

D) Gateway Answer: C

Q2) RAM is a volatile memory used for temporary storage while a program is running.

A)True

B)False Answer: True

Q3) What type of volatile memory is usually used only for temporary storage while running a program?

A) ROM

B) TMM

C) RAM

D) TVM

Answer: C

Q4) A disk drive stores data by __________ encoding it onto a circular disk.

Answer: magnetically

To view all questions and flashcards with answers, click on the resource link above. Page 3

Chapter 2: Input, Processing, and Output

Available Study Resources on Quizplus for this Chatper

40 Verified Questions

40 Flashcards

Source URL: https://quizplus.com/quiz/48073

Sample Questions

Q1) The Python turtle is initially positioned in the __________ of a graphics window and it first appears,by default,to be heading __________.

A) center, up

B) top left corner, east

C) bottom left corner, down

D) center, east

Answer: D

Q2) In Python,math expressions are always evaluated from left to right,no matter what the operators are.

A)True

B)False

Answer: False

Q3) The __________ specifier is a special set of characters that specify how a value should be formatted.

Answer: formatting

Q4) Python uses __________ to categorize values in memory. Answer: data types

Q5) The % symbol is the remainder operator,also known as the ___________ operator. Answer: modulus,mod

To view all questions and flashcards with answers, click on the resource link above. Page 4

Chapter 3: Decision Structures and Boolean Logic

Available Study Resources on Quizplus for this Chatper

40 Verified Questions

40 Flashcards

Source URL: https://quizplus.com/quiz/48074

Sample Questions

Q1) Which of the following will determine if the turtle's pen is up and will change it to down if that is the case?

A) if turtle.isup():

Turtle.isdown()

B) if turtle.isdown

Turtle.penup()

C) if not(turtle.isdown()): Turtle.pendown()

D) if not(turtle.penup())

Turtle.penup()

Answer: C

Q2) Which of the following is the correct if clause to determine whether y is in the range 10 through 50,inclusive?

A) if 10 < y or y > 50:

B) if 10 > y and y < 50:

C) if y >= 10 and y <= 50:

D) if y >= 10 or y <= 50:

Answer: C

Q3) A(n)___________ expression is made up of two or more Boolean expressions. Answer: compound

To view all questions and flashcards with answers, click on the resource link above. Page 5

Chapter 4: Repetition Structures

Available Study Resources on Quizplus for this Chatper

41 Verified Questions

41 Flashcards

Source URL: https://quizplus.com/quiz/48075

Sample Questions

Q1) The following for loop iterates ___________ times to draw a square. for x in range(4): turtle.forward(200) turtle.right(90)

Q2) A while loop is called a pretest loop because the condition is tested after the loop has had one iteration.

A)True

B)False

Q3) A(n)__________ structure is a structure that causes a statement or a set of statements to execute repeatedly.

A) sequence

B) decision

C) module

D) repetition

Q4) Which of the following is not an augmented assignment operator?

A) *=

B) /=

C) +=

D) <=

Q5) A(n)___________ structure causes a set of statements to execute repeatedly.

Page 6

To view all questions and flashcards with answers, click on the resource link above.

Chapter 5: Functions

Available Study Resources on Quizplus for this Chatper

66 Verified Questions

66 Flashcards

Source URL: https://quizplus.com/quiz/48076

Sample Questions

Q1) A value-returning function is

A) a single statement that performs a specific task

B) called when you want the function to stop

C) a function that will return a value back to the part of the program that called it

D) a function that receives a value when called

Q2) In Python there is no restriction on the name of a module file.

A)True

B)False

Q3) The function header begins with the keyword __________ and is followed by the name of the function.

Q4) Whic of the following will assign a random integer in the range of 1 through 50 to the variable number?

A) random(1, 50) = number

B) number = random.randint(1, 50)

C) randint(1, 50) = number

D) number = random(range(1, 50))

Q5) Functions that are in the standard library are stored in files that are known as __________.

Q6) The return values of the trigonometric functions in Python are in __________.

Page 7

To view all questions and flashcards with answers, click on the resource link above.

Chapter 6: Files and Exceptions

Available Study Resources on Quizplus for this Chatper

40 Verified Questions

40 Flashcards

Source URL: https://quizplus.com/quiz/48077

Sample Questions

Q1) Which of the following is the correct way to open a file named users.txt to write to it?

A) outfile = open('w', users.txt)

B) outfile = write('users.txt', 'w')

C) outfile = open('users.txt', 'w')

D) outfile = open('users.txt')

Q2) Which mode specifier will open a file but not let you change the file or write to it?

A) 'w'

B) 'r'

C) 'a'

D) 'e'

Q3) Given that the customer file references a file object,and the file was opened using the 'w' mode specifier,how would you write the string 'Mary Smith' to the file?

A) customer file.write('Mary Smith')

B) customer.write('w', 'Mary Smith')

C) customer.input('Mary Smith')

D) customer.write('Mary Smith')

Q4) A(n)__________ file contains data that has not been converted to text.

To view all questions and flashcards with answers, click on the resource link above.

8

Chapter 7: Lists and Tuples

Available Study Resources on Quizplus for this Chatper

40 Verified Questions

40 Flashcards

Source URL: https://quizplus.com/quiz/48078

Sample Questions

Q1) Which method or operator can be used to concatenate lists?

A) *

B) +

C) %

D) concat

Q2) The sort method rearranges the elements of a list so they are in ascending or descending order.

A)True

B)False

Q3) The index -1 identifies the last element in a list.

A)True

B)False

Q4) What is an advantage of using a tuple rather than a list?

A) Tuples are not limited in size.

B) Tuples can include any data as an element.

C) Processing a tuple is faster than processing a list.

D) There is never an advantage to using a tuple.

Q5) The __________ function returns the item that has the lowest value in the sequence.

Page 9

Q6) The ___________ function can be used to convert a list to a tuple.

To view all questions and flashcards with answers, click on the resource link above.

Chapter 8: More About Strings

Available Study Resources on Quizplus for this Chatper

37 Verified Questions

37 Flashcards

Source URL: https://quizplus.com/quiz/48079

Sample Questions

Q1) What will be the value of the variable string after the following code executes?

String = 'Hello'

String += ' world!'

A) 'Hello'

B) ' world!'

C) 'Hello world!'

D) Nothing; this code is invalid

Q2) When accessing each character in a string,such as for copying purposes,you would typically use a while loop.

A)True

B)False

Q3) The following code will display 'yes + no':

mystr = 'yes'

yourstr = 'no'

mystr += yourstr

print(mystr)

A)True

B)False

Q4) The __________ method returns the list of the words in a string.

Q5) The __________ method returns True if the string contains only numeric digits.

Page 10

To view all questions and flashcards with answers, click on the resource link above.

Chapter 9: Dictionaries and Sets

Available Study Resources on Quizplus for this Chatper

39 Verified Questions

39 Flashcards

Source URL: https://quizplus.com/quiz/48080

Sample Questions

Q1) Each element in a dictionary view is a __________.

Q2) Which method can be used to add a group of elements to a set?

A) add

B) addgroup

C) update

D) addset

Q3) If you try to retrieve a value from a dictionary using a nonexistent key,a KeyError exception is raised.

A)True

B)False

Q4) Which would you use to get the number of elements in a dictionary?

A) size

B) length

C) len

D) sizeof

Q5) The __________ method returns all of a dictionary's keys as a dictionary view.

Q6) To determine whether or not a key is included in a dictionary,or if an element is included in a set,you can use the ___________ operator.

Q7) To add a single item to a set,you can use the set __________ method.

To view all questions and flashcards with answers, click on the resource link above. Page 11

Chapter 10: Classes and Object-Oriented Programming

Available Study Resources on Quizplus for this Chatper

38 Verified Questions

38 Flashcards

Source URL: https://quizplus.com/quiz/48081

Sample Questions

Q1) Each object that is created from a class is called a(n)__________ of the class.

Q2) Which is the first line needed when creating a class named Worker?

A) def__init__(self):

B) class Worker:

C) import random

D) def worker_pay(self):

Q3) An object is a stand-alone program but is used by programs that need its service.

A)True

B)False

Q4) A method that returns a value from a class's attribute but does not change it is known as a(n)__________ method.

Q5) A mutator method has no control over the way that a class's data attributes are modified.

A)True B)False

Q6) All class definitions are stored in the library so that they can be imported into any program.

A)True

B)False

To view all questions and flashcards with answers, click on the resource link above. Page 12

Chapter 11: Inheritance

Available Study Resources on Quizplus for this Chatper

36 Verified Questions

36 Flashcards

Source URL: https://quizplus.com/quiz/48082

Sample Questions

Q1) New attributes and methods may be added to a subclass which makes it a(n)__________ version of the superclass.

Q2) The term ___________ refers to an object's ability to take different forms.

Q3) Given the following line of code,in a UML diagram,what would the open arrowhead point to?

Class Celery(Vegetable):

A) Celery

B) Vegetable

C) class

D) Celery(Vegetable)

Q4) What gives a program the ability to call the correct method depending on the type of object that is used to call it?

A) Polymorphism

B) Inheritance

C) Encapsulation

D) Methods

Q5) A superclass is also called a(n)__________ class.

Q6) In a UML diagram,a line with an open arrowhead from a subclass to a superclass indicates ___________.

13

To view all questions and flashcards with answers, click on the resource link above.

Chapter 12: Recursion

Available Study Resources on Quizplus for this Chatper

35 Verified Questions

35 Flashcards

Source URL: https://quizplus.com/quiz/48083

Sample Questions

Q1) What is the second step to take in order to apply a recursive approach?

A) Identify at least one case in which the problem can be solved without recursion.

B) Determine a way to use recursion to solve the problem in all circumstances which cannot be solved without recursion.

C) Determine a way to return to the main function.

D) Identify a way to stop the recursion.

Q2) Which of the following describes the base case in a recursive solution?

A) a case in which the problem can be solved without recursion

B) the case in which the problem is solved through recursion

C) the way to stop the recursion

D) the way to return to the main function

Q3) If a recursive solution is evident for a particular problem,and if the recursive algorithm does not slow system performance by an intolerable amount,then recursion would probably be a good design choice.

A)True

B)False

Q4) Some problems are more __________ solved with recursion than with a loop.

Q5) Recursive function calls are __________ efficient than loops.

To view all questions and flashcards with answers, click on the resource link above. Page 14

Chapter 13: Gui Programming

Available Study Resources on Quizplus for this Chatper

42 Verified Questions

42 Flashcards

Source URL: https://quizplus.com/quiz/48084

Sample Questions

Q1) Which widget creates an area that displays one line of text or an image?

A) Label

B) Canvas

C) Message

D) Text

Q2) In a GUI environment,no text input is possible.

A)True

B)False

Q3) A __________ program is an event-driven program.

A) GUI

B) command line

C) procedural

D) modular

Q4) Which of the following is not a method of the Canvas widget?

A) create_line

B) create_oval

C) create_button

D) create_text

Q5) The __________ widget is used to display text in a window.

Q6) The __________ module allows you to create GUI programs in Python.

Page 15

To view all questions and flashcards with answers, click on the resource link above.

Turn static files into dynamic content formats.

Create a flipbook
Python Programming Final Test Solutions - 533 Verified Questions by Quizplus - Issuu