Docsity

Linux Commands and Python Fundamentals, Exams of Advanced Education

Toggle sidebar
bg1
Python Final Exam With 100% Correct
And Verified Answers 2024
A(n) __________ program translates a high-level language program into a separate
machine language program.
translator
assembler
compiler
utility - Correct Answer-compiler
The rules that must be followed when writing a program are called __________.
operators
punctuation
syntax
key words - Correct Answer-syntax
The __________ translates an assembly language program to a machine language
program.
assembler
translator
compiler
interpreter - Correct Answer-assembler
Computers can only execute programs that are written in __________.
assembly language
Java
Python
machine language - Correct Answer-machine language
In the __________ numbering system, all numeric values are written as sequences of
0s and 1s.
octal
hexadecimal
decimal
binary - Correct Answer-binary
A byte is made up of __________ bits.
2
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12

Partial preview of the text

Download Linux Commands and Python Fundamentals and more Exams Advanced Education in PDF only on Docsity!

Python Final Exam With 100% Correct

And Verified Answers 2024

A(n) __________ program translates a high-level language program into a separate machine language program. translator assembler compiler utility - Correct Answer-compiler The rules that must be followed when writing a program are called __________. operators punctuation syntax key words - Correct Answer-syntax The __________ translates an assembly language program to a machine language program. assembler translator compiler interpreter - Correct Answer-assembler Computers can only execute programs that are written in __________. assembly language Java Python machine language - Correct Answer-machine language In the __________ numbering system, all numeric values are written as sequences of 0s and 1s. octal hexadecimal decimal binary - Correct Answer-binary A byte is made up of __________ bits. 2

4 - Correct Answer- A byte is enough memory to store a(n) __________ value. character exponential integer floating point - Correct Answer-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 - Correct Answer-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 - Correct Answer-RAM The part of a computer that runs programs is called __________. CPU secondary storage RAM main memory - Correct Answer-CPU Which command is used to print the path to the current working directory? path chmod cat pwd - Correct Answer-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

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 - Correct Answer-rm -r mydirectory In the vi/vim editor what key must be pressed to go to command mode? shift-f cntrl esc i - Correct Answer-esc A __________ is a sequence of characters. text block string character collection char sequence - Correct Answer-string A __________ is a name that references a value in the computer's memory. variable register RAM slot byte - Correct Answer-variable A string literal in Python must be enclosed in either single-quotes or double-quotes. double quotes. single quotes. parentheses. - Correct Answer-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 math expression - Correct Answer-assignment statement This symbol marks the beginning of a comment in Python &

% - Correct Answer-# Which of the following statements will cause an error? x = 17 x = 42 % 7 17 = x x = '17' - Correct Answer-17 = x This operator performs integer division. % ** / // - Correct Answer-// This is an operator that raises a number to a power. / % **

    • Correct Answer-** 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 - Correct Answer-float What is the return datatype of the function input()? string float integer boolean - Correct Answer-string A __________ structure can execute a set of statements only under certain circumstances. Boolean circumstantial sequence

A compound Boolean expression created with the __________ operator is true only if both of its sub expressions are true. and not or both - Correct Answer-and A compound Boolean expression created with the _________ operator is true if either of its sub expressions is true. not

= or and - Correct Answer-or The ___________ operator takes a Boolean expression as its operand and reverses its logical value. either not and or - Correct Answer-not A __________ -controlled loop uses a true/false condition to control the number of times that it repeats. decision sentinel/condition counter Boolean - Correct Answer-sentinel/condition A __________ -controlled loop repeats a specific number of times. counter decision Boolean sentinel/condition - Correct Answer-counter Each repetition of a loop is known as a(n) __________. revolution orbit iteration resolution - Correct Answer-iteration

The while loop is a __________ type of loop. no test prequalified pretest post-test - Correct Answer-pretest A(n) __________ loop has no way of ending and repeats until the program is interrupted. timeless indeterminate interminable infinite - Correct Answer-infinite The -= operator is an example of a(n) __________ operator. augmented assignment reverse assignment complex assignment relational - Correct Answer-augmented assignment A(n) __________ variable keeps a running total. constant valued counter sentinel accumulator - Correct Answer-accumulator 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 the loop control variable?

flag sentinel value counter boolean - Correct Answer-counter A file that data is written to is known as a(n): input file output file binary file sequential access file - Correct Answer-output file A file that data is read from is known as a(n) output file sequential access binary file input file - Correct Answer-input file Before a file can be used by a program, it must be encrypted opened closed formatted - Correct Answer-opened When a program is finished using a file, it should do this. erase the file open the file close the file encrypt the file - Correct Answer-close the file The contents of this type of file can be viewed in an editor such as Notepad. English file binary file image file text file - Correct Answer-text file This type of file contains data that has not been converted to text. text file binary file symbolic file

unicode file - Correct Answer-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 - Correct Answer-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 - Correct Answer-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 - Correct Answer-buffer You write this statement to respond to exceptions. run/handle try/handle try/except attempt/except - Correct Answer-try/except This is the first index in a string. 0 The size of the string minus one 1 -1 - Correct Answer- This is the last index in a string. size of the string minus one 0 1 size of the string - Correct Answer-size of the string minus one

This string method returns a copy of the string with all leading and trailing whitespace characters removed. rstrip remove_whitespace clean strip - Correct Answer-strip You can use the _________ operator to determine whether a key exists in a dictionary. ^ in ? & - Correct Answer-in You use _________ to delete an element from a dictionary. erase delete del remove - Correct Answer-del The _________ function returns the number of elements in a dictionary: len() count() elements() size() - Correct Answer-len() You can use _________ to create an empty dictionary. [] empty() {} () - Correct Answer-{} The _________ method returns a randomly selected key-value pair from a dictionary. rand_pop() popitem() pop() random() - Correct Answer-popitem() The _________ dictionary method returns the value associated with a specified key. If the key is not found, it returns a default value.

value() get() key() pop() - Correct Answer-get() The _________ method returns all of a dictionary's keys and their associated values as a sequence of tuples. get() values() items() keys_values() - Correct Answer-items() The following function returns the number of elements in a set: size() elements() len() count() - Correct Answer-len() You can add one element to a set with this method. merge add append update - Correct Answer-add You can add a group of elements to a set with this method. update add merge append - Correct Answer-update This set method removes an element but does not raise an exception if the element is not found. discard erase remove delete - Correct Answer-discard This operator can be used to find the union of two sets.

^

An object is a(n) ______________. variable cookie cutter instance blueprint - Correct Answer-instance By doing this you can hide a class's attribute from code outside the class. begin the attribute's name with two underscores avoid using the self parameter to create the attribute begin the name of the attribute with private__ begin the name of the attribute with the @ symbol - Correct Answer-begin the attribute's name with two underscores A(n) ______________ method gets the value of a data attribute but does not change it. mutator accessor retriever constructor - Correct Answer-accessor A(n) ______________ method stores a value in a data attribute or changes its value in some other way. modifier constructor accessor mutator - Correct Answer-mutator The ______________ method is automatically called when an object is created. object str init init - Correct Answer-init If a class has a method named str, which of these is a way to call the method? by passing an instance of the class to the built in str function you call it like any other method: object .str() by passing an instance of the class to the built-in state function the method is automatically called when the object is created - Correct Answer-by passing an instance of the class to the built in str function

A set of standard diagrams for graphically depicting object-oriented systems is provided by ______________. flowcharts the Object Hierarchy System the Unified Modeling Language pseudocode - Correct Answer-the Unified Modeling Language In one approach to identifying the classes in a problem, the programmer identifies the ______________ in a description of the problem domain. nouns adjectives verbs adverbs - Correct Answer-nouns In one approach to identifying a class's data attributes and methods, the programmer identifies the class's ______________. nouns name responsibilities synonyms - Correct Answer-responsibilities In an inheritance relationship, the __________ is the general class. slave class child class subclass superclass - Correct Answer-superclass In an inheritance relationship, the __________ is the specialized class. master class parent class subclass superclass - Correct Answer-subclass Suppose a program uses two classes: Airplane and JumboJet. Which of these would most likely be the subclass? none of the above both Airplane JumboJet - Correct Answer-JumboJet