Home / Expert Answers / Computer Science / please-do-in-python-write-a-program-that-asks-the-user-for-a-choice-if-the-chouce-is-1-then-ent-pa920

(Solved): please do in python Write a program that asks the user for a choice. - If the chouce is 1 , then ent ...



please do in python

Write a program that asks the user for a choice.
- If the chouce is 1 , then enter the name of an input and outpal file. Your
portion (troms \( 1 / 4 \) of hetght to \( 5 / 4 \) of height and trom \( 1 / 4 \) of width to \( 9 / 4 \) of width) of the o
Write a program that asks the user for a choice. - If the chouce is 1 , then enter the name of an input and outpal file. Your program should then save the top left quarter of the image to the oulput fille spocified by the user. - If the choice is 1 , then enter the name of an outper file to save the midille portion (from of height to of height and from of with to of width) of the ariginal figure. The logo is from ImageMagick program. A sample run of your program should losk like: Enter 1 to get top left corner Enter 2 to get middle portion Yoaz choice: ? Enter lnput tile name: magie logo.pag Enter ostpot flle nure; nagie_logo_top_left,png which would have as input and oenput: Another sample rin of your program should look like: Enter 1 to get top left eorner Encer 2 to get middle portion Yoar ehoice ? Enter isput file naate nagie_logo-peg Enter outpet file nome1 nagi?_logo niddie.png which would have as input and ootput: When entering any number other than of 2 , here is an output: Enter 1 to get top left corper riter 2 to get middle portion Tour choices 3 wrong choice Wink: See sample mograms from Lectures 4 and 6 Hint: When ingouf a choice anher ahan 'l'ar '2'. priat "arong chovec" and ent the prognim, Oheruise, enker bhe inysit file name and outpot file mame, then deprnding an the choice (either 'or 2 ' 29 , cut the image and save the povtion to the owtput file portion (troms of hetght to of height and trom of width to of width) of the original ftgure. The logo is from ImageMagick program. A sample run of your program shoald look like: Enter I to get top lett corner Enter 2 to get niddle portion Your choice: 1 Enter input file namet magie_logo.png Enter oucput file name: magic_logo_top_left.png which would have as input and output: Anoher sample run of your program should look like: Enter 1 to get top left corner Enter 2 to get niddle portion Your choice1 2 Enter input tile nane: magie_logo, pag Enter outpat file name1 magio_logo_middle.png which would have as input and output: When entering any number other than or 2 , here is an output: Enter 1 to get top left corner Enter 2 to get middle portion Your ehoice: 3 wrong choice Hint: See sample programs from Lectures 4 and 6. Hint: When input a choice other than 'l' or '2', print "wrong choice" and exit the program. Olherwise, enter the inpur file name and output flle name, then depending on the choice (either ' ' or '20. cut the image and save the portion to the output file. Note: before submitting your program for grading, remove any commands that show the image (i.e. the ones that pop up the graphics window with the image). The program is graded on a server on the cloud and does not have a graphics window, so, the plt. show () and plt. Imshow() commands will give an error. Instcad, the files your program produces are compared pixel-by-pixel to the answer to check for correctness.


We have an Answer from Expert

View Expert Answer

Expert Answer


Here's a possible implementation of the program in Python:from PIL import Image# ask user for choiceprint("Enter 1 to get top left corner")print("Ente
We have an Answer from Expert

Buy This Answer $5

Place Order

We Provide Services Across The Globe