Basics of a Dictionary

Basics of a Dictionary

Lesson Details:
June 29, 2020


I: Introduction

A: Here, the writer gives the introduction about what you are going to write.

II: Body

A: This is the main part of article. You can discuss the basics with dictionary.

III: Conclusion

Here you can discuss what you have done in this article and how it helped you.

So, we discussed the basic structure for your article and how to write a python article.

Step by Step Guide to Write a Python Program:

Now we will see the steps to write a python program. These steps will help you while writing a python program to make every task simple and easy.

But, before moving ahead make sure that you have already installed python on your system. For detailed guide on how to install python on different operating systems, check this link.

Step 1: Setup Environment

First of all, we need to create an environment for our work. So, we need to create a project folder and inside that folder we will create another folder for our software and inside that folder we need to create another folder for source files and another one for build files.

Building an environment for programming is considered as a best practice and every developer should follow the same to organize their work and maintain it easily.

Step 2: Create a file and name it hello_world.py

Here, we will create a python source file named hello_world.py and for this, we will use any text editor like notepad++ or sublime text or visual studio code etc. And, in that file we will write a code that will say hello world when we run that file in command line or terminal. This code looks like below:

hello_world.py # Prints Hello World in Python print( "Hello World" ) 1 2 3 # Prints Hello World in Python print ( "Hello World" )

Step 3: Compile the file hello_world.py into byte code using Python compiler Pyc

After writing the code in source file change its name from hello_world.py to hello_world.pyc by right clicking on it and selecting rename option. The reason behind this is that, python compiler need byte code file with .pyc extension to compile the source file into byte code hence renaming the file from .py to .pyc.

Next step is compiling the source file into byte code using PYC compiler available in python installation directory. For windows user, this is in C:Python34Libsite-packagesPyInstaller__main__PyCompilerPyCompiler.exe and for linux user check your python installation directory using which python command in terminal and search for PyCompiler.exe there. It should be available in the same directory where python is installed i.e., /usr/bin/ or /usr/local/bin/. Open command prompt in windows or terminal in linux and type below command which looks like below:

Pyc command pyc source_file_name 1 pyc source_file_name

Thats it! Now your source file has become byte code file which can be executed on different platforms without compilation again and again each time you run your program on different platforms like window or linux or mac os x etc. You can use this source file anywhere without making it again and again each time you run your program on different platforms because it is already compiled byte code file which can be executed on different platforms without compilation again and again each time you run your program on different platforms. We did this because if you run your program on any other platform than windows then the source files run directly without compilation step but on windows, we need to compile the source file into byte code every time we want to run our program which makes our program unreadable by others people who don't know python programming language well. If anyone sees our source files then they won’t understand our program easily but if you compile it into byte code then it will become executable on any platform without compilation hence everyone can understand our program easily even if they don't know python programming language. Also, running the source code on windows machine is slow because after compilation, windows machine will take some time to execute it but when you use compilable byte code then windows machine compiles only once and executes it quickly without taking too much time. Using compilable byte code is very necessary when working with big projects because running big projects in windows machine takes more time compared with compilable byte code hence using compilable byte code saves lot of time while developing software projects. There are two types of compilable byte codes one is byte code created by python compiler PYC which is created by compiling source files with .py extension and second is byte code created by perl compiler PBC which is created by compiling source files with .pl extension so if you want to use compilable byte code then rename your source files from .py to .pyc or .pl if you want to use perl compiler otherwise python compiler will compile your source files into compilable byte code by default when you rename them from .py to .pyc using PYC compiler available in python installation directory. Next step is installing PyInstaller using pip install PyInstaller command in terminal or command prompt in windows or Linux shell in linux because PyInstaller only supports python3 programming language so make sure that you have python3 installed in your system otherwise you can't use it for packaging your application. For more info about installing PyInstaller read this link. After installing PyInstaller make sure that you have added PyInstaller directory in Windows environmental variables path or Linux/Mac environmental variables path otherwise PyInstaller will not work properly i.e., you can't start it using the command line interface (terminal) in windows or Linux shell (terminal) in linux or Mac OS X command prompt (terminal) in Mac OS X even after installing it because if PyInstaller is not added to environmental variables path then how it will find its modules responsible for execution of your programs? So, adding PyInstaller directory in Windows environmental variables path or Linux/Mac environmental variables path is very important thing otherwise PyInstaller won’t work properly i.e., you can't start it using the command line interface (terminal) in windows or Linux shell (terminal) in linux or Mac OS X command prompt (terminal) in Mac OS X even after installing it because if PyInstaller is not added to environmental variables path then how it will find its modules responsible for execution of your programs? So, make sure that you have added PyInstaller directory in Windows environmental variables path or Linux/Mac environmental variables path otherwise PyInstaller will not work properly i.e., you can't start it using the command line interface (terminal) in windows or Linux shell (terminal) in linux or Mac OS X command prompt (terminal) in Mac OS X even after installing it because if PyInstaller is not added to environmental variables path then how it will find its modules responsible for execution of your programs? So, adding PyInstaller directory in Windows environmental variables path or Linux/Mac environmental variables path is very important thing otherwise PyInstaller won’t work properly i.e., you can't start it using the command line interface (terminal) in windows or Linux shell (terminal) in linux or Mac OS X command prompt (terminal) in Mac OS X even after installing it because if PyInstaller is not added to environmental variables path then how it will find its modules responsible for execution of your programs? So, make sure that you have added PyInstaller directory in Windows environmental variables path or Linux/Mac environmental variables path otherwise PyInstaller won’t work properly i.e., you can't start it using the command line interface (terminal) in windows or Linux shell (terminal) in linux or Mac OS X command prompt (terminal) in Mac OS X even after installing it because if PyInstaller is not added to environmental variables path then how it will find its modules responsible for execution of your programs? So, add PyInstaller directory in Windows environmental variables path or Linux/Mac environmental variables path otherwise PyInstaller won’t work properly i.e., you can't start it using the command line interface (terminal) in windows or Linux shell (terminal) in linux or Mac OS X command prompt (terminal) in Mac OS X even after installing it because if PyInstaller is not added to environmental variables path then how it will find its modules responsible for execution of your programs? So, add PyInstaller directory in Windows environmental variables path or Linux/Mac environmental variables path otherwise PyInstaller won’t work properly

loader
Course content