Refer to the following code and answer the questions on the right: 1 class Product: 2 store_name = "ProtoTop" 1. Which of the following can be used to change the stock attribute of hopia? 3 O hopia.add_supplies(20) O hopia.sell(20) O Product.add_supplies(hopia, 20) O Product.selI(hopia, 20) O hopia.stock += 20 4 def _init_(self, name, category, price, stock, weight_in_grams): self.name = name self.description = self.category = category 8 self.price = price self.stock = stock 10 self.weight_in_grams = weight_in_grams 2. What will be the output by the print function below: 11 def change_name(self, new_name): self.name = new_name hopia.change_description(f"{hopia.name} is a {hopia.category} product that weighs {hopia.weight_in_grams} grams print(hopia.description) 12 13 14 15 def change_description(self, new_description): Answer: 16 self.description = new_description 17 18 def change_category(self, new_category): 19 self.category = new_category After the last line, let us add the following assignment statement hopia.store_name = "FreshTop" 3. 20 21 def change_weight(self, new_weight_in_grams): print(hopia.store_name) 22 self.weight_in_grams = new_weight_in_grams 23 We have directly accessed and changed the value of the store_name attribute of hopia. This means that what we are printing is now an instance attribute and not a class attribute. def add_supplies(self, stocks_added): self.stock += stocks_added 24 25 O True 26 O False def sell(self, stocks_sold): if self.stock > stocks_sold: self.stock -- stocks_sold 27 28 29 30 else: 31 print(f"Not enough stocks of {self.name} for selling.") 32 33 hopia = Product("Hopia", "food", 4, 100, 20)
SQL
SQL stands for Structured Query Language, is a form of communication that uses queries structured in a specific format to store, manage & retrieve data from a relational database.
Queries
A query is a type of computer programming language that is used to retrieve data from a database. Databases are useful in a variety of ways. They enable the retrieval of records or parts of records, as well as the performance of various calculations prior to displaying the results. A search query is one type of query that many people perform several times per day. A search query is executed every time you use a search engine to find something. When you press the Enter key, the keywords are sent to the search engine, where they are processed by an algorithm that retrieves related results from the search index. Your query's results are displayed on a search engine results page, or SER.
Using PYTHON,
Step by step
Solved in 4 steps with 3 images