Skip to content
Snippets Groups Projects
Commit c5b47d8a authored by Agha Muhammad Aslam's avatar Agha Muhammad Aslam
Browse files

Initial commit

parents
Branches
No related tags found
No related merge requests found
# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
# Editor directories and files
.vscode/*
\ No newline at end of file
hello.py 0 → 100644
import os # This goes to the top of the file
def save_ppm():
# Put this inside the function
output_path = os.path.join(os.path.dirname(__file__), "output")
output_file = os.path.join(output_path, "image.ppm")
os.makedirs(output_path, exist_ok=True)
ppm_file = open(output_file, "w")
# This is the header for a PPM file
width = 256
height = 256
header = "P3\n{w} {h}\n255\n".format(w=width, h=height)
ppm_file.write(header)
for y in range(0, height):
for x in range(0, width):
value = "{r} {g} {b}\n".format(r=x, g=y,b=0)
ppm_file.write(value)
# Close the file after writing
ppm_file.close()
if __name__ == "__main__":
save_ppm()
print("PPM file created successfully.")
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment