Purpose: This study aimed to explore the relationship between mathematic achievement and programming self-efficacy, and adopt a mediation model to verify the mediating role of creativity on the relationship between mathematic achievement and programming self-efficacy.Methods: A total of 950 upper-secondary school students were surveyed using their math test scores, the Kirton Adaption-Innovation and the Programmed Self-Efficacy Scale. SPSS-26 was used for descriptive statistical analysis and correlation analysis of related variables. The PROCESS plugin was used to test the mediating effect of creativity.Results: (1) Mathematic achievement has a positive effect on programming self-efficacy, mathematic achievement is positively related to creativity, and creativity also has a positive influence on programming self-efficacy. (2) Creativity has a mediating effect on the relationship between mathematic achievement and programming self-efficacy.Conclusion: The results revealed that mathematic achievement affected programming self-efficacy directly and also indirectly through creativity. This provided certain ideas for the development of programming education for teenagers. Since students’ mathematics learning and creativity are related to programming learning, it is necessary to pay attention to the integration of the disciplines of programming education and mathematics. Further, the cultivation of innovative thinking is also critical to facilitate programming learning.