Course Hero Logo

It 140 introduction to scripting v3 home

Course Hero uses AI to attempt to automatically extract content from documents to surface to you and others so you can study better, e.g., in search results, to enrich docs, and more. This preview shows page 46 - 48 out of 56 pages.

3/26/2021IT 140: Introduction to Scripting v3 home46/56Special casesThe number of columns of text considered to be acceptable varies from 80 to 120.Good practice is touse the widely accepted standard of 80 columns. A few exceptions to the rules of indentation dealwith very long statements that require more than one line andwrapto the next line. Such specialsituations do not indicate new code blocks.Figure 3.8.2: Some indentations are continuations of the previous line.Multiple lines enclosed within parentheses are implicitly joined into a single string (withoutnewlines between each line); use implicit line joining for very long strings or functions withnumerous arguments. Ex: All extra lines are indented to the same column as the openingquotation mark on the ±rst line.When declaring list or dict literals, entries can be placed on separate lines for clarity.declaration= ("When in the Course of human events, it becomes necessary for ""one people to dissolve the political bands which have connected ""them with another, and to assume among the powers of the earth...")result_of_power=math.pow(long_variable_name_left_operand,long_variable_name_right_operand)Figure 3.8.3: List, dict multi-line constructs.Containers like lists and dicts can be broken into multiple lines, with the elements onseparate, indented lines.my_list= [1,2,3,4,5,6]my_dict={'entryA':1,'entryB':2}PARTICIPATIONACTIVITY3.8.1: Indentation.1)The standard number of spaces to usefor indentation is 4.©zyBooks 03/26/21 10:57 925595harley smithSNHUIT140v3©zyBooks 03/26/21 10:57 925595harley smithSNHUIT140v3
3/26/2021IT 140: Introduction to Scripting v3 home2)Mixing spaces and tabs whenindenting is considered an acceptableprogramming style.TrueFalse
47/56
3)A programmer can start new codeblocks at any point in the code, as longas the indentation for each line in theblock is consistent.CHALLENGEACTIVITY3.8.1: Indentation: Fix the program.Retype the below code. Fix the indentation as necessary to make the program work.if 'New York' in temperatures:if temperatures['New York'] > 90:print('The city is melting!')else:print('The temperature in New York is', temperatures['NewYork'])else:print('The temperature in New York is unknown.')Sample output with input: 105The city is melting!

Upload your study docs or become a

Course Hero member to access this document

Upload your study docs or become a

Course Hero member to access this document

End of preview. Want to read all 56 pages?

Upload your study docs or become a

Course Hero member to access this document

Term
Spring
Professor
professor_unknown
Tags
1984, Equals sign, relational operator, multiharley smith

Newly uploaded documents

Show More

Newly uploaded documents

Show More

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture