insy 1

¡Supera tus tareas y exámenes ahora con Quizwiz!

What are the values that the variable num contains through the iterations of the following for loop? for num in range(4):

0,1,2,3

What are the values that the variable num contains through the iterations of the following for loop? for num in range(10, 1, -1):

10,9,8,7,6,5,4,3,2

What are the values that the variable num contains through the iterations of the following for loop? for num in range(2, 9, 2):

2,4,6,8

What is the output of the following command, given that the value1 = 2.0 and value2 = 12? print(value1 * value2)

24.0

What will be the output after the following code is executed? def pass_it(x, y): z = y**y return(z) num1 = 3 num2 = 4 answer= pass_it(num1, num2) print(answer)

256

What will be displayed after the following code is executed? for num in range(0, 20, 5): num += num print(num)

30

How many numbers of loop iterations will both of the following for clauses generate? for num in range(1, 5):

4

How many numbers of loop iterations will both of the following for clauses generate? for num in range(4):

4

What will be displayed after the following code is executed? total = 0 for count in range(4, 6): total += count print(total)

4 9

What will be displayed after the following code is executed? total = 0 for count in range(1,4): total += count print(total)

6

When applying the .3f formatting specifier to the number 76.15854, what will be the result?

76.159

Which of the following is not an augmented assignment operator?

<=

Which of the following are steps in the program development cycle? A. design the program B. write the code and correct syntax errors C. test the program D. correct logic errors

ABCD

A local variable can be accessed from anywhere in the program.

False

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

False

According to the behavior of integer division, when an integer is divided by an integer, the result will be a float.

False

All programs are normally stored in ROM and are loaded into RAM as needed for processing.

False

If you print a variable that has not been assigned a value, the number 0 will be displayed.

False

In Python, an infinite loop usually occurs when the computer accesses an incorrect memory address.

False

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

False

Python formats all floating-point numbers to two decimal places when outputting with the print statement.

False

Single alternative control structure tests a condition and then takes one path if the condition is true, or another path if the condition is false.

False

Strings can be compared using all relational operators except '!=' operator.

False

The not operator is a unary operator which must be used in a compound expression.

False

To calculate the total number of iterations of a nested loop, add the number of iterations of all the loops.

False

Unlike other languages, in Python the number of values a function can return is limited to one.

False

Variable name can contain spaces but are case sensitive.

False

What is the result of the following Boolean expression, given that x = 5, y = 3, and z = 8? not (x < y or z > x) and y < z

False

When will the following loop terminate? while keep_on_going != 999:

When keep_on_going refers to a value equal to 999

Which of the following functions returns the largest integer that is less than or equal to its argument?

floor

What would the following display? Print('george', 'john', 'paul', sep= '@')

george@john@paul

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

number = random.randint(1, 50)

Which logical operators perform short-circuit evaluation?

or, and

Which of the following will display 20%

print(format(0.2, '0%')) <enter>

Suppose the following statement is in a program: quantity = 17 % 3. After this statement executes, the quantity variable will reference a value of this data type.

Int

In a value-returning function, the value of the expression that follows the keyword __________ will be sent back to the part of the program that called the function.

Return

A value-returning function is like a simple function except that when it finishes it returns a value back to the part of the program that called it.

True

Both of the following for clauses would generate the same number of loop iterations. for num in range(9): for num in range(1,10):

True

Computer programs typically perform three steps: input is received, some process is performed on the input, and output is produced.

True

Decision structures are also known as selection structures.

True

In Python, print statements written on separate lines do not necessarily output on separate lines.

True

In python, you would use the for statement to write a count-controlled loop.

True

Nested decision statements are one way to test more than one condition.

True

The formatting specifier is a special set of characters that specify how a value should be formatted

True

The randrange function returns a randomly selected value from a specific sequence of numbers.

True

To assign a value to a global variable in a function, the global variable must be first declared in the function.

True

What is the result of the following Boolean expression, given that a = 2, b = 4, and c = 6? 1 != b and c != 3

True

A Boolean variable can reference one of two values which are

True of False

What type of loop structure repeats the code based on the value of Boolean expression?

condition-controlled loop

What will be displayed after the following code is executed? count = 4 while count < 12: print("counting") count = count + 2

counting counting counting counting

Python uses ____________ to categorize values in memory.

data types

In a print statement, you can set the ____________ argument to a space or empty string to stop the output from advancing to a new line.

end

Write an if-else statement that displays 'Cold Outside' if the temp is within the rage of 30 to 50 F. If temp value is outside this range display 'Not cold Outside'.

if temp >= 30 and temp <= 50: print ('Cold Outside.') else: print ('Not cold Outside.')

Write an if-else statement that assigns 0 to the variable y if the variable x is less than 10. Otherwise it should assign 99 to the variable y.

if x < 10: y = 0 else: y = 99

Write an if clause to determine whether x is anything other than 10

if x!= 10

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

if y >= 10 and y <= 50:

Which of the following statements causes the interpreter to load the contents of the random module into memory?

import random

To use Python's turtle graphics, you must include which of the following statements in y our program?

import turtle

The __________ function reads a piece of data that has been entered at the keyboard and returns that piece of data, as a string, back to the program.

input()

The _________ operator takes a Boolean expression as its operand and reverses its logical value.

not

What would the following display? num = 99 num = 5 print ('num')

num


Conjuntos de estudio relacionados

Chapter 9 - Flexible Budgets and Performance Analysis Assignment

View Set

Chapter 23: Nursing Management: Patients With Gastric and Duodenal Disorders PrepU

View Set

CCNA Security v2.0 Final Answers - Implementing Network Security

View Set

Chapter 19: Trauma & Stressor-Related Disorders

View Set

Life policy Provisions, Riders and Options

View Set

6th Grade Language Arts 2nd Semester

View Set

NSCI 175: Brain Rhythms and Sleep

View Set