Table of Contents

How to Import Python File Using Python Programming Environment of PictoBlox

Import Python File
Example Description
Importing Python into PictoBlox is an innovative project developed using PictoBlox that demonstrates how external Python files can be imported and executed within a PictoBlox environment. The project focuses on modular programming, where functions and reusable code are stored in separate Python files and integrated into the main program whenever required.

Introduction

PictoBlox allows users to learn the Python Programming Language and develop projects based on Python Programming, with the help of a Python programming Environment. This project demonstrates how external Python files can be imported and used inside other Python files using the PictoBlox software to create modular and reusable programs. 

Step-by-Step Python Coding Guide

Let’s create a script to import a Python file in PictoBlox

  1. Click on Stage.py & declare two variables as:
    Two variables as Name 1 & Name 2

    Name1 = "Hazel" 
    Name2 = "John"
  2. Click on Tobi.py and write down the code below

import Name 1 & Name 2

from Stage import name1, name2

print(name1, '----> as name1 variable')
print(name2, '----> as name2 variable')

Output

  1. While being on Tobi.py, go to the Terminal area.
  2. Click on Run and wait for a few seconds.

Optimized

Conclusion

This project successfully demonstrates how external Python files can be imported and executed in PictoBlox. By using modular programming concepts, the project helps in organising code efficiently, improving readability, and promoting code reusability.