Section 1.6 - IT 140_ Introduction to Scripting _ zyBooks

pdf

School

Southern New Hampshire University *

*We aren’t endorsed by this school

Course

140 - X625

Subject

Computer Science

Date

Apr 3, 2024

Type

pdf

Pages

2

Uploaded by DeaconCaterpillar4154

Report
Students: Section 1.6 is a part of 1 assignment: 1-3 zyBooks Participation Activities Includes: PA "My program is correct, but the system is complaining about output whitespace. " 1.6 Why whitespace matters Whitespace and precise formatting For program output, whitespace is any blank space or newline. Most coding activities strictly require a student program's output to exactly match the expected output, including whitespace. Students learning programming often complain: However, correctness often includes output being formatted correctly. PARTICIPATION ACTIVITY 1.6.1: Precisely formatting a meeting invite. PARTICIPATION ACTIVITY 1.6.2: Program correctness includes correctly-formatted output. Consider the example above. 1) The programmer on the left intentionally inserted a newline in the ±rst sentence, namely "Kia Smith ... video meeting". Why? Probably a mistake So the text appears less jagged To provide some randomness to the output 2) The programmer on the right did not end the ±rst sentence with a newline. What effect did that omission have? "Join meeting" appears on the same line No effect 3) The programmer on the left neatly formatted the link, the "Phone:" text, and phone numbers. What did the programmer on the right do? Also neatly formatted those items Output those items without neatly formatting 4) On the right, why did the "Reminder..." text appear on the same line as the separator text "------"? Because programs behave erratically Because the programmer didn't end the output with a newline 5) Whitespace _____ important in program output. is is not Programming is all about precision Programming is all about precision . Programs must be created precisely to run correctly. Ex: Kia Smith is inviting you to a video meeting. Join meeting: http://www.zoomskype.us/5592 Phone: 1-669-555-2634 (San Jose) 1-929-555-4000 (New York) Meeting ID: 5592 ------------------------- Reminder: 10 min before Kia Smith is inviting you to a video meeting. Join meeting: http://www.zoomskype.us/5592 Phone: 1-669-555-2634 (San Jose) 1-929-555-4000 (New York) Meeting ID: 5592 ------------------------- Reminder: 10 min before 1. This program for online meetings not only does computations like scheduling and creating a unique meeting ID, but also outputs text formatted neatly for a calendar event. 2. A calendar program may append more text after the meeting invitation text. 3. The programmer of the invitation on the right wasn't careful with whitespace. "Join meeting" is buried, the link is hard to see, and the "Phone" text is dangling at a line's end. 4. The programmer also didn't end with a newline, causing subsequent text to appear at the end of a line, and even wrap to the next line. This output looks unprofessional. Captions Feedback? Feedback? Start 2x speed
Activity summary for assignment: 1-3 zyBooks Participation Activities 98 % 98 % submitted to desire2learn = and == have different meanings. Using i where j was meant can yield a hard-to-±nd bug. Not considering that n could be 0 in sum/n can cause a program to fail entirely in rare but not insigni±cant cases. Counting from i being 0 to i < 10 vs. i <= 10 can mean the difference between correct output and a program outputting garbage. In programming, every little detail counts. Programmers must get in a mindset of paying extreme attention to detail . Thus, another reason for caring about whitespace in program output is to help new programmers get into a "precision" mindset when programming. Paying careful attention to details like whitespace instructions, carefully examining feedback regarding whitespace differences, and then modifying a program to exactly match expected whitespace is an exercise in strengthening attention to detail. Such attention can lead programmers to make fewer mistakes when creating programs, thus spending less time debugging, and instead creating programs that work correctly. PARTICIPATION ACTIVITY 1.6.3: Thinking precisely, and attention to detail. Programmers bene±t from having a mindset of thinking precisely and paying attention to details. The following questions emphasize attention to detail. See if you can get all of the questions correct on the ±rst try. 1) How many times is the letter F (any case) in the following? If Fred is from a part of France, then of course Fred's French is good. 2) How many differences are in these two lines? Printing A linE is done using printIn Printing A linE is done using print1n 3) How many typos are in the following? Keep calmn and cary one. 4) If I and E are adjacent, I should come before E, except after C (where E should come before I). How many violations are in the following? BEIL CEIL ZIEL YIEIK TREIL 5) A password must start with a letter, be at least 6 characters long, include a number, and include a special symbol. How many of the following passwords are valid? hello goodbye Maker1 dog!three Oops_again 1augh#3 Programmer attention to details The focus needed to answer the above correctly on the ±rst try is the kind of focus needed to write correct programs. Due to this fact, some employers give "attention to detail" tests to people applying for programming positions. See for example this test , or this article discussing the issue. Or, just web search for "programmer attention to details" for more such tests and articles. How was this section? | Check Show answer Check Show answer Check Show answer Check Show answer Check Show answer Feedback? Provide section feedback Completion details
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help