Filters
Question type

Study Flashcards

The relational operator that means "not equal" is represented with which operator in Python?


A) ==
B) !=
C) <=
D) >=

Correct Answer

verifed

verified

In order to use the sqrt() function, you must use which of the following Python statements?


A) use math;
B) import math;
C) math::sqrt() ;
D) return sqrt() ;

Correct Answer

verifed

verified

1. Match each definition with its term. -Contains a question and other groups of statements that may or may not be executed, depending on the result of the question.


A) Boolean values
B) Selection statement
C) Logical operators
D) Relational expressions

Correct Answer

verifed

verified

Explain the difference between the "=" in line 1 and the "==" in line 2 in the code sample below: 1. >>> apple = 25 2. >>> apple == 25 3. True

Correct Answer

verifed

verified

On line 1, the variable apple is assigne...

View Answer

The code in the accompanying case study 2 (see below) is used to calculate a running product. >>> acc = 0 >>> for x in range(1, 6): acc = acc + x >>> acc 15

Correct Answer

verifed

verified

Case Study 3: 1. if <condition>: 2. if <condition>: 3. <statements> 4. else: 5. <statements> 6. else: 7. if <condition>: 8. <statements> 9. else: 10. <statements> -Refer to the code in the accompanying case study. Under what circumstances are the statements on line 10 executed?


A) The condition in line 1 is false, and the condition in line 7 is false.
B) The condition in line 1 is false, and the condition in line 7 is true.
C) The condition in line 1 is true, and the condition in line 7 is false.
D) The condition in line 1 is true, and the condition in line 7 is true.

Correct Answer

verifed

verified

1. Match each definition with its term. -and, or, and not


A) Boolean values
B) Selection statement
C) Logical operators
D) Relational expressions

Correct Answer

verifed

verified

Case Study 1: >>> import math >>> numSides = 8 >>> innerAngleB = 360.0 / numSides >>> halfAngleA = innerAngleB / 2 >>> oneHalfSideS = math.sin(math.radians(halfAngleA) ) >>> sideS = oneHalfSideS * 2 >>> polygonCircumference = numSides * sideS >>> pi = polygonCircumference / 2 >>> pi 3.0614674589207183 -Refer to the session in the accompanying case study 1. How many sides does the polygon in this approximation have?


A) 2
B) 8
C) 64
D) pi

Correct Answer

verifed

verified

Why are decisions referred to as "selection" in computer science?

Correct Answer

verifed

verified

In computer science, decisions are often...

View Answer

What equation relates pi to the circumference of a circle?


A) C = 2πr (where r is the radius of the circle)
B) C = πr (where r is the radius of the circle)
C) C = 2πd (where d is the diameter of the circle)
D) C = 2πa (where a is the area of the circle)

Correct Answer

verifed

verified

Case Study 3: 1. if <condition>: 2. if <condition>: 3. <statements> 4. else: 5. <statements> 6. else: 7. if <condition>: 8. <statements> 9. else: 10. <statements> -Refer to the code in the accompanying Case study 3. Why is this section of code referred to as "nested selection"?

Correct Answer

verifed

verified

The result of this structure is to decid...

View Answer

Explain how a Monte Carlo simulation can be used to calculate the value of pi.

Correct Answer

verifed

verified

Pretend that we are looking at a dartboa...

View Answer

Case Study 2: >>> acc = 0 >>> for x in range(1, 6): acc = acc + x >>> acc 15 -Refer to the session in the accompanying Case Study 2. Explain what pattern this code implements and why it is useful.

Correct Answer

verifed

verified

The code implements a common problem-solving pattern known as the accumulator pattern. This common pattern comes up often. Your ability to recognize the pattern and then implement it will be especially useful as you encounter new problems that need to be solved. As an example, consider the simple problem of computing the sum of the first five integer numbers. Of course, this is quite easy because we can just evaluate the expression 1+2+3+4+5. But what if we wanted to sum the first ten integers? Or perhaps the first hundred? In this case, we would find that the size of the expression would become quite long. To remedy this, we can develop a more general solution that uses iteration.

Which of the following is a constant in the math module?


A) sqrt
B) tan
C) asin
D) e

Correct Answer

verifed

verified

1. Match each definition with its term. -Compares two data values.


A) Boolean values
B) Selection statement
C) Logical operators
D) Relational expressions

Correct Answer

verifed

verified

Case Study 2: >>> acc = 0 >>> for x in range(1, 6) : acc = acc + x >>> acc 15 -Refer to the session in the accompanying case study 2. What type of variable is acc?


A) Accumulator variable
B) Range variable
C) Initialization variable
D) Timer variable

Correct Answer

verifed

verified

Explain how to modify the coordinate system of the drawing window when using the turtle module.

Correct Answer

verifed

verified

To modify the coordinate system of the d...

View Answer

To create a random number in Python, use the ____ function.


A) math.random()
B) random.random()
C) montecarlo.random()
D) help.random()

Correct Answer

verifed

verified

B

Another name for an if statement is a selection statement.

Correct Answer

verifed

verified

True

What are some patterns to keep in mind when implementing the Leibniz formula with Python?

Correct Answer

verifed

verified

All the numerators are 4.
The ...

View Answer

Showing 1 - 20 of 33

Related Exams

Show Answer