Python Final Exam Questions and Answers, Exams of Advanced Education

A comprehensive set of questions and answers related to python programming, suitable for exam preparation or self-assessment. It covers topics such as object-oriented programming concepts (subclasses, polymorphism, inheritance), basic syntax, data types, operators, control structures (decision and loop statements), file handling, and exception handling. The questions are designed to test understanding of fundamental python concepts and their practical application. This resource is valuable for students learning python and preparing for exams or quizzes. It includes questions on variables, strings, operators, and control flow, making it a useful tool for reinforcing key concepts and improving problem-solving skills in python programming. The document also covers file handling and exception handling, providing a well-rounded review of essential python programming topics.

Typology: Exams

2024/2025

Available from 11/16/2025

guidedexam
guidedexam 🇺🇸

2.5

(2)

6.9K documents

1 / 31

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Python Final Exam Questions and
Answers
You create a subclass from a superclass. You can only access private data
attributes derived from the parent class using...
accessor methods
dot operator
__str__
initialization method - ANSWERS-accessor methods
Polymorphism allows you to write methods in a subclass that have the same
name as methods in the superclass.
True
False - ANSWERS-True
It is not possible to call a superclass's __init__ method from a subclass's
__init__ method.
True
False - ANSWERS-False
A subclass can have a method with the same name as a method in the
superclass.
True
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f

Partial preview of the text

Download Python Final Exam Questions and Answers and more Exams Advanced Education in PDF only on Docsity!

Python Final Exam Questions and

Answers

You create a subclass from a superclass. You can only access private data attributes derived from the parent class using... accessor methods dot operator str initialization method - ANSWERS-accessor methods Polymorphism allows you to write methods in a subclass that have the same name as methods in the superclass. True False - ANSWERS-True It is not possible to call a superclass's init method from a subclass's init method. True False - ANSWERS-False A subclass can have a method with the same name as a method in the superclass. True

False - ANSWERS-True Only the init method can be overridden. True False - ANSWERS-False You can have an empty class. True False - ANSWERS-True A(n) __________ program translates a high-level language program into a separate machine language program. translator assembler compiler utility - ANSWERS-compiler The rules that must be followed when writing a program are called __________. operators punctuation syntax key words - ANSWERS-syntax

4 - ANSWERS-

A byte is enough memory to store a(n) __________ value. character exponential integer floating point - ANSWERS-character A type of memory that can hold data for long periods of time, even when there is no power to the computer, is called __________. RAM CPU registers secondary storage main memory - ANSWERS-secondary storage This is a volatile type of memory that is used only for temporary storage while a program is running. secondary storage RAM the USB drive the disk drive - ANSWERS-RAM

The part of a computer that runs programs is called __________. CPU secondary storage RAM main memory - ANSWERS-CPU Which command is used to print the path to the current working directory? path chmod cat pwd - ANSWERS-pwd What does mv my_file.py my_file2.py do? renames my_file2.py to my_file.py renames my_file.py to my_file2.py moves my_file2.py to the directory my_file.py moves my_file.py to the directory my_file2.py - ANSWERS-renames my_file.py to my_file2.py Which command allows you to view the contents of a file without opening a text editor? ls -l pwd

./filename cd usr/local/bin/filename .. cd .. - ANSWERS-cd .. What is the command to create a directory? rmdir cdir mkdir cd - ANSWERS-mkdir To remove a directory mydirectory as well as the corresponding files that directory contains, which command do we use? rmdir mydirectory rm -r mydirectory delete -r mydirectory delete mydirectory - ANSWERS-rm -r mydirectory In the vi/vim editor what key must be pressed to go to command mode? shift-f cntrl esc i - ANSWERS-esc

A __________ is a sequence of characters. text block string character collection char sequence - ANSWERS-string A __________ is a name that references a value in the computer's memory. variable register RAM slot byte - ANSWERS-variable A string literal in Python must be enclosed in either single-quotes or double-quotes. double quotes. single quotes. parentheses. - ANSWERS-either single-quotes or double-quotes. A(n) __________ makes a variable reference a value in the computer's memory. assignment statement variable declaration string literal

* - ANSWERS-**

Suppose the following statement is in a program: price = 99.0. After this statement executes, the price variable will reference a value of this data type. char integer string float - ANSWERS-float What is the return datatype of the function input()? string float integer boolean - ANSWERS-string A __________ structure can execute a set of statements only under certain circumstances. Boolean circumstantial sequence decision - ANSWERS-decision A(n) __________ expression has a value of either true or false.

input output assignment Boolean - ANSWERS-Boolean ________ are relational operators. and, or if-else =

, <, >=, <=, ==, != - ANSWERS->, <, >=, <=, ==, != A parallelogram is used to represent a(n) _____ statement in a program control flow chart. start/finish decision assignment input/output - ANSWERS-input/output You use a(n) __________ statement to write a single alternative decision structure. test-jump if-elif-else if-else

not

= or and - ANSWERS-or The ___________ operator takes a Boolean expression as its operand and reverses its logical value. either not and or - ANSWERS-not A __________ -controlled loop uses a true/false condition to control the number of times that it repeats. decision sentinel/condition counter Boolean - ANSWERS-sentinel/condition A __________ -controlled loop repeats a specific number of times. counter decision Boolean sentinel/condition - ANSWERS-counter

Each repetition of a loop is known as a(n) __________. revolution orbit iteration resolution - ANSWERS-iteration The while loop is a __________ type of loop. no test prequalified pretest post-test - ANSWERS-pretest A(n) __________ loop has no way of ending and repeats until the program is interrupted. timeless indeterminate interminable infinite - ANSWERS-infinite The -= operator is an example of a(n) __________ operator. augmented assignment reverse assignment

a c b 1 - ANSWERS-a Refer to the following python code snippet: a = 100 b = 1 c = 5 while a > 1: b += 1 a*=0. print(b,c) What type of loop is this? sentinel controlled always true flagged

counter controlled - ANSWERS-sentinel controlled Refer to the following python code snippet: a = 100 b = 1 c = 5 while a > 1: b += 1 a*=0. print(b,c) What is b? flag sentinel value counter boolean - ANSWERS-counter A file that data is written to is known as a(n):

English file binary file image file text file - ANSWERS-text file This type of file contains data that has not been converted to text. text file binary file symbolic file unicode file - ANSWERS-binary file When working with this type of file, you access its data from the beginning of the file to the end of the file. direct access sequential access random access binary access - ANSWERS-sequential access When working with this type of file, you can jump directly to any piece of data in the file without reading the data that comes before it. sequential access binary access ordered access

direct access - ANSWERS-direct access This is a small "holding section" in memory that many systems write data to before writing the data to a file. virtual file variable temporary file buffer - ANSWERS-buffer You write this statement to respond to exceptions. run/handle try/handle try/except attempt/except - ANSWERS-try/except This is the first index in a string. 0 The size of the string minus one 1 -1 - ANSWERS- This is the last index in a string. size of the string minus one