Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

How do you ad a image in Python3?

0 votes
asked Apr 12 by Melaine Sublette (220 points)

1 Answer

0 votes
answered Apr 18 by Peter Minarik (58,190 points)
What exactly are you after? What do you mean by "add an image"? Do you have a context? Do you have some code to share?

Would you like to load an image? Or display it on the screen (not gonna happen in OnlineGDB as it's a character-based terminal only, no graphics output)? What sort of image are we talking about?
commented Apr 20 by Melaine Sublette (220 points)
Sort of like a video game image.
commented Apr 21 by Peter Minarik (58,190 points)
First of all, OnlineGDB code is running on a server and the standard output is relayed to your computer and displayed in the console of your browser. You cannot display pictures this way.

In general, if you're running Python on a computer with graphics capability (e.g. your own computer) you can display pictures of course.

A quick browser search brought up the following solutions:
- https://www.delftstack.com/howto/python/python-display-image/
- https://pythonexamples.org/python-pillow-show-display-image/

And as mentioned in another answer, you can check out Pygame to create games: https://www.pygame.org/

You need to do a bit of research, and download the required libraries. Check out the linked websites, they have instructions on how to get started.

Good luck!
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...