Python 1 final review

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

x = 0while x < 5:x += 1print('loop') What is the output from running the above code most like? "loop" "loop" (4 times) "loop" (5 times) forever loop

"loop" (5 times)

def add_num(num_1 = 10):return num_1 + num_1 Choose the correct output of calling the function above using the following code: print(add_num(100)) 20 100 200 An Error

200

Convert 1D from hexadecimal to decimal

29

Which attributes can you define for a datetime.time object? Month Day Hour Second

Hour

Which of the following is an example of pseudocode? If button is clicked then add the numbers else display a message If btn_Sum.Clicked ThenSum = int_Num1 + int_Num2elsePrint("Don't you want to know the answer?")End If Click the button Add the numbers Show the answer 1) initial variable x to 42) increase x by 13) output x4) repeat steps 2 - 3 until x = 1005) output "program end"

If button is clicked then add the numbers else display a message

Which two functions can you use to determine whether a path leads to either a file or a directory? Choose 2. os.path.isfile(path) os.path.exists(file_path) os.path.isdir(path) os.remove(file_path)

os.path.isfile(path) os.path.isdir(path)

Which statements evaluate True and without errors? (Choose all that apply.) "The Title".istitle() 3.isdigit() "upper".islower() "upper".isupper()

"The Title".istitle() "upper".islower()

vehicle_type = "Truck" if vehicle_type.upper().startswith("P"): print(vehicle_type, 'starts with "P"') else: print(vehicle_type, 'does not start with "P"') What is the output from running the above code? "Truck starts with "P"" "Truck does not start with "P"" "True" "False"

"Truck does not start with "P""

count = 1while count >= 1:print("loop")count +=1 What is the output from running the above code most like? "loop" "loop" (2 times) "loop" (infinite times) no output

"loop" (infinite times)

def low_case(words_in):return words_in.lower() Choose the correct output of calling the function above using the following code: words_lower = low_case("Return THIS lower")print(words_lower) "Return THIS lower" No Output "return this lower" An Error

"return this lower"

x = 0while True:if x < 10:print('run forever')x += 1else:break What is the output from running the above code most like? "run forever" (10 times) "run forever" (9 times) "run forever" No output

"run forever" (10 times)

name = "skye homsi" name_1 = name.title()name_2 = name_1.swapcase()print(name_2) What is the output from the above code? "Skye Homsi" "sKYE hOMSI" "SKYE HOMSI" "skye homsi"

"sKYE hOMSI"

size_num = "8 9 10"size = "8" # user inputif size.isdigit() == False:print("Invalid: size should only use digits")elif int(size) < 8:print("size is too low")elif size in size_num:print("size is recorded")else:print("size is too high") What is the output from running the above code?

"size is recorded"

time = 3while True:print('time is', time)if time == 3:time = 4else:breakWhat is the output from running the above code most like? "time is 3" "time is 4" no output "time is 3" & "time is 4"

"time is 3" & "time is 4"

Which is a valid Python code comment? / comments make code easier to update. [comment] comments can provide use instructions for other developers. # use comments to describe the function of code. (comment) warnings can be placed in comments.

# use comments to describe the function of code.

When using printf-style string formatting, which conversion flag outputs a single character? %c %d %s %x

%c

When using printf-style string formatting, which conversion flag outputs a signed integer decimal? %c %d %s %x

%d

To move the pointer in an open file to the first character, what should you use? reset(filename) .seek(-1) .seek(0) All of the other answers are correct.

.seek(0)

To move the pointer 5 characters past the current pointer location, what should you use? All of the other answers are correct. .seek(5, 0) .seek(5,2) .seek(5,1)

.seek(5,1)

Which function displays a datetime.date object in the form Monday, January 01, 2018? .strftime("%A, %B %d, %Y") .strftime("%A, %B %D, %Y") .strftime("%A, %M %d, %Y") .strftime("%A, %M %D, %Y")

.strftime("%A, %B %d, %Y")

Which answer best describes what .strip() does in the following code sample? poem_line = poem1.readline().strip() .strip() removes leading and trailing parenthesis .strip() removes all whitespace in a string, including the '\n' formatting character .strip() removes leading and trailing whitespace, including the '\n' formatting character All of the other answers are correct.

.strip() removes leading and trailing whitespace, including the '\n' formatting character

x = 3 y = 3 calculation = x/y print(calculation) What is the best estimate for the output of the above code? 9 9.0 1 1.0

1.0

Convert 32 from decimal to binary

100000

def add_numbers(num_1, num_2 = 10):return num_1 + num_2 Choose the correct output of calling the function above using the following code: print(add_numbers(100)) 100 110 200 An error

110

Convert 1D from hexadecimal to binary

11101

Convert 240 from decimal to binary

11110000

Convert 10000011 from binary to hexadecimal

131

Convert 32 from decimal to hexadecimal

20

You perform the following Boolean comparison operation: (x >= 10) and (not (x < 20)) and (x % 2 == 0) For which two numbers is the comparison operation True? (Choose two.) 10 20 25 50

20

def add_num(num_1 = 10):print(num_1 + num_1) Choose the correct output of calling the above function using the following code: add_num() 0 10 20 An Error

20

name = input("enter your name") print(name, "your score is", score) score = 199 Order the above numbered code lines into the proper sequence. 1,2,3 2,3,1 3,1,2 3,2,1

3,1,2

Convert 110110 from binary to decimal

54

What does print(type(3.55)) return? <class 'float'> <class 'int'> <class 'string'> <class 'Bool'>

<class 'float'>

What does print(type("Hello World!")) return?

<class 'float'> <class 'int'> <class 'str'> <class 'bool'>

You are comparing two numerical values in the following operation: In [1]: 9 ___ 9 Out[1]: True Which operator correctly completes the operation? => =! >= <

>=

Which element should come first in a multi-line docstring for a function? A blank line The function arguments The function parameters A summary line that describes the function as a command

A summary line that describes the function as a command

Which of the following statements about tuples is true? A tuple can contain list elements. A tuple cannot contain another tuple. After you define a tuple, you can add elements to it. You define the elements of a tuple within square brackets.

A tuple can contain list elements.

Who is considered the Father of Computing? Ada Lovelace Charles Babbage Bill Gates Steve Jobs

Charles Babbage

What are the advantages of creating and using functions in code? (Choose all that apply.) code reuse Boolean string testing faster running code easier testing

Code reuse Easier testing

Testing for all syntax errors is called: Logic Errors Commenting Beta Testing Debugging

Debugging

In a Flowchart, what indicates the flow of logic? There is no flow of logic Direction of the arrow What color the symbol is, follow ROYGBIV pattern Where the symbol is placed

Direction of the arrow

An infinite loop is a loop that runs until the value returned by the loop condition is False.

False

Function calls should be placed at the beginning of a code page, and functions should be placed later and toward the end of the code. True False

False

Function names cannot begin with a number as the first character. True False

False

In Python string comparisons, lower case "a" is less than upper case "A". True False

False

In Python, we can use the "+" operator to add numbers, but not to add strings.

False

Python Function return values must be stored in variables. True False

False

To read each line of a file as an item in a list, use .listread(). True False

False

True or False: You can use the remove function to delete a specific file directory. True False

False

When handling exceptions, Python code can include an else clause or a finally clause, but not both. True False

False

You are performing the following operation: In [1]: 10 == 20 Out[1]: _____ What is the result of the operation? 0 10 True False

False

while True: will loop forever but can be interrupted using the Python keyword "end" inside the loop. True False

False

What will be displayed by the following code? count = 0 while count < 5: print("Hello", end = " ") count +=1 Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello, Hello, Hello, Hello, Hello, Hello

Hello Hello Hello Hello Hello

What is the order of the five steps of the programming process? Identify the Problem Design the Solution Write the Program Test the Program Document and Maintain the Program Design the Solution Identify the Problem Write the Program Test the Program Document and Maintain the Program Identify the Problem Design the Solution Write the Program Document and Maintain the Program Test the Program Design the Solution Identify the Problem Document and Maintain the Program Write the Program Test the Program

Identify the Problem Design the Solution Write the Program Test the Program Document and Maintain the Program

Which two statements about the pydoc module are true? It generates documentation from the docstrings in a module. It generates documentation for a module without importing it. It imports a module and then generates documentation for the module. It automatically suppresses module functions from running while generating documentation for the module.

It generates documentation from the docstrings in a module. It imports a module and then generates documentation for the module.

Which two statements about a positional argument are true? (Choose two.) It is a required argument It is an optional argument It is always the first argument Its position depends on the command

It is a required argument Its position depends on the command

print("It's time to code") What is the output of the above code? It's time to code It"s time to code Its time to code an Error

It's time to code

1. 2. score = add_score(190) 3. 4. print(name, "your score is", score) 5. At which line above should the following add_score() function definition be inserted so the program runs without error? def add_score(current):return current + 10

Line 1

In which two ways is a tuple like a list? (Choose two) Lists and tuples are data structures that can store a sequence of elements. Lists and tuples are immutable data structures. Lists and tuples can contain int, float, list, and string elements. You can reorder the elements of lists and tuples.

Lists and tuples are data structures that can store a sequence of elements. Lists and tuples can contain int, float, list, and string elements.

PriNt("Hello World!") will not output the message "Hello World!". What will it result in? TypeError SyntaxError NameError This is not an error

NameError

Which version of Python does this course cover? Python 2 Python 3 Python 4 Python 5

Python 3

Which of the following statements is true? Python variables are case sensitive Python variables have a fixed, unchangeable data type Python variable names start with a number, letter or underscore Python variables cannot be assigned new values

Python variables are case sensitive

Which is NOT a way to run a code cell in a Jupyter Notebook? Shift + R Ctrl + Enter Shift + Enter Menu: Runtime>Run focused cell

Shift + R

Which is NOT a way to run a code cell in a Jupyter Notebook?

Shift + R Ctrl + Enter Shift + Enter Menu: Runtime>Run focused cell

assignment = 25if assignment = 25:print('use "=" to assign values')else:pass What is the output of the above code? SyntaxError "use "=" to assign values" True No Output

SyntaxError

Which line of code defines a heterogeneous tuple? T = ("switch",) T = tuple(L) T = ("Tobias", 23, 25.3, []) T = (10, -4, 59, 58, 23, 50)

T = ("Tobias", 23, 25.3, [])

Given that the file school_names contains the following text with 3 school names: City ElementaryMaths High SchoolEarly Learner PreSchool if we run the following code: schools = open("school_names.txt", "w+") Which item is Not True? The file school_names will contain the original 3 school names. The file school_names will be erased and empty. We can now read to the school_names by using schools.readline(). schools.read()will return an empty string.

The file school_names will contain the original 3 school names.

When a function calls a subfunction, which variables are maintained in memory? (Choose all that apply.) The global variables The function variables The subfunction variables

The global variables The subfunction variables

What is the result of not setting the value of the year attribute of a datetime.date object. The year defaults to 0. The year defaults to the current year. The year defaults to 9999. The object is invalid.

The object is invalid.

Which two statements are true for two objects that contain the same information and are saved in different memory locations? Example: ```python x = [1,2,3,a,b] y = [1,2,3,a,b] ``` (Choose two.) They are equal. They are not equal. They are identical. They are not identical.

They are equal. They are not identical.

What is print() used for? To input To make strings To display output None of the answer choices are correct

To display output

"Hello".isalpha() What is the output of the above code? "Hello" True and a false if it is not. False Error

True

"w+" mode opens a file for write plus read, such as in the following Python code: schools = open("school_names.txt", "w+")

True

.readline() is used to read one line, as a string, from an open text file.

True

A datetime.timedelta object stores only days, seconds, and microseconds. True False

True

A file opened in read mode cannot be changed (we cannot write to the file).

True

For the code: x = 3 + 9 * 2, the value of x is 21 when applying order of operations.

True

In Python, using the `raise` statement allows the programmer to define and raise their own exception.

True

Jupyter Notebooks have code cells and markdown(text) cells.

True

Like else, the elif can execute only when the previous if conditional evaluates False (shown in the below code sample). if response == 3: return "Correct"elif response <= 0: return "Correct"else: return "Incorrect"

True

Nested Conditional code always runs all sub-conditions that are indented under if statements.

True

Python code can include a script that returns the operating system platform your code is running on with the .sys.

True

The containment operators in and not in return a True/False result.

True

The double equal sign (==) is used to compare values.

True

The input() function in Python returns user input as a string.

True

This course load is based on daily M-F 90 minute class time on a computer with reliable Internet access.

True

length = "33"length.isalnum() What is the output of the above code? "33" Error False True

True

name = "SKYE HOMSI"print("y" in name.lower()) What is the output from the above code? True False "skye homsi" 3

True

while 3 < 5: is a forever loop just like while True: is. True False

True

answer = input("enter your answer: "); print(10 + answer) If user input is 38, what is the output of the above code? 48 1038 10answer TypeError

TypeError

Which process can you use to assign the values of a tuple to multiple variables? Convert the tuple into a list Create a homogeneous tuple Slice the tuple Unpack the tuple

Unpack the tuple

Choose the correct statement. Variables only represent strings in Python. Variables in Python can be initialized using the equals sign (=). The same variable in Python can be represented in either upper or lower case. New variables always start out as zero.

Variables in Python can be initialized using the equals sign (=).

def ignore_case(name):answer = ""while answer.isalpha() == False:answer = input("enter last name: ")return answer.lower() == name.lower() When will the ignore_case function exit the while loop? When answer == name When only letters are entered at the input prompt When answer.lower() == name.lower() When a digit is entered at the input prompt

When only letters are entered at the input prompt

Which statement about local variables is true? A local variable can be read from the global scope. You can use the same variable name in multiple functions. A local variable in one function can be read from another function. A function can update a global variable in a local scope by using the same name for a local variable and assigning a new value.

You can use the same variable name in multiple functions.

True or False The code print("I am", 17, "years old") will output: I am17years old

Your Answer: False. The "," aka the comma's give space between the am and 17

The keyword that interrupts the loop is ____. end stop break final

break

In a loop, a(n) ____, which is either true or false, determines whether the computer will execute the loop again. executable condition keyword Integer value

condition

A(n) ____-controlled loop requires that you initialize a variable before the loop. object procedure item counter

counter

A function with 2 integer parameters could start with which definition? funct add_numbers(num_1, num_2): def add_numbers(num_1, num_2): def 2_numbers(num_1, num_2): FUNCTION add_numbers(x, y):

def add_numbers(num_1, num_2):

All of the following are part of testing except debugging deployment logic errors beta testing

deployment

Spelling and grammar are irrelevant in Computer Programming.

false

The type() function is used to change from one data type to another. True False

false

Which clause should you use for code that you want to execute regardless of whether an exception is raised? else elseif except finally

finally

Which three data types can you use for dictionary keys? (Choose three.) float int lists other dictionaries string

float int string

Which code should you use to import a function named abc from a Python module named xyz?

from xyz import abc

Which process does Python use to optimize dictionary search capabilities? containment hashing iteration looping

hashing

Which operator has the highest precedence? (Choose one.) or is not

is not

greet(name) name = input("enter your name: ") greet(name) def greet(person): print("Hi,", person) greet(name) Which line or lines need to be removed from the above code so the program prints a greeting without error? lines 1 and 2 lines 1 and 3 line 1 only line 3 only

lines 1 and 3

Which is the best choice to complete the following sentence? Opening a file in Python using read mode ('r')... reads the file as a string 10 characters at a time. creates a new file. makes file contents available for Python to read from the file. erases all of the contents of the file being opened.

makes file contents available for Python to read from the file.

Which function from the math module can you use to round up the number 12.34 to 13? math.ceil() math.float() math.floor() math.trunc()

math.ceil()

def greet(person): print("Hi,", person) greet(name) Which line is missing so this program runs without error and prints a greeting using the user's name. another greet(name) statement before the definition. name = input("enter your name: ") greet = person person = Susan Question 75

name = input("enter your name: ")

What type of loop should you use to iterate over the elements of a simple table (two-dimensional list)? compound for nested while

nested

Which Boolean operator has the highest precedence? (Choose one.) and not or >=

not

num_1 = 3num_2 = "8" What is the minimum code to mathematically add num_1 to num_2? num_1 + str(num_2) int(num_1) + str(num_2) num_1 + int(num_2) int(num_1) + int(num_2)

num_1 + int(num_2)

Which function can you use to list the contents of the current working directory? os.listdir() os.chdir() os.getcwd() os.rmdir()

os.listdir()

Which function can you use to test whether an absolute or relative path to a folder is valid? os.path.commonpath(paths) os.path.exists(path) os.path.normpath(path) os.path.realpath(path)

os.path.exists(path)

Which two os module functions can you use to delete a specific file?

os.remove() os.unlink()

Which function can you use to delete an empty folder? os.chdir() os.getcwd() os.rmdir() os.listdir()

os.rmdir()

Which type of statement should you use as a placeholder for future function code? break place pass continue

pass

Hello World! What is the best choice of code to create the output shown above? print("Hello\pWorld!") print("Hello World!") print("Hello\nWorld!") print("Hello\tWorld!")

print("Hello\nWorld!")

Which is a properly formatted Python print() function example? print("Welcome the", 3, New students!) print("Welcome the", 3 + New students!) print("Welcome the", 3, "New students!") print("Welcome the", 3 + " New students!")

print("Welcome the", 3, "New students!")

\\\\ What is the best choice of code to create the output shown above? print("'\''\''\''\''\'") print("\\\\") print(\\\\) print("\\\\\\\\")

print("\\\\\\\\")

Which of the following is a Python function? "Hello World!" x = 3 print() def

print()

Given the following code, which choice is best to represent the first line in the text file books.txt in Title format, where every word is capitalized? books = open('books.txt', 'r') print(books.readline().title()) print(books[0].upper()) print(books.readline().upper()) All of the other answers are correct.

print(books.readline().title())

Given the code below and entering "Colette" for user_name input: total_cost = 22.95 user_name = input("Enter your name: ") Choose the print statement that will output: Colette - the total is $ 22.95 for today's purchase print(Colette, "- the total is $", total_cost, "for today's purchase") print(user_name, "- the total is $", total_cost, "for today's purchase") print(Colette, '- the total is $', total_cost, 'for todays purchase') print("user_name", "- the total is $", "total_cost", "for today's purchase")

print(user_name, "- the total is $", total_cost, "for today's purchase")

Which command should you use to generate HTML documentation for a Python module named program.py? pydoc program pydoc -h program.py pydoc -w program pydoc -t program.py

pydoc -w program

Which command should you use to generate text documentation for a Python module named program.py? pydoc -h program.py pydoc program command:pydoc test. pydoc -t program.py pydoc -w program

pydoc program

Which function returns only whole, even numbers from within the range from 1 to 100? random.choice(1, 100, even) random.randint(1, 100, 2) random.randrange(2, 100, 2) random.uniform(1, 100)

random.randrange(2, 100, 2)

What is the best choice to complete the following sentence? Using .readlines() to read an open file results in... reading one line at a time. reading the entire file as a string. reading each line in the file as an item in a list. Menu: Cell... > Run Cells.

reading each line in the file as an item in a list.

x = 3y = "3" # get_diff takes an int and a str def get_diff(xint, ystr):# <function code needed here>if y.isdigit() == False:print('"y" is not an integer string')elif get_diff(x,y) == 0:print('x equal to y')else:print('x is NOT equal to y') To make this program work, printing "x equal to y", choose the best code to replace the above comment "# <function code needed here> " in the get_diff function return int(ystr) - xint return str(ystr) - in(xint) return ystr - x return int(xint) - y

return int(ystr) - xint

def show_name():print("Tobias Ledford") Which code calls the function in the above code? show_name.run() open(show_name) run show_name show_name()

show_name()

Which of the following are valid expressions for the datetime.timedelta objects t1, t2, and t3? (Choose all that apply.) t1 = t2 - t3 t1 = 6 % t2 month = datetime.timedelta(1 month) year = datetime.timedelta(365 days)

t1 = t2 - t3 t1 = 6 % t2

Given the following starting code: test1 = open('test1.txt', 'r') We can read 10 string characters from a file into memory by using which Python code? ten_char = test1.read(11) ten_char = test1.read(10) ten_char = test1[0:11] All of the other answers are correct.

ten_char = test1.read(10)

After we open a file (first_test) using: test1 = open('test1.txt', 'r') we can read the file into memory with which Python code? for test_data in test1: test_data.open.read(test1) test_data = open(test1) test_data = test1.read()

test_data = test1.read()

A program is a list of instructions that makes the computer think. written in English that tells the computer what to do. that performs a specific task when executed by a computer written in a special language that the computer understands. written in Java that makes the computer think.

that performs a specific task when executed by a computerwritten in a special language that the computer understands.

For full credit on Python assignments, you must submit the following: the .pdf file the .ipynb file the .pdf file AND the .ipynb file .py file

the .pdf file AND the .ipynb file

The .close method conserves system memory because... file.close() compresses files by 50%. file.close() closes any unused files created by Python file.close() permanently deletes all text data in the target file. the file.close() method removes the reference created from file.open() function.

the file.close() method removes the reference created from file.open() function.

When using .readlines(), it is common to remove the last character of each string in the generated list, because... A. .readlines() adds a character that cannot be processed. the last character is always duplicated when using .readlines(). the last character is typically a whitespace newline character, "\n". All of the other answers are correct.

the last character is typically a whitespace newline character, "\n".

Complete the sentence to be true for code running in a Python environment. A local scope is created... when a function is created. when a function is called. when a function returns to its caller. when a function is destroyed.

when a function is called.

What type of loop should you use to repeat a code process as long as a condition resolves as `True`? compound for nested while

while

Which is not a possible "infinity/infinite" loop? while True: while 1 > 0: while 1 != 0: while 0 > 1:

while 0 > 1:

An infinite loop is a loop: that stops when its condition is false. whose condition is always false that stops when its condition is true. whose condition is always true.

whose condition is always true.

Which statement ensures that a file will be closed even when an exception is raised? else: file.close() with open(file_path, mode) as file: file.close() file = open(file_path, mode)

with open(file_path, mode) as file:

Given x has the value of 9, which line of code will evaluate False? x == 9 x < 3 3 < x 9 <= x

x < 3

if x < 0: print("-")else: if y >= 0: print("+/+") else: print("+/-") Which values for x and y result in the output "+/-"? (Choose the best answer.) x = 1 and y = 0 x = 0 and y = -1 x = 0 and y = 0 x = -1 and y = 1

x = 0 and y = -1

if x < 0: print("-")else: if y >= 0: print("+/+") else: print("+/-")The nested conditional code is sure to be run if ___. (Choose the best answer.) x = 1 x = -1 y = -1 y = 1

x = 1

In what format does a dictionary store information? (key, value) [key:value] {key, value} {key:value}

{key:value}

When using the str.format() method, which placeholder outputs the variable x as a three-digit float with two digits before and one digit after the decimal point (for example, 12.3)? {x:2.2f} {x:3.1f} {x:3.2f} {x:4.2f}

{x:3.1f}

x = 3 y = 4 calculation = x*y print(calculation) What is the best estimate for the output of the above code? 12.0 9.0 12 9

12

calculation = 5 + 15 / 5 + 3 * 2 - 1 print(calculation) What is the best estimate for the output of the above code? 13 13.0 9 9.0

13.0

day = "monday" if day.capitalize() == "Monday": print("Start the week!") else:pass What is the output from running the above code? True False No Output "Start the week!"

"Start the week!"

Which is an example of a valid one-line docstring?

"""This rolls dice"""

year = "2001" if year.isdigit(): print(year, "is all digits") else: pass What is the output from running the above code? "True" "False" No Output "2001 is all digits"

"2001 is all digits"

if True: if False: print("Banana") else: print("Apple")else: if True: print("Dates") else: print("Corn") What is the output of the above code? "Dates" "Corn" "Banana" "Apple"

"Apple"

hot_plate = True if hot_plate: print("Be careful, hot plate!") else:print("The plate is ready.") What is the output from running the above code? "Be careful, hot plate!" "The plate is ready." "True" NameError

"Be careful, hot plate!"

name = "Jin Xu" if type(name) == type("Hello"): print(name, "is a string entry") else: print(name, "is not a string entry") What is the output from running the above line of code? "Hello Jin Xu" "Jin Xu is a not string entry" "Jin Xu is a string entry" "string"

"Jin Xu is a string entry"

Given that the file school_names contains the following text: *City*Elementary* *Maths*High*School* *Early*Learner*PreSchool* Which answer best describes the output of the following code? schools = open("school_names.txt", "r") name = schools.readline().strip('*\n')while name:if name.startswith("M"):print(name)else:passname = schools.readline().strip('*\n') "Maths High School" "Maths*High*School" "MathsHighSchool" "*Maths*High*School*"

"Maths*High*School"

Which operator has the highest precedence? (Choose one.) + == and

+

When using the str.format() method, which flag places a - (negative sign) in front of negative numbers?

-

In an os function, which syntax can you use to move up one folder in the current directory structure? / \ // . .

. .

Convert 1 from hexadecimal to decimal

1

num_1 = ""num_temp = ""num_final = ""while True:num_1 = input("Enter an integer: ")if num_1.isdigit():num_final = num_temp + num_1num_temp = num_finalelse:print(num_final)break What is the output, when running the above code, if the user plans to enter input in the following order at the "Enter an Integer:" prompt? 1st input: 3 2nd input: 4 3rd input: five 4th input: 6

34

When using Python, which mathematic operation returns a value of 2? 42/4 42//4 42 % 4 42 ** 4

42 % 4

When using Python, what is the result of the mathematical operation 1 ** (2 * 3) / 4 + 5? 0.11 .067 5.25 6.50

5.25

Which statement about the datetime data type is true? All variables are optional. All variables are required. All date variables are required. All time variables are required.

All variables are required.

Which is NOT a high-level programming language? C ++ Java Python Assembly Language

Assembly Language

In Python, what is the base class for all built-in exceptions? BaseException Error Exception IOError

BaseException

Convert 240 from decimal to hexadecimal

F0

What are the part(s) of identifying the problem in the programming process? Specifications only Requirements only Requirements and Specifications Requirements and Documentation

Requirements and Specifications

What is the output of the following code? print('She said, "Who is there?"')

She said,"Who is there?"

You run a Python script named my_script.py directly from a terminal window. In the script environment, what is the value of the `__name__` variable? `__my_script__` `__main__` `my_script` `my_script.py`

`__main__`

You run a Python script named my_script.py by importing it as a module into a script named second_script.py. In the script environment, what is the value of the `__name__` variable? `__main__` `__my_script__` `my_script` `my_script.py`

`my_script`

What does the input() function return? an integer value a string value a float value All of the answer choices are correct

a string value

Which information should you include in a multi-line docstring for a function? arguments, return values, and exceptions function name function parameters public methods and instance variables

arguments, return values, and exceptions

Which element stores Python script command-line arguments and options? arg argc argparse argv

argv

Which expression defines an object named hiredate with a value of July 1, 2018? hiredate = datetime.datetime(year = 2018, month = 7, day = 1) hiredate = datetime.date(year = 2018, month = 7, day = 1) hiredate = datetime.timedate(year = 2018, month = 7, day = 1) hiredate = datetime.timedelta(days = 43282)

hiredate = datetime.date(year = 2018, month = 7, day = 1)

Given the following string: s = "Welcome" Which code results in an error? print(s) print(s.lower()) s = 'r' print(s + 1)

print(s + 1)


संबंधित स्टडी सेट्स

Stevenson, "The Nature of Ethical Disagreement"

View Set

Ch 16 The Nursing Role in Providing Comfort During Labor and Birth

View Set

Pharmacology- CH 91- Fluoroquinolones, metronidazole, Rifampin, etc.

View Set

Chapter 17 Law Final Study Guide

View Set

Chapter 15 Drugs Affecting Inflammation and Infection

View Set