@dataclass

PHOTO EMBED

Tue Mar 08 2022 14:33:49 GMT+0000 (Coordinated Universal Time)

Saved by @armin10020 #python

from dataclasses import dataclass

@dataclass
class Book_list:
	name: str
	perunit_cost: float
	quantity_available: int = 0
		
	# function to calculate total cost	
	def total_cost(self) -> float:
		return self.perunit_cost * self.quantity_available
	
book = Book_list("Introduction to programming.", 300, 3)
x = book.total_cost()

# print the total cost
# of the book
print(x)

# print book details
print(book)

# 900
Book_list(name='Python programming.',
		perunit_cost=200,
		quantity_available=3)
content_copyCOPY

what it does?

https://www.geeksforgeeks.org/g-fact-41-multiple-return-values-in-python/