Question
Given the following Python-like code snippet:Â
  ```python   class Counter:     def __init__(self):       self.count = 0     def increment(self):       self.count += 1     def get_count(self):       return self.count   c1 = Counter()   c2 = Counter()   c1.increment()   c1.increment()   c2.increment()   print(c1.get_count() + c2.get_count())   ```   What will be the output?Solution
Dry Run: Â Â Â Â Â Â `c1 = Counter()` -> `c1.count = 0` Â Â Â Â Â Â `c2 = Counter()` -> `c2.count = 0` Â Â Â Â Â Â `c1.increment()` -> `c1.count = 1` Â Â Â Â Â Â `c1.increment()` -> `c1.count = 2` Â Â Â Â Â Â `c2.increment()` -> `c2.count = 1` Â Â Â Â Â Â `print(c1.get_count() + c2.get_count())` -> `print(2 + 1)` -> `3`
The average weight of 28 students in a class is 40 kg while the average weight of 5 teachers who teach them is 58 kg. 10 students and 1 teacher go for a...
The average weight of 8 students in a class is 35 kg. If the weight of 4 teachers is also included, then the new average weight of each person (teacher ...
The average score of 28 players in a team is 73. After two new players with scores (x + 8) and (x - 6) joined, the average score decreased by 2 points. ...
In a warehouse, there are 200 washing machines and 300 microwaves. The average price of a washing machine is Rs. 15,000 while the average price of a mic...
- The average age of a group of employees is 45 years. When a new employee aged 60 joins, the average increases by 1 year. Find the total age of the group be...
A box contains 16 packets of rice with an average weight of 2.5 kg. If x new packets are added with an average weight of 3.2 kg, the new average becomes...
Each question contains a statement followed by Quantity I and II. Read the information clearly and answer your questions accordingly.Â
Quanti...
The average of a set of 's' numbers is 45. If 180 is added to the set, then the average of the set becomes 45.2. Find the value of '4 X (s - 18)'.
- In a community park, the ratio of the number of benches, swings, and slides is 4:3:2, respectively, and the average number of these items is 60. What is th...
If average of first 5 numbers is (n – 46) and the sum of remaining number is 1850. Find the value of ‘n’, if the average of 20 numbers is ‘n’....