Question: WRITE A PYTHON CODE Suppose you want to print something but you only have access to a very strange printer. The printer is only able

WRITE A PYTHON CODE

WRITE A PYTHON CODE Suppose you want to print something but youonly have access to a very strange printer. The printer is onlyable to print uppercase letters. The printer has 3 buttons: "On/Off" button:Boot the printer or shutdown to finish the printing. "Print" button /

Suppose you want to print something but you only have access to a very strange printer. The printer is only able to print uppercase letters. The printer has 3 buttons: "On/Off" button: Boot the printer or shutdown to finish the printing. "Print" button / Delayed Print": Both buttons will try to print an uppercase letter to the paper. The letter to be printed is based on alphabetical order: the first time you hit "Print"/"Delayed Print, the printer tries to print A, then the next time you do this the printer tries to print B, and so on. The printer will stop printing any letters after trying to print Z. The difference between the two buttons is, hitting the "Print" button will print the letter immediately, but after hitting the "Delayed Print" button, the letter will be printed to the paper after 30 seconds. In this assignment, we assume that after using On/Off to finish the printing, we cannot boot the printer again. Despite its strange design, the print is indeed capable of printing certain words. For example, the word BAD is printable, and here is how to do this. We first boot the printer, and for convenience, we refer to this time point as "second 0. We first immediately hit Delayed Print, the printer will try to print A, but only at second 30. Then at second 1, we hit Print, which immediately prints a B to the paper. Then at second 10, we hit "Delayed Print", which will cause the C to be printed at second 40. Wait until second 30, which will print A to the paper. Now the paper has BA. At second 31, hit Print, which prints D to the paper immediately. Now the paper has BAD, and we hit the "On/Off" button to finish the printing. (Note that at this time point the letter "C" is still waiting to be printed, but if we hit "On/Off', all the delayed prints will be canceled). We have successfully printed BAD". However, some words are not printable using this printer. An example will be the word HAD, which is not printable. You can think about why. Your Task Write a program which reads a file and determine whether each word of the file is printable. In the input file, every line contains a word. Given such a file, your program should show output to the screen whether the word is printable or not. Sample Input file ALERT HAT LED ABORT CABIND FABRIC PARTY Sample output given the above input: INO YES NO YES YES NO YES Suppose you want to print something but you only have access to a very strange printer. The printer is only able to print uppercase letters. The printer has 3 buttons: "On/Off" button: Boot the printer or shutdown to finish the printing. "Print" button / Delayed Print": Both buttons will try to print an uppercase letter to the paper. The letter to be printed is based on alphabetical order: the first time you hit "Print"/"Delayed Print, the printer tries to print A, then the next time you do this the printer tries to print B, and so on. The printer will stop printing any letters after trying to print Z. The difference between the two buttons is, hitting the "Print" button will print the letter immediately, but after hitting the "Delayed Print" button, the letter will be printed to the paper after 30 seconds. In this assignment, we assume that after using On/Off to finish the printing, we cannot boot the printer again. Despite its strange design, the print is indeed capable of printing certain words. For example, the word BAD is printable, and here is how to do this. We first boot the printer, and for convenience, we refer to this time point as "second 0. We first immediately hit Delayed Print, the printer will try to print A, but only at second 30. Then at second 1, we hit Print, which immediately prints a B to the paper. Then at second 10, we hit "Delayed Print", which will cause the C to be printed at second 40. Wait until second 30, which will print A to the paper. Now the paper has BA. At second 31, hit Print, which prints D to the paper immediately. Now the paper has BAD, and we hit the "On/Off" button to finish the printing. (Note that at this time point the letter "C" is still waiting to be printed, but if we hit "On/Off', all the delayed prints will be canceled). We have successfully printed BAD". However, some words are not printable using this printer. An example will be the word HAD, which is not printable. You can think about why. Your Task Write a program which reads a file and determine whether each word of the file is printable. In the input file, every line contains a word. Given such a file, your program should show output to the screen whether the word is printable or not. Sample Input file ALERT HAT LED ABORT CABIND FABRIC PARTY Sample output given the above input: INO YES NO YES YES NO YES

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!