IDLE
.
file = open('book.txt', 'r') line_count = 0 for line in file: line_count += 1 if line_count % 6 == 1: title = line.strip() elif line_count % 6 == 2: sub_title = line.strip() elif line_count % 6 == 3: author = line.strip() elif line_count % 6 == 4: publisher = line.strip() elif line_count % 6 == 5: copyright = line.strip() elif line_count % 6 == 0: description = line.strip() b1 = Book(title, sub_title, author, publisher, copyright) print('Title:', b1.get_title()) print('Sub_title:', b1.get_sub_title()) print('Author:', b1.get_author()) print('Publisher:', b1.get_publisher()) print('Copyright:', b1.get_copyright()) b1.set_description(description) print('Description:', b1.get_description()) print(b1)
Title: Guns, Germs, and Steel Sub_title: The Fates of Human Societies Author: Jared Diamond Publisher: Norton Copyright: 1997 Description: How the accident of geography influences the development of technology Guns, Germs, and Steel: The Fates of Human Societies, Jared Diamond, Norton (1997)
pass
statement. b1 = Book(title, sub_title, author, publisher, copyright)Add assignment statements for each of the attributes.
Title: Guns, Germs, and Steel Sub_title: The Fates of Human Societies Author: Jared Diamond Publisher: Norton Copyright: 1997 Description: How the accident of geography influences the development of technology Guns, Germs, and Steel: The Fates of Human Societies, Jared Diamond, Norton (1997)
cd it117/hw/hw9
python3 hw9.py
Title: Guns, Germs, and Steel Sub_title: The Fates of Human Societies Author: Jared Diamond Publisher: Norton Copyright: 1997 Description: How the accident of geography influences the development of technology Guns, Germs, and Steel: The Fates of Human Societies, Jared Diamond, Norton (1997)
Copyright © 2022 Glenn Hoffman. All rights reserved. May not be reproduced without permission.