Exam 5: Bigger Data: File Io: the While Loop, String Formatting, Reading Online Data in CSV and Json Formats
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
Using JSON, data is formatted most like which Python collection?
(Multiple Choice)
4.9/5
(38)
The data embedded in a file that describes the data is called:
(Multiple Choice)
4.8/5
(35)
The string format method is used to create formatted strings in Python.
(True/False)
4.8/5
(36)
1. Match each of the descriptions with the appropriate formatting option for strings.
-Put the value in a field 20 characters wide with two characters to the right of the decimal point.
(Multiple Choice)
4.8/5
(28)
Explain the while loop mechanism and provide the syntax, or template, of the structure.
(Essay)
4.9/5
(39)
Once a file has been opened, it becomes a Python object just like all other data.
(True/False)
4.9/5
(31)
1. Match each of the descriptions with the appropriate formatting option for strings.
-Put the value in a field 20 characters wide, left-justified.
(Multiple Choice)
4.7/5
(39)
Explain how the following session, which creates a list of cubes, could be re-written as a single step using list comprehensions.
>>> cubes = []
>>> for x in range(1, 11):
cubes.append(x * x * x)
>>> cubes
[1, 8, 27, 64, 125, 216, 343, 512, 729, 1000]
(Essay)
4.8/5
(42)
Case Study 2:
>>> with open("rainfall.txt", "r") as inFile:
aLine = inFile.readline()
>>> aLine
'Akron 25.81\n'
>>> with open("rainfall.txt", "r") as inFile:
lineList = inFile.readlines()
>>> lineList
['Akron 25.81\n', 'Albia 37.65\n', 'Algona 30.69\n', 'Allison 33.64\n','Alton 27.43\n', 'AmesW 34.07\n', 'AmesSE 33.95\n', 'Anamosa 35.33\n','Ankeny 33.38\n', 'Atlantic 34.77\n', 'Audubon 33.41\n','Beaconsfield 35.27\n', 'Bedford 36.35\n', 'BellePlaine 35.81\n','Bellevue 34.35\n', 'Blockton 36.28\n', 'Bloomfield 38.02\n',
'Boone 36.30\n', 'Brighton 33.59\n', 'Britt 31.54\n', 'Buckeye 33.66\n','BurlingtonKBUR 37.94\n', 'Burlington 36.94\n','Carroll 33.33\n', 'Cascade 33.48\n']
>>> with open("rainfall.txt", "r") as inFile:
fileString = inFile.read()
>>> fileString
'Akron 25.81\nAlbia 37.65\nAlgona 30.69\nAllison 33.64\nAlton
27.43\nAmesW 34.07\nAmesSE 33.95\nAnamosa 35.33\nAnkeny 33.38\n
Atlantic 34.77\nAudubon 33.41\nBeaconsfield 35.27\nBedford 36.35\nBellePlaine 35.81\nBellevue 34.35\nBlockton 36.28\nBloomfield 38.02\nBoone 36.30\nBrighton 33.59\nBritt 31.54\nBuckeye 33.66\nBurlingtonKBUR 37.94\nBurlington 36.94\nCarroll 33.33\nCascade 33.48\n'
>>>
-Refer to the session in the accompanying Case Study 2 and describe the function of the readline() method.
(Essay)
4.9/5
(43)
Case Study 1:
1. >>> item = 'A dozen eggs'
2. >>> itemPrice = 2.4
3. >>> print("{0} costs ${1:.2f}".format(item, itemPrice))
4. ???
5. >>> myDict = {'name':'candy bar', 'price':95}
6. >>> print("The {name} costs {price} cents".format(**myDict))
7. ???
-Refer to the session in the accompanying Case Study 1. What is printed on line 4?
(Multiple Choice)
4.9/5
(35)
Showing 21 - 33 of 33
Filters
- Essay(0)
- Multiple Choice(0)
- Short Answer(0)
- True False(0)
- Matching(0)