use PYTHON Even though Windows and macOS sometimes hide them, most files have file extensionsLinks to an external site., a suffix that starts with a period (.) at the end of their name. For instance, file names for GIFsLinks to an external site. end with .gif, and file names for JPEGsLinks to an external site. end with .jpg or .jpeg. When you double-click on a file to open it, your computer uses its file extension to determine which program to launch. Web browsers, by contrast, rely on media typesLinks to an external site., formerly known as MIME types, to determine how to display files that live on the web. When you download a file from a web server, that server sends an HTTP headerLinks to an external site., along with the file itself, indicating the file’s media type. For instance, the media type for a GIF is image/gif, and the media type for a JPEG is image/jpeg. To determine the media type for a file, a web server typically looks at the file’s extension, mapping one to the other. See developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_typesLinks to an external site. for common types. In a file called extensions.py, implement a program that prompts the user for the name of a file and then outputs that file’s media type if the file’s name ends, case-insensitively, in any of these suffixes: .gif .jpg .jpeg .png .pdf .txt .zip Please see attache photos for Demo and Test use PYTHON
use PYTHON
Even though Windows and macOS sometimes hide them, most files have file extensionsLinks to an external site., a suffix that starts with a period (.) at the end of their name. For instance, file names for GIFsLinks to an external site. end with .gif, and file names for JPEGsLinks to an external site. end with .jpg or .jpeg. When you double-click on a file to open it, your computer uses its file extension to determine which program to launch.
Web browsers, by contrast, rely on media typesLinks to an external site., formerly known as MIME types, to determine how to display files that live on the web. When you download a file from a web server, that server sends an HTTP headerLinks to an external site., along with the file itself, indicating the file’s media type. For instance, the media type for a GIF is image/gif, and the media type for a JPEG is image/jpeg. To determine the media type for a file, a web server typically looks at the file’s extension, mapping one to the other.
See developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_typesLinks to an external site. for common types.
In a file called extensions.py, implement a program that prompts the user for the name of a file and then outputs that file’s media type if the file’s name ends, case-insensitively, in any of these suffixes:
- .gif
- .jpg
- .jpeg
- .png
- .txt
- .zip
Please see attache photos for Demo and Test
use PYTHON
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 2 images