Question
Im having trouble with gettin this code to run in python, can anyone help? def main(): author = input('Enter author: ') title = input('Enter title:
Im having trouble with gettin this code to run in python, can anyone help?
def main(): author = input('Enter author: ') title = input('Enter title: ') num_pages = int(input('Enter number of pages: ')) b = Book(author, title, num_pages) print(' ') b.printAuthor() b.printTitle() b.printNumPages() author = input('Enter updated author name: ') title = input('Enter updated title: ') num_pages = int(input('Enter updated number of pages: ')) b.setAuthor(author) b.setTitle(title) b.setNumPages(num_pages) print(' ') b.printAuthor() b.printTitle() b.printNumPages()
main()
class Book:
pass
def __init__(self, author, title, num_pages): self.author = author self.title = title self.num_pages = num_pages
def setAuthor(self, author): self.author = author
def setTitle(self, title): self.title = title
def setNumPages(self, num_pages): self.num_pages = num_pages
def printAuthor(self): print('Author: ' + self.author)
def printTitle(self): print('Title: ' + self.title)
def printNumPages(self): print('Number of pages: ' + str(self.num_pages)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started