Generating questions is one of the most challenging tasks in the natural language processing discipline. With the significant emergence of electronic educational platforms like elearning systems and the large scalability achieved with elearning, there is an increased urge to generate intelligent and deliberate questions to measure students' understanding. Many works have been done in this field with different techniques; however, most approaches work on extracting questions from text. This research aims to build a model that can conceptualize and generate questions on Python programming language from program codes. Different models are proposed by inserting text and generating questions; however, the challenge is understanding the concepts in the code snippets and linking them to the lessons so that the model can generate relevant and reasonable questions for students. Therefore, the standards applied to measure the results are the code complexity and question validity regarding the questions. The method used to achieve this goal combines the QuestionGenAi framework and ontology based on semantic code conversion. The results produced are questions based on the code snippets provided. The evaluation criteria were code complexity, question validity, and question context. This work has great potential improvement to the e-learning platforms to improve the overall experience for both learners and instructors.