Exam 2: Pthon: Estimating PI: Math and Random Methods, Selection and Boolean Expressions, the Print Function
Exam 1: Introduction to Python: Introduction to Numeric Types, Turtle Graphics, Simple for Loops and Functions34 Questions
Exam 2: Pthon: Estimating PI: Math and Random Methods, Selection and Boolean Expressions, the Print Function33 Questions
Exam 3: Codes and Other Secrets: String Operators and Methods, the Len Built-In Function, Keyword Parameters, User Input33 Questions
Exam 4: Introducing the Python Collections: Lists, Dictionaries, Tuples, and Statistics33 Questions
Exam 5: Bigger Data: File Io: the While Loop, String Formatting, Reading Online Data in CSV and Json Formats33 Questions
Exam 6: Image Processing: Nested for Loops, Functions As Parameters, Namespaces, Lists of Lists33 Questions
Exam 7: Data Mining: Cluster Analysis: More on the While Loop; Parrallel Lists31 Questions
Exam 8: Cryptanalysis: Advanced Dictionaries and Lists, Regular Expressions32 Questions
Exam 9: Fractals: the Geometry of Nature: Recursion, Grammars and Production Rules33 Questions
Exam 10: Astronomy: Creating Classes, Writing Constructors, Accessors, Mutators and Special Methods33 Questions
Exam 11: Simulation:computer Simulation Using Objects34 Questions
Exam 12: Father Was a Rectangle: Inheritance and Object-Oriented Design32 Questions
Exam 13: Video Games: Multithreading, Event Handlers, Static Variables33 Questions
Select questions type
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.
Free
(Essay)
4.8/5
(38)
Correct Answer:
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.
Another name for an if statement is a selection statement.
Free
(True/False)
4.8/5
(38)
Correct Answer:
True
To create a random number in Python, use the ____ function.
Free
(Multiple Choice)
4.8/5
(44)
Correct Answer:
B
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
(Essay)
4.7/5
(36)
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.
(Multiple Choice)
4.8/5
(46)
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?
(Multiple Choice)
4.8/5
(29)
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
(True/False)
4.9/5
(34)
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?
(Multiple Choice)
4.8/5
(31)
1. Match each definition with its term.
-Compares two data values.
(Multiple Choice)
4.8/5
(41)
Explain how to modify the coordinate system of the drawing window when using the turtle module.
(Essay)
4.8/5
(43)
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?
(Multiple Choice)
4.9/5
(40)
The relational operator that means "not equal" is represented with which operator in Python?
(Multiple Choice)
4.9/5
(38)
Explain how a Monte Carlo simulation can be used to calculate the value of pi.
(Essay)
4.7/5
(29)
In order to use the sqrt() function, you must use which of the following Python statements?
(Multiple Choice)
4.9/5
(36)
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"?
(Essay)
4.7/5
(46)
What are some patterns to keep in mind when implementing the Leibniz formula with Python?
(Essay)
4.8/5
(39)
Showing 1 - 20 of 33
Filters
- Essay(0)
- Multiple Choice(0)
- Short Answer(0)
- True False(0)
- Matching(0)