skip to Main Content

New beginner here for python and ı have sense of basics of python. I was trying to learn OOP details by following a tutorial then ı realized when ı run my code on VScode. It doesn’t give me anything back. I just gives me back the filepath. I am not sure what to do. I tried adding print to see if anything comes out but nope!

class Item:
    pay_rate = 0.8
    def __init__(self, name: str, price: float, quantity=0):
        assert price >= 0, f"Price {price} should be greater or equal to zero!"
        assert quantity >= 0, f"Quantity {quantity} should be greater or equal to zero!"


        self.name = name
        self.price = price
        self.quantity = quantity

    def calculate_total_price(self):
        return self.price * self.quantity

    def apply_discount(self):
        self.price = self.price * self.pay_rate

    
item1 = Item("Phone", 100, 1)
item2 = Item("Laptop", 1000, 3)
item3 = Item("Cable", 10, 5)
item4 = Item("Mouse", 50, 5)
item5 = Item("Keyboard", 75, 5)

enter image description here

Well that is how it looks

2

Answers


  1. Chosen as BEST ANSWER

    Figured it out guys! It is an interpreter issiue!


  2. It means that the program is not outputting anything to the console because you run the your code and see only the file path so you should double check the code for any errors and other methods to display the results

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search