IS 240 Midterm

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

* a + 7 / (x - y) + (n * 3)

(x - y)

Determine the value of the expression: "Python".upper().find("tho")

-1

Integer division is accomplished using the ____________ operator.

//

Determine the value of the expression: "Python".find("Pyt")

0

Determine the value of the expression: "all clear".title().count('a')

1

Determine the output: x=1while x<5:print(x)x+=1

1 2 3 4

Determine the following output: total=0num=1while num<5:total+=numnum+=1print(total)

10

Given str1 = "Life, the universe and everything." what does str1.find("ve") return?

13

What will the following line of Python display? print (round(22.5))

22

Determine the value of the expression: "whippersnapper".find("pp")

3

Determine the value of the expression: len("brrr")

4

Determine the value of the expression: "Mississippi".rfind("ss")

5

Determine the output displayed. **Assume the response to the input is a isvowel=Falseletter=input("Enter a letter: ")letter=letter.upper()if (letter in "AEIOU"):isvowel=Trueif isvowel:print(letter, "is a vowel.")elif (not(65<=ord(letter)<=90)):print("You did not enter a letter.")else:print(letter, "is not a vowel.")

A is a vowel.

Determine the output displayed: if "":print("An empty string is true.")else:print ("An empty string is false.")

An empty string is false.

Determine the value of the expression: "brrr".upper

BRRR

Determine the output displayed. **Assume the response to the input is 6 if length<1:cost=3.00 #cost in dollarselse:cost=3.00+((length-1)*2.50)result="Cost of cloth is ${0:0.2f}.".format(cost)print (result)

Cost of cloth is $15.50.

Determine the output: age=12gender="m"while age>=12 and gender=="f":print ("Abc")print("Def")

Def

An assignment statement evaluates the expression on the left side of the = and then assigns its value to the variable on the right.

False

Assuming the value of a is 2 and the value of b is 3, then state whether this statement evaluates to True or False: ((5-a)*b)<7

False

Assuming the value of a is 2 and the value of b is 3, then state whether this statement evaluates to True or False: a**b=b**a

False

Chained methods are executed from right to left.

False

Continue statements cannot be used with if-statements.

False

Determine whether the condition evaluates to True or False

False

Determine whether the condition evaluates to True or False (7<34) and ("7"<"34")

False

Determine whether the condition evaluates to True or False True and False

False

In the program development cycle, the first step in writing instructions to carry out a task is to determine how to process the input to obtain the desired output.

False

Numeric expressions may not contain variables.

False

Python does not allow for out of bounds indexing for slices.

False

Strings in a text file may be formatted with bold, italics, and color.

False

When an empty string, list, or tuple is used as a condition, what does it evaluate to?

False

isinstance("5", int)

False

Determine the result: q=1while q>0:q=3*q-1print(q)

Infinite loop

Determine the value of the expression: "king lear".title()

King Lear

In Python, the term ____________ refers to any instance of a data type.

Object

Each execution of the body of a loop is called a(n) ____________.

Pass

Determine the value of the expression: "Python"[-10:10]

Python

Determine the output displayed: gpa=3.49result=""if gpa>=3.5:result="Honors"print(result + "Student")

Student

Determine the following output a=10b=10if a = b:print("same")

Syntax Error

A variable must be created with assignment statement before it can be used in an expression.

True

Assuming the value of a is 2 and the value of b is 3, then state whether this statement evaluates to True or False: (a*a<b) or not(a*a<a)

True

Break statements usually appear in the bodies of if-statements

True

De Morgan's law can be applied from left to right or from right to left.

True

Determine whether the condition evaluates to True or False isinstance(32,int)

True

Determine whether the condition evaluates to True or False not False

True

Every object in Python has a truth value associated with it.

True

Flowcharts are time-consuming to write and difficult to update.

True

Given x = 5, y = 7 and z = "kitten" what does the following condition evaluate to?

True

In order for two tuples to be equal, they must have the same length and corresponding items must have the same value.

True

Lists are mutable.

True

Pseudocode is typically more compact than a flowchart.

True

Python requires all programs be saved as a file on a storage device before they can be executed.

True

The function range(0, n) can be abbreviated to range(n).

True

The main benefit of hierarchy charts is in the initial planning phase of a program.

True

The result of a multiplication is a float if either of the numbers is a float.

True

The word disk is often used to refer to any storage device.

True

The words "if" and "else" are reserved words.

True

When numbers are used as conditions, 0 evaluates to False.

True

Which variable name is invalid?

a. X-ray

The statement a /= 5 is an example of a(n) ____________.

a. augmented assignment

After the del function or remove method are executed on a list, the items following the eliminated item are ____________.

a. moved one position left in the list

A good reason to include documentation in your program is ____________.

all of the above

Hierarchy charts are also called

all of the above

In Python, variable names may consist of ____________.

all of the above

In the split method, if no separator is specified, the default is ____________.

any whitespace character

A statement of the form variableName = numericExpression is called a(n) ____________.

assignment statement

In Python, variable names may begin with ____________.

both a & b

The ____________ statement causes an exit from anywhere in the body of a loop.

break

An error is a program is called a(n) _______________.

bug

A syntax error is caught

by the interpreter

Writing Python statements is called _______________.

coding

Conditions that use the logical operators are called ____________ conditions.

compound

Combining two strings to form a new string is called ____________.

concatenation

The ____________ statement causes the current iteration of the body of a loop to terminate and execution returns to the loop's header.

continue

In a flowchart, the representation of instructions that require a "yes" or "no" answer is called a(n) _______________.

decision structure

Using different inputs and outputs on a flowchart to test an algorithm is called _______________.

desk checking

In Python, string literals are surrounded by

either a or b

In a while loop, the line beginning with while is called a(n) ____________.

header

Which programming tool is used to show how the different parts of a program relate to each other?

hierarchy chart

Objects that cannot be changed in place are called ____________.

immutable

What function prompts a user to enter data?

input

Using a while loop to ensure a proper response is received from a request is called ____________.

input validation

Which method converts a list of strings into a string value consisting of the elements of the list concatenated together?

join

For readability purposes, you should not chain ____________ methods together.

more than three

Determine the value of the expression: "Python"[5]

n

The escape sequence for the newline character is ____________.

n

When one loop is contained in the body of another loop, it is said to be ____________.

nested

Determine the value of the expression: "Python"[-2]

o

The ____________ statement is a do-nothing statement.

pass

Determine the output displayed: number=5if number<0:print("negative")else:if number==0: print("zero")else: print("positive")

positive

Which programming tool uses English-like phrases with some Python terms to outline the task?

pseudocode

When Python stops evaluating a compound condition with the logical and operator because a condition evaluates to False, it is called ____________evaluation.

short-circuit

A sequence of consecutive characters from a string is called a(n) ____________.

slice

Instructions in a Python program are called _______________.

source code

Comments are useful for

specifying the intent of the program

Which method turns a single string into a list of substrings?

split

Which function converts a number to its string representation?

str

When comparing two lists of different lengths, if all items pairs match up to the end of the shorter sequence, which sequence is said to be the lesser of the two?

the shorter sequence

Determine the value of the expression: "Python"[2:]

thon

A _______________ is any person who runs a program.

user

What Python loop repeatedly executes a block of statements as long as a certain condition is met?

while


Kaugnay na mga set ng pag-aaral

LearningCurve Module 19. The Nonvisual Senses

View Set

Persian Wars, Athens/Sparta, and Golden Age

View Set

NCCER Core Curriculum , Module 5 Blueprints

View Set

Microeconomics Elasticity and Its Application

View Set

Psych 405: Ch. 16 Disorders Common Among Children and Adolescents

View Set

NUR 113 Coordinating & Managing Care Prep-U

View Set

Inb Bus Mid Ch. 3, I.B. test 2, INTB CH 14 (MC), international business chapter 7, International Finance 7&8 Q101-150

View Set

Comm 1301 ch 12 media and politics review

View Set