Regard the `2` people who sit together as one 'unit' and the other `3` people as `3` 'units'. Arrange `4` 'units' in a circle: `(4 − 1)! Number of permutations of `2` people who sit together: `2! = 2` So `6 × 2 = 12` ways. 'I think 5 to 10 times per month. A lot has changed, especially with transitioning ― I am a transgender man. About four years in, our sex life really dropped off, and we had to figure out how to adjust to having busy schedules and making more effort to have sex.
Using Floor Beam Span Tables
Continuing on from Part 2: Wood Joist Span Tables of Residential Structural Design, we were just about to make our example house wider. Once we go beyond the allowable spans for floor joists (as shown in the floor joist span tables), we will need some kind of support under these floor joists.
This support could take the form of a structural wall. The wall could be either a properly sized structural concrete or concrete block wall or a wood framed wall. We'll discuss these possibilities later. For now, we'll look into supporting the floor joists with a floor joist beam.
The widest span in the floor joist span table in Part 2 of this tutorial module showed that floor joists can span 17'2' if they are 2 X 12s spaced 12' o.c. (on center). Let's expand our house beyond that 17'2' span capability to 24 feet wide. So the house dimensions will now be 24' X 13'.
It would be possible to still frame the floor in the same way as above but just run the floor joists in the opposite direction (looking for a lumber size to span 13') but for our example, we are going to keep the floor joists running in the same direction. Now at 24 feet, we are beyond the span capabilities of our table in our previous example. So we will have to place wood floor beams (or likewise, wood ceiling beams) across the width of the house to support the floor joists. See the picture below for a plan view of how this will look.
The floor joists are still 12' long but now you can see a floor beam running horizontally across the middle of the house (supported by the lower concrete foundation wall). The picture below shows what the framing for this floor would look like in a three-dimensional perspective.
The question now is how big does that center floor beam need to be? Once again, it is not necessary to do tricky wood beam calculations but rather, simply look up the answer in a beam span table. There are many beam span tables for all the different lumber species and also for the number of floors that are ultimately supported by this beam. The table below shows an excerpt from a maximum span for built-up Douglas fir floor beams table for supporting not more than one floor. There are several beam span tables for all the species of wood.
In the following examples, input and output are distinguished by the presence orabsence of prompts (>>> and …): to repeat the example, you must typeeverything after the prompt, when the prompt appears; lines that do not beginwith a prompt are output from the interpreter. Note that a secondary prompt on aline by itself in an example means you must type a blank line; this is used toend a multi-line command.
Many of the examples in this manual, even those entered at the interactiveprompt, include comments. Comments in Python start with the hash character,#
, and extend to the end of the physical line. A comment may appear at thestart of a line or following whitespace or code, but not within a stringliteral. A hash character within a string literal is just a hash character.Since comments are to clarify code and are not interpreted by Python, they maybe omitted when typing in examples.
Some examples:
3.1. Using Python as a Calculator¶
Let's try some simple Python commands. Start the interpreter and wait for theprimary prompt, >>>
. (It shouldn't take long.)
3.1.1. Numbers¶
The interpreter acts as a simple calculator: you can type an expression at itand it will write the value. Expression syntax is straightforward: theoperators +
, -
, *
and /
work just like in most other languages(for example, Pascal or C); parentheses (()
) can be used for grouping.For example:
The integer numbers (e.g. 2
, 4
, 20
) have type int
,the ones with a fractional part (e.g. 5.0
, 1.6
) have typefloat
. We will see more about numeric types later in the tutorial.
Division (/
) always returns a float. To do floor division andget an integer result (discarding any fractional result) you can use the //
operator; to calculate the remainder you can use %
:
With Python, it is possible to use the **
operator to calculate powers 1:
The equal sign (=
) is used to assign a value to a variable. Afterwards, noresult is displayed before the next interactive prompt:
If a variable is not 'defined' (assigned a value), trying to use it willgive you an error:
There is full support for floating point; operators with mixed type operandsconvert the integer operand to floating point:
In interactive mode, the last printed expression is assigned to the variable_
. This means that when you are using Python as a desk calculator, it issomewhat easier to continue calculations, for example:
This variable should be treated as read-only by the user. Don't explicitlyassign a value to it — you would create an independent local variable with thesame name masking the built-in variable with its magic behavior.
In addition to int
and float
, Python supports other types ofnumbers, such as Decimal
and Fraction
.Python also has built-in support for complex numbers,and uses the j
or J
suffix to indicate the imaginary part(e.g. 3+5j
).
3.1.2. Strings¶
Besides numbers, Python can also manipulate strings, which can be expressedin several ways. They can be enclosed in single quotes ('..'
) ordouble quotes ('..'
) with the same result 2. can be usedto escape quotes:
In the interactive interpreter, the output string is enclosed in quotes andspecial characters are escaped with backslashes. While this might sometimeslook different from the input (the enclosing quotes could change), the twostrings are equivalent. The string is enclosed in double quotes ifthe string contains a single quote and no double quotes, otherwise it isenclosed in single quotes. The print()
function produces a morereadable output, by omitting the enclosing quotes and by printing escapedand special characters:
If you don't want characters prefaced by to be interpreted asspecial characters, you can use raw strings by adding an
r
beforethe first quote:
String literals can span multiple lines. One way is using triple-quotes:''..''
or ''..''
. End of lines are automaticallyincluded in the string, but it's possible to prevent this by adding a atthe end of the line. The following example:
produces the following output (note that the initial newline is not included):
Strings can be concatenated (glued together) with the +
operator, andrepeated with *
:
Two or more string literals (i.e. the ones enclosed between quotes) nextto each other are automatically concatenated.
Anytrans 7 0 4 (20181108) – complete ios content management. This feature is particularly useful when you want to break long strings:
This only works with two literals though, not with variables or expressions:
If you want to concatenate variables or a variable and a literal, use +
:
Strings can be indexed (subscripted), with the first character having index 0.There is no separate character type; a character is simply a string of sizeone:
Indices may also be negative numbers, to start counting from the right:
Note that since -0 is the same as 0, negative indices start from -1.
In addition to indexing, slicing is also supported. While indexing is usedto obtain individual characters, slicing allows you to obtain substring:
Slice indices have useful defaults; an omitted first index defaults to zero, anomitted second index defaults to the size of the string being sliced.
Note how the start is always included, and the end always excluded. Thismakes sure that s[:i]+s[i:]
is always equal to s
:
One way to remember how slices work is to think of the indices as pointingbetween characters, with the left edge of the first character numbered 0.Then the right edge of the last character of a string of n characters hasindex n, for example:
The first row of numbers gives the position of the indices 0…6 in the string;the second row gives the corresponding negative indices. The slice from i toj consists of all characters between the edges labeled i and j,respectively.
For non-negative indices, the length of a slice is the difference of theindices, if both are within bounds. For example, the length of word[1:3]
is2.
Attempting to use an index that is too large will result in an error:
However, out of range slice indexes are handled gracefully when used forslicing:
Python strings cannot be changed — they are immutable.Therefore, assigning to an indexed position in the string results in an error:
If you need a different string, you should create a new one:
The built-in function len()
returns the length of a string:
See also
Together 3 5 100
Strings are examples of sequence types, and support the commonoperations supported by such types.
Dupezap 4 1 13. Strings support a large number of methods forbasic transformations and searching.
String literals that have embedded expressions.
Copy clip 2 9 9 1 – clipboard manager resume. Information about string formatting with str.format()
.
The old formatting operations invoked when strings arethe left operand of the %
operator are described in more detail here.
3.1.3. Lists¶
Python knows a number of compound data types, used to group together othervalues. The most versatile is the list, which can be written as a list ofcomma-separated values (items) between square brackets. Lists might containitems of different types, but usually the items all have the same type.
Like strings (and all other built-in sequence types), lists can beindexed and sliced:
All slice operations return a new list containing the requested elements. Thismeans that the following slice returns ashallow copy of the list:
Lists also support operations like concatenation:
Unlike strings, which are immutable, lists are a mutabletype, i.e. it is possible to change their content:
You can also add new items at the end of the list, by usingthe append()
method (we will see more about methods later):
Assignment to slices is also possible, and this can even change the size of thelist or clear it entirely:
Together 3 5 101
The built-in function len()
also applies to lists:
It is possible to nest lists (create lists containing other lists), forexample:
3.2. First Steps Towards Programming¶
Of course, we can use Python for more complicated tasks than adding two and twotogether. For instance, we can write an initial sub-sequence of theFibonacci seriesas follows:
This example introduces several new features.
The first line contains a multiple assignment: the variables
a
andb
simultaneously get the new values 0 and 1. On the last line this is used again,demonstrating that the expressions on the right-hand side are all evaluatedfirst before any of the assignments take place. The right-hand side expressionsare evaluated from the left to the right.The
while
loop executes as long as the condition (here:a<10
)remains true. In Python, like in C, any non-zero integer value is true; zero isfalse. The condition may also be a string or list value, in fact any sequence;anything with a non-zero length is true, empty sequences are false. The testused in the example is a simple comparison. The standard comparison operatorsare written the same as in C:<
(less than),>
(greater than), (equal to),<=
(less than or equal to),>=
(greater than or equal to)and!=
(not equal to).The body of the loop is indented: indentation is Python's way of groupingstatements. At the interactive prompt, you have to type a tab or space(s) foreach indented line. In practice you will prepare more complicated inputfor Python with a text editor; all decent text editors have an auto-indentfacility. When a compound statement is entered interactively, it must befollowed by a blank line to indicate completion (since the parser cannotguess when you have typed the last line). Note that each line within a basicblock must be indented by the same amount.
The
print()
function writes the value of the argument(s) it is given.It differs from just writing the expression you want to write (as we didearlier in the calculator examples) in the way it handles multiple arguments,floating point quantities, and strings. Strings are printed without quotes,and a space is inserted between items, so you can format things nicely, likethis:The keyword argument end can be used to avoid the newline after the output,or end the output with a different string:
Footnotes
Together 3 5 1000
Since **
has higher precedence than -
, -3**2
will beinterpreted as -(3**2)
and thus result in -9
. To avoid thisand get 9
, you can use (-3)**2
.
Together 3 5 10 Day
Unlike other languages, special characters such as n
have thesame meaning with both single ('..'
) and double ('..'
) quotes.The only difference between the two is that within single quotes you don'tneed to escape '
(but you have to escape '
) and vice versa.