Documentation

    Table of Content
    • 3D File Formats
      • 3D File Formats
      • 3D2
      • 3DS
      • 3MF
      • AMF
      • ASE
      • DAE
      • DRC
      • FBX
      • GLB
      • GLTF
      • JRXML
      • JT
      • OBJ
      • PLY
      • PRC
      • RVM
      • STEP
      • U3D
      • VRML
      • X
      • X3D
    • Audio File Formats
      • Audio File Formats
      • AAC
      • FLAC
      • M3U
      • MID
      • MKA
      • MP3
      • OGG
      • RA
      • SDT
      • STAP
      • WAV
    • CAD File Formats
      • CAD File Formats
      • CF2
      • DC3
      • DGN
      • DWF
      • DWFX
      • DWG
      • DWT
      • DXF
      • HPGL
      • IFC
      • IGES
      • IGS
      • JVSG
      • NWC
      • NWD
      • NWF
      • PAT
      • PHJ
      • PLT
      • PSM
      • PSS
      • RVT
      • STL
    • Compression File Formats
      • Compression File Formats
      • 7Z
      • ARC
      • ARJ
      • BZ2
      • DAA
      • GZ
      • RAR
      • TAR
      • ZIM
      • ZIP
    • Database
      • Database File Formats
      • ACCDB
      • ACCDE
      • ACCDT
      • ACCFT
      • BAK
      • BCP
      • DDL
      • DTSX
      • LDF
      • MDB
      • MDF
      • MYI
      • NDF
      • NSF
      • SQL
      • SQLITE
    • EBook File Formats
      • EBook File Formats
      • AZW
      • AZW3
      • EPUB
      • FB2
      • KFX
      • LRF
      • LRS
      • LRX
      • MOBI
      • TR
    • Email File Formats
      • Email File Formats
      • EDB
      • EML
      • EMLX
      • ICS
      • MBOX
      • MSG
      • OFT
      • OST
      • PST
      • TNEF
      • VCF - Virtual Contact File
    • Font
      • Font File Formats
      • CFF
      • CFF2
      • EOT
      • FNT
      • FON
      • JFPROJ
      • OTF
      • PFA
      • PFB
      • PFM
      • SFD
      • TTF
      • WOFF
    • GIS File Formats
      • GIS File Formats
      • E00
      • FileGDB
      • GeoJSON
      • GML
      • GPX
      • KML
      • KMZ
      • OSM
      • SHP
    • Image File Formats
      • Image File Formats
      • AI
      • APNG
      • AVIF
      • BMP
      • BPG
      • CDR
      • CMX
      • CPC
      • DCM
      • DIB
      • DICOM
      • DJVU
      • DNG
      • EMF
      • EMZ
      • EXIF
      • FLIF
      • GIF
      • ICO
      • J2K
      • JFIF
      • JP2
      • JPEG
      • JXR
      • ODG
      • OTG
      • PNG
      • PSB
      • PSD
      • SVGZ
      • TGA
      • TIFF
      • VDX
      • VSD
      • VSDM
      • VSDX
      • VSS
      • VSSM
      • VSSX
      • VST
      • VSTM
      • VSTX
      • VSX
      • VTX
      • WEBP
      • WMF
      • WMZ
    • Note Taking File Formats
      • Note Taking File Formats
      • ONE
      • ONETOC2
    • Page Description Language
      • Page Description Language
      • CGM
      • EPS
      • PCL
      • PS
      • SVG
      • SWF
      • TEX
      • XPS
      • XSLFO
    • PDF
      • PDF
      • PDF/A
      • PDF/E
      • PDF/UA
      • PDF/VT
      • PDF/X
    • Presentation File Formats
      • Presentation File Formats
      • ODP
      • OTP
      • POT
      • POTM
      • POTX
      • PPS
      • PPSM
      • PPSX
      • PPT
      • PPTM
      • PPTX
    • Programming
      • Programming
      • C
      • Class
      • CPP
      • CS
      • CSPROJ
      • Dart
      • H
      • JAR
      • Java
      • KT
      • MF
      • PDB
      • PHP
      • PY
      • SH
      • SLN
      • SWIFT
      • TOML
      • VB
      • VBPROJ
      • VCXPROJ
      • YAML
    • Project Management File Formats
      • Project Management File Formats
      • MPP
      • MPT
      • MPX
      • XER
    • Spreadsheet File Formats
      • Spreadsheet File Formats
      • CSV
      • DIF
      • ODS
      • OTS
      • TSV
      • XLAM
      • XLM
      • XLS
      • XLSB
      • XLSM
      • XLSX
      • XLT
      • XLTM
      • XLTX
    • Video File Formats
      • Video File Formats
      • 3G2
      • 3GP
      • AVI
      • F4V
      • FLV
      • M4V
      • MKV
      • MOV
      • MP4
      • RM
      • RMVB
      • RV
      • SRT
      • VOB
      • WMV
      • Xvid
    • Web File Formats
      • Web File Formats
      • ASP
      • ASPX
      • CHM
      • CSS
      • HTM
      • HTML
      • JS
      • JSON
      • MHTML
      • Sass
      • SCSS
      • VDW
      • XAML
      • XHTML
      • XML
      • XOML
      • XSLT
    • Word Processing File Formats
      • Word Processing File Formats
      • DOC
      • DOCM
      • DOCX
      • DOT
      • DOTM
      • DOTX
      • MD
      • ODT
      • OTT
      • RTF
      • TXT

    What's on this Page

      • What is a PY file?
      • Brief History
        • Versions
      • How to open Python files
      • How to run/execute Python files
      • PY File Format
        • Syntax
      • References
    1. Home
    2. Programming
    3. PY

    What is a PY file?

    Files with the .py extension contain the python source code. It is a very popular language that can be used for web development, software development, mathematics, and system scripting. Python is a cross-platform language that can work on different platforms like Windows, MAC, Linux, Raspberry Pi, etc. Python provides a simple syntax that is similar to the English language and is easier to read. Pythons syntax allows programs to be written with fewer lines of code. Python runs on an interpreter system so the code can be executed as soon as it is written which makes it very good for prototyping.

    Brief History

    Python was conceived in the late 1980s by Guido van Rossum as a successor to ABC programming language. Its implementation began in December 1989 with Van Rossum as the sole lead developer. He worked on python until 12 July 2018. In January 2019, the active Python core developers elected a five-member “Steering Council” comprising of Nick Coghlan, Brett Cannon, Carol Willing, Barry Warsaw, and Van Rossum to lead the project.

    Versions

    • Python 2.0 was released on 16 October 2000.
    • Python 3.0 was released on 3 December 2008.

    How to open Python files

    To open Python files, you can use the following:

    • Notepad (this will not execute the script)
    • VS Code
    • Visual Studio
    • PyCharm

    How to run/execute Python files

    To check the version of Python installed, you can use the following command:

    python --version
    

    This will output the version on the console like

    Python 3.7.4
    

    If Python is not installed on your machine, you can go to python.org and download and install Python for your relevant operating system.

    To execute a Python script, you can use the following command:

    python helloworld.py
    

    helloworld.py is a script file that contains the following code

    print("Hello World from Python")
    

    This will print the following on the console window.

    Hello World from Python
    

    Note: If you use IDEs, they provide buttons on the screen or different keyboard shortcuts to run Python. For example, a play button is shown in the gutter with the editor in PyCharm that lets you execute the Python script.

    PY File Format

    Python was designed for readability and has similarities to English and Math. Python uses new lines to indicate the complete command as opposed to semicolons or parenthesis used in other languages. For scopes, loops, and functions, Python relies on indentation and whitespaces as opposed to curly braces used in other languages.

    Syntax

    The following is an example of Python syntax.

    print("Hello World")
    
    #Variables
    name = "John"
    age = 25
    print(name)
    print(age)
    
    #While Loop
    i = 1
    while i < 3:
      print(i)
      i += 1
      
    #For Loop
    names = ["John", "Harry", "Tom"]
    for name in names:
      print(name)
    

    References

    • Python Introduction - W3schools
    • Python (programming language) - Wikipedia

    See Also

    • KT File Format
    • Dart File Format
    • Java File Format
    • F4V File Format
    • AVIF File Format