exam 2 IS210

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

In Python the __________ symbol is used as the not-equal-to operator.

!=

sum = 0 x = 10 y = 5 z = 9 if ( x + y < z ): sum = x + y + z if (x - y < z ): sum = x - y - z if ( x + y == z ): sum = x + y - z

-4

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

Hours = 6 // 4 print (hours)

1

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

Condition-controlled loop

What type of loop structure repeats the code a specific number of times?

Count-controlled loop

Hours = 6 % 4 print (hours)

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

sum = 0 x= 9 y = 13 if (x < y): sum = x + y elif ( x == y ): sum = 2 * x - y elif (x > y ): sum = y - x

22

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

30

x = 2 y =12 if ( x + 3 * 4 > y): x = x ** 2 else: x = x ** 3

4

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

6

x = 9 if (x >= 10) : x = x + 1 else: x = x - 1

8

total = 0 for count in range(4, 6): total += count print(total)

9

In Python the __________ symbol is used as the equality operator.

==

A variable used to keep a running total is called a(n) .

Accumulator

if ( choice == 1): print("You have selected addition operator") elif ( choice == 2 ) : print("You have selected subtraction Operator") elif ( choice == 3 ) : print("You have selected Multiplication Operator") elif ( choice == 4 ) : print("You have selected Division Operator") elif ( choice == 5 ) : print("You have selected Exponentiation Operator") else : print("Invalid Selection")

Multiway Selection Control structure

__________________ are operators which compare two data. They are used to construct Boolean expressions where two pieces of data are compared to each other

Relational operators ( Comparison Operators)

Multiple Boolean expressions can be combined by using a logical operator to create __________ expressions.

compound

iterates a specific number of times

counter-controlled loop

Updating a variable by adding 1 is called an ______________. Subtracting 1 from a variable is called ______________.

increment; decrement

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

False

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

True

A Boolean variable can reference one of two values which are

True or False

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

When keep_on_going refers to a value not equal to 999

When using the __________ logical operator, both subexpressions must be true for the compound expression to be true.

and

the _______ logical operator is binary operator which combines two Boolean expressions. Both of the Boolean expressions should be evaluated to True so that the overall result is True.

and

the _____________ statement us used to jump out if the loop

break

x = 8 if ( x == 8 ) : print("Hello World") if ( x != 8 ) : print("My Name is UAH") print("Good bye")

converting a dual-alternative selection control structure to single alternative

x = 8 if ( x == 8 ) : print("Hello World") else : print("My Name is UAH") print("Good bye")

dual-alternative selection control structure

The _________ ______________ is an example of an iteration control structure found in the Python programming language. It is used for counter-based loops only.

for statement

Which of the following is correct if the clause is to determine whether choice is anything other than 10?

if choice != 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:

are operators which combines two or more relational operators. There are used to construct Boolean expressions

logical operators

the _______ logical operator is unary operator which negates the condition. If the Boolean expression is true, it negates to become false.

not

When using the __________ logical operator, one or both of the subexpressions must be true for the compound expression to be true.

or

the ______ logical operator is binary operator which it combines two Boolean expressions. One of the two Boolean expressions should be evaluated to True so that the overall result is True.

or

returns an iterable object

range

A(n) __________ structure is a structure that causes a statement or a set of statements to execute repeatedly.

repetition

special value that marks the end of a sequence of items

sentinal

x = 8 if ( x == 8 ): print("Hello world") print("Good bye")

single alternative selection control structure

//, divides two numbers and rounds down to an integer

the floor integer.

_______________ _____________ is the process in which the new value of the variable depends on the old value.

updating variables

What does the expression x <= y mean?

x is less than or equal to y


Set pelajaran terkait

Women and Gender Studies Final Study Guide

View Set

Chapter 6: Cost-Volume-Profit Relationship

View Set

History Chapter 3 - Early Humans

View Set

Human Physiology Chapter 3 Part 1

View Set

Direct and Representative Democracy

View Set

Algebra I Fundamentals : Factoring Trinomials (1)

View Set

Organizational Management Chapter 9

View Set

Financial Algebra Vocab 5-5 and 5-6

View Set

Chapter 23, Section 1 World History

View Set