In this paper, we propose a framework for the design of learning activities, which follows the key idea of the “Learning-for-Use” model and adopts characteristics from the exploratory and collaborative learning. We elaborated on the framework in the design of learning activities for Introductory Programming courses and we developed and evaluated in a real classroom environment, learning activities for the teaching of the infinite “while” loop. The experimental results are encouraging for the effectiveness of the activities in enhancing learning and indicate that the framework enables the students to gain deeper understanding of the programming constructs under consideration and to apply them more effectively.