Skip to content

Latest commit

 

History

History

0x0B-python-input_output

Python - Input/Output

In this project, I practiced file handling in Python. I used the builtin with, open, and read functions with the json module to read and write files and serialize and deserialize objects with JSON.

Files

Filename Description
0-read_file.py Function that reads a text file and prints it to stdout
1-write_file.py Function that writes a string to a text file and returns the number of characters written
2-append_write.py Function that appends a string at the end of a text file and returns the number of characters added
3-to_json_string.py Function that returns the JSON representation of an object (string)
4-from_json_string.py Function that returns an object represented by a JSON string
5-save_to_json_file.py Function that writes an Object to a text file, using a JSON representation
6-load_from_json_file.py Function that creates an Object from a “JSON file”
7-add_item.py Script that adds all arguments to a Python list, and then save them to a file
8-class_to_json.py Function that returns the dictionary description with simple data structure for JSON serialization of an object
9-student.py Class Student that defines a student by its first_name, last_name and age
10-student.py Class Student that defines a student with a method to retrieve a JSON representation
11-student.py Class Student that defines a student with a method to load a JSON object
12-pascal_triangle.py Function that returns a list of lists of integers representing the Pascal's triangle of n
100-append_after.py Function that inserts a line of text to a file, after each line containing a specific string
101-stats.py Function that reads stdin line by line and computes metrics

Technologies

  • Python Scripts are written with Python 3.4.3
  • Tested on Ubuntu 14.04 LTS