file i o exception assertion
play

File I/O, Exception, Assertion COL 100 - Introduction to Computer - PowerPoint PPT Presentation

File I/O, Exception, Assertion COL 100 - Introduction to Computer Science Department of Computer Science and Engineering Indian Institute of Technology Delhi Reading and Writing Files It is a common task to read some input data file


  1. File I/O, Exception, Assertion COL 100 - Introduction to Computer Science Department of Computer Science and Engineering Indian Institute of Technology Delhi

  2. Reading and Writing Files It is a common task to • read some input data file • do some calculation/filtering/processing with the data • write some output data file with results Python distinguishes between • text files ('t') • binary files 'b') If we don’t specify the file type, Python assumes we mean text files.

  3. Reading and Writing Files Writing a text file https://www.southampton.ac.uk/~fangohr/training/python/pdfs/Python-for-Computational-Science-and-Engineering.pdf

  4. Reading and Writing Files Writing a text file https://www.southampton.ac.uk/~fangohr/training/python/pdfs/Python-for-Computational-Science-and-Engineering.pdf

  5. Reading and Writing Files Reading a text file https://www.southampton.ac.uk/~fangohr/training/python/pdfs/Python-for-Computational-Science-and-Engineering.pdf

  6. Reading and Writing Files Reading a text file https://www.southampton.ac.uk/~fangohr/training/python/pdfs/Python-for-Computational-Science-and-Engineering.pdf

  7. Reading and Writing Files Exercise https://www.southampton.ac.uk/~fangohr/training/python/pdfs/Python-for-Computational-Science-and-Engineering.pdf

  8. Reading and Writing Files Exercise https://www.southampton.ac.uk/~fangohr/training/python/pdfs/Python-for-Computational-Science-and-Engineering.pdf

  9. Source:https://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-0001-introduction-to-computer-science-and- programming-in-python-fall-2016/lecture-slides-code/

  10. Source:https://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-0001-introduction-to-computer-science-and- programming-in-python-fall-2016/lecture-slides-code/

  11. Source:https://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-0001-introduction-to-computer-science-and- programming-in-python-fall-2016/lecture-slides-code/

  12. Source:https://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-0001-introduction-to-computer-science-and- programming-in-python-fall-2016/lecture-slides-code/

  13. Source:https://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-0001-introduction-to-computer-science-and- programming-in-python-fall-2016/lecture-slides-code/

  14. Source:https://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-0001-introduction-to-computer-science-and- programming-in-python-fall-2016/lecture-slides-code/

  15. Source:https://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-0001-introduction-to-computer-science-and- programming-in-python-fall-2016/lecture-slides-code/

  16. Exceptions

  17. Exceptions

  18. Assertion • Want to be sure that assumptions on state of computation are as expected • use an assert statement to raise an exception • an example of good defensive programming

  19. Assertion Source:https://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-0001-introduction-to-computer-science-and- programming-in-python-fall-2016/lecture-slides-code/

  20. Assertion Source:https://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-0001-introduction-to-computer-science-and- programming-in-python-fall-2016/lecture-slides-code/

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend