Computer Science 1026A/B Study Guide - Final Guide: Init, Class Variable, Bank Code

129 views14 pages
terubarenuka and 39895 others unlocked
COMPSCI 1026A/B Full Course Notes
26
COMPSCI 1026A/B Full Course Notes
Verified Note
26 documents

Document Summary

Process the line. line = infile. readline() line = infile. read() line = infile. read(i) while line != "" : Process the line. line = infile. read (i) line = infile. readlines() for line in infile: Process the line. outfile. write("number of entries: %d\ntotal: %8. 2f\n" % (count, total)) print("total: ", end= ,file=outfile) The finally clause is used when you need to take some action whether or not an exception is raised with open(filename, "w") as outfile : # prompt user for file name data = readfile(filename) # may raise exceptions. The discard() method removes an element if the element exists cast. discard("arthur") cast. remove("the colonel") # could raise an exception cast. clear() # cast now has size 0 issubset() union() intersection() # inboth: the set {"white", "red"} inboth = british. intersection(italian) different() print("colors that are in the italian flag but not the british:") print(italian. difference(british)) # prints {"green"} contacts = { "fred": 7235591, "mary": 3841212, "bob":

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers

Related Documents

Related Questions