0

pay_rate is a class variable of class Item, I want to keep the value of this variable always as Integer.If I tries to change the value of this variable outside the class using the class name like Item.pay_rate="AABB". Here I set a string value for this variable. I want that python interpreter will gonna show me a warning that you are setting a string value instead of an integer value.

class Item:
    pay_rate:int=8 # It is a class variable, I want to keep the value of this variable always as Integer.If I tries to change the value of this variable outside the class using the class name like Item.pay_rate="AABB". Here I set a string value for this variable. I want that python interpretor will gonna show me a warning that you are setting a string value instead of an integer value.
Item.pay_rate="AABB" # Integer value is excepted. You are setting a string value instead of integer value. I want my python interpreter to show me this kind of warning.
#Second Doubt
class Test:
    salary:float # What is the meaning of this line(salary:float) to python interpreter. Is this a class variable? Please clear my confusion.

Thanks

0 Answers0