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

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

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

Demo
$ python extensions.py
File name: cat.gif
image/gif
$ python extensions.py
File name: cat.jpg
image/jpeg
$ python extensions.py
File name: cat.jpeg
image/jpeg
Transcribed Image Text:Demo $ python extensions.py File name: cat.gif image/gif $ python extensions.py File name: cat.jpg image/jpeg $ python extensions.py File name: cat.jpeg image/jpeg
Run your program with python extensions.py. Type happy.jpg and press Enter. Your program should output:
image/jpeg
• Run your program with python extensions.py. Type document.pdf) and press Enter. Your program should output:
application/pdf
Transcribed Image Text:Run your program with python extensions.py. Type happy.jpg and press Enter. Your program should output: image/jpeg • Run your program with python extensions.py. Type document.pdf) and press Enter. Your program should output: application/pdf
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
File Input and Output Operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education