Skip to content
Home » [NEW] Python parentheses primer | brackets คือ – NATAVIGUIDES

[NEW] Python parentheses primer | brackets คือ – NATAVIGUIDES

brackets คือ: นี่คือโพสต์ที่เกี่ยวข้องกับหัวข้อนี้


13

Table of Contents

Python parentheses primer

If you have children, then you probably remember them learning to walk, and then to read. If you’re like me, you were probably amazed by how long it took to do things that we don’t even think about. Things that we take for granted in our day-to-day lives, and which seem so obvious to us, take a long time to master.

You can often see and experience this when you compare how you learn a language as a native speaker, from how you learn as a second language. I grew up speaking English, and never learned all sorts of rules that my non-native-speaking friends learned in school. Similarly, I learned all sorts of rules for Hebrew grammar that my children never learned in school.

It’s thus super easy to take things for granted when you’re an expert. Indeed, that’s almost the definition of an expert — someone who understands a subject so well, that for them things are obvious.

To many developers, and especially Python developers, it’s obvious not only that there are different types of parentheses in Python, but that each type has multiple uses, and do completely different things. But to newcomers, it’s far from obvious when to use round parentheses, square brackets, and/or curly braces.

I’ve thus tried to summarize each of these types of parentheses, when we use them, and where you might get a surprise as a result.  If you’re new to Python, then I hope that this will help to give you a clearer picture of what is used when.

I should also note that the large number of parentheses that we use in Python means that using an editor that colorizes both matching and mismatched parentheses can really help. On no small number of occasions, I’ve been able to find bugs quickly thanks to the paren-coloring system in Emacs.

Regular parentheses — ()

Callables (functions and classes)

Perhaps the most obvious use for parentheses in Python is for calling functions and creating new objects. For example:

x = len('abcd')

i = int('12345')

It’s worth considering what happens if you don’t use parentheses. For example, I see the following code all the time in my courses:

d = {'a':1, 'b':2, 'c':3}
for key, value in d.items:
    print(f"{key}: {value}")

When you try to run this code, you can an error message that is true, but whose meaning isn’t completely obvious:

TypeError

: 'builtin_function_or_method' object is not iterable

Huh?  What the heck does this mean?

It’s worth remembering how “for” loops work in Python:

  • “for” turns to the object at the end of the line, and asks whether it’s iterable
  • if so, then “for” asks the object for its next value
  • whenever the object says, “no more!” the loop stops

In this case, “for” turns to the method “d.items” and asks if it’s iterable. Note that we’re not asking whether the output from “d.items” is iterable, but rather whether the method itself is iterable.

That’s because there’s a world of difference between “d.items” and “d.items()”. The first returns the method. The second returns an iterable sequence of name-value pairs from the dictionary “d”.

The solution to this non-working code is thus to add parentheses:

d = {'a':1, 'b':2, 'c':3}
for key, value in d.items():
    print(f"{key}: {value}")

Once we do that, we get the desired result.

I should note that we also need to be careful in the other direction: Sometimes, we want to pass a function as an argument, and not execute it. One example is when we’re in the Jupyter notebook (or other interactive Python environment) and ask for help on a function or method:

help(len)

help(str.upper)

In both of the above cases, we don’t want to get help on the output of those functions; rather, we want to get help on the functions themselves.

Prioritizing operations

In elementary school, you probably learned the basic order of arithmetic operations — that first we multiply and divide, and only after do we add and subtract.

Python clearly went to elementary school as well, because it follows this order.  For example:

In [1]: 2 + 3 * 4
Out[1]: 14

We can change the priority by using round parentheses:

In [2]: (2 + 3) * 4
Out[2]: 20

Experienced developers often forget that we can use parentheses in this way, as well — but this is, in many ways, the most obvious and natural way for them to be used by new developers.


Creating tuples

Of course, we can also use () to create tuples. For example:

In [8]: t = (10,20,30)

In [9]: type(t)
Out[9]: tuple

What many beginning Python developers don’t know is that you actually don’t need the parentheses to create the tuple:

In [6]: t = 10,20,30

In [7]: type(t)
Out[7]: tuple

Which means that when you return multiple values from a function, you’re actually returning a tuple:

In [3]: def foo():
...: return 10, 20, 30
...:
...:

In [4]: x = foo()

In [5]: x
Out[5]: (10, 20, 30)

What surprises many newcomers to Python is the following:

In [10]: t = (10)

In [11]: type(t)
Out[11]: int

“Wait,” they say, “I used parentheses. Shouldn’t t be a tuple?”

No, t is an integer.  When Python’s parser sees something like “t = (10)”, it can’t know that we’re talking about a tuple.  Otherwise, it would also have to parse “t = (8+2)” as a tuple, which we clearly don’t want to happen, assuming that we want to use parentheses for prioritizing operations (see above).  And so, if you want to define a one-element tuple, you must use a comma:

In [12]: t = (10,)

In [13]: type(t)
Out[13]: tuple

Generator expressions

Finally, we can use round parentheses to create “generators,” using what are known as “generator expressions.” These are a somewhat advanced topic, requiring knowledge of both comprehensions and iterators. But they’re a really useful tool, allowing us to describe a sequence of data without actually creating each element of that sequence until it’s needed.

For example, if I say:

In [17]: g = (one_number * one_number
...: for one_number in range(10))

The above code defines “g” to be a generator, the result of executing our generator expression. “g” is than an iterable, an object that can be placed inside of a “for” loop or a similar context.   The fact that it’s a generator means that we can have a potentially infinite sequence of data without actually needing to install an infinite amount of RAM on our computers; so long as we can retrieve items from our iterable one at a time, we’re set.

The above generator “g” doesn’t actually return 10 numbers. Rather, it returns one number at a time. We can retrieve them all at once by wrapping it in a call to “list”:

In [18]: list(g) 
Out[18]: [0, 1, 4, 9, 16, 25, 36, 49, 64, 81]

But the whole point of a generator is that you don’t want to do that. Rather, you will get each element, one at a time, and thus reduce memory use.

Something funny happens with round parentheses when they’re used on a generator expression in a function call.  Let’s say I want to get a string containing the elements of a list of integers:

In [19]: mylist = [10, 20, 30]

In [20]: '*'.join(mylist)

This fails, because the elements of “mylist” are integers.  We can use a generator expression to turn each integer into a string:

In [21]: '*'.join((str(x)
...: for x in mylist))
Out[21]: '10*20*30'

Notice the double parentheses here; the outer ones are for the call to str.join, and the inner ones are for the generator expression. Well, it turns out that we can remove the inner set:

In [22]: '*'.join(str(x)
...: for x in mylist)
Out[22]: '10*20*30'

So the next time you see a call to a function, and a comprehension-looking thing inside of the parentheses, you’ll know that it’s a generator expression, rather than an error.

Cheating Python’s indentation rules

Python is famous for its use of indentation to mark off blocks of code, rather than curly braces, begin/end, or the like. In my experience, using indentation has numerous advantages, but tends to shock people who are new to the language, and who are somewhat offended that the language would dictate how and when to indent code.

There are, however, a few ways to cheat (at least a little) when it comes to these indentation rules. For example, let’s say I have a dictionary representing a person, and I want to know if the letter ‘e’ is in any of the values.  I can do something like this:

In [39]: person = {'first':'Reuven', 'last':'Lerner', 'email':'[email protected]'}

In [40]: if 'e' in person['first'] or 'e' in person['last'] or 'e' in person['email']:
...: print("Found it!")
...:
Found it!

That “if” line works, but it’s far too long to be reasonably readable.  What I’d love to do is this:

In [40]: if 'e' in person['first'] or 
            'e' in person['last'] or 
            'e' in person['email']:
...: print("Found it!")

The problem is that the above code won’t work; Python will get to the end of the first “or” and complain that it reached the end of the line (EOL) without a complete statement.

The solution is to use parentheses. That’s because once you’ve opened parentheses, Python is much more forgiving and flexible regarding indentation. For example, I can write:

In [41]: if ('e' in person['first'] or
...:         'e' in person['last'] or
...:         'e' in person['email']):
...:         print("Found it!")
...:
...:
Found it!

Our code is now (in my mind) far more readable, thanks to the otherwise useless parentheses that I’ve added.

By the way, this is true for all parentheses. So if I want to define my dict on more than one line, I can say:

In [42]: person = {'first':'Reuven',
...:               'last':'Lerner',
...:               'email':'[email protected]'}

Python sees the opening { and is forgiving until it finds the matching }. In the same way, we can open a list comprehension on one line and close it on another.  For years, I’ve written my list comprehensions on more than one line, in the belief that they’re easier to read, write, and understand. For example:

[one_number * one_number

for one_number in range(10)]

Square brackets — []

Creating lists

We can create lists with square brackets, as follows:

mylist = [ ]  # empty list

mylist = [10, 20, 30]  # list with three items

Note that according to PEP 8, you should write an empty list as [], without any space between the brackets.  I’ve found that with certain fonts, the two brackets end up looking like a square, and are hard for people in my courses to read and understand.  So I always put a space between the brackets when creating an empty list.

(And yes, I’m that rebellious in real life, not just when programming.)

We can use square brackets not just to create lists with explicitly named elements, but also to create lists via list comprehensions:

In [16]: [one_number * one_number
...: for one_number in range(10)]
...:
Out[16]: [0, 1, 4, 9, 16, 25, 36, 49, 64, 81]

The square brackets tell Python that this is a list comprehension, producing a list.  If you use curly braces, you’ll get either a set or a dict back, and if you use regular parentheses, you’ll get a generator expression (see above).

Requesting individual items

Many people are surprised to discover that in Python, we always use square brackets to retrieve from a sequence or dictionary:

In [23]: mylist = [10, 20,30]

In [24]: t = (10, 20, 30)

In [25]: d = {'a':1, 'b':2, 'c':3}

In [26]: mylist[0]
Out[26]: 10

In [27]: t[1]
Out[27]: 20

In [28]: d['c']
Out[28]: 3

Why don’t we use regular parentheses with tuples and curly braces with dictionaries, when we want to retrieve an element? The simple answer is that square brackets, when used in this way, invoke a method — the __getitem__ method.

That’s right, there’s no difference between these two lines of code:

In [29]: d['c']
Out[29]: 3

In [30]: d.__getitem__('c')
Out[30]: 3

This means that if you define a new class, and you want instances of this class to be able to use square brackets, you just need to define __getitem__.  For example:

In [31]: class Foo(object):
...:         def __init__(self, x):
...:             self.x = x
...:         def __getitem__(self, index):
...:             return self.x[index]
...:

In [32]: f = Foo('abcd')

In [33]: f[2]
Out[33]: 'c'

See?  When we say f[2], that’s translated into f.__getitem__(2), which then returns “self.x[index]”.

The fact that square brackets are so generalized in this way means that Python can take advantage of them, even on user-created objects.

Requesting slices

You might also be familiar with slices. Slices are similar to individual indexes, except that they describe a range of indexes. For example:

In [46]: import string

In [47]: string.ascii_lowercase[10:20]
Out[47]: 'klmnopqrst'

In [48]: string.ascii_lowercase[10:20:3]
Out[48]: 'knqt'

As you can see, slices are either of the form [start:end+1] or [start:end+1:stepsize].  (If you don’t specify the stepsize, then it defaults to 1.)

Here’s a little tidbit that took me a long time to discover: You can get an IndexError exception if you ask for a single index beyond the boundaries of a sequence. But slices don’t have in such problems; they’ll just stop at the start or end of your string:

In [50]: string.ascii_lowercase[500]
---------------------------------------------------------------------------
IndexError Traceback (most recent call last)
<ipython-input-50-fad7a1a4ec3e> in <module>()
----> 1 string.ascii_lowercase[500]

IndexError: string index out of range


In [51]: string.ascii_lowercase[:500]
Out[51]: 'abcdefghijklmnopqrstuvwxyz'

How do the square brackets distinguish between an individual index and a slice? The answer: They don’t. In both cases, the __getitem__ method is being invoked. It’s up to __getitem__ to check to see what kind of value it got for the “index” parameter.

But wait: If we pass an integer or string (or even a tuple) to square brackets, we know what type will be passed along. What type is passed to our method if we use a slice?

In [55]: class Foo(object):
...:         def __getitem__(self, index):
...:             print(f"index = {index}, type(index) = {type(index)}")
...:


In [56]: f = Foo()

In [57]: f[100]
index = 100, type(index) = <class 'int'>

In [58]: f[5:100]
index = slice(5, 100, None), type(index) = <class 'slice'>

In [59]: f[5:100:3]
index = slice(5, 100, 3), type(index) = <class 'slice'>

Notice that in the first case, as expected, we get an integer. But in the second and third cases, we get a slice object. We can create these manually, if we want; “slice” is in the “bulitin” namespace, along with str, int, dict, and other favorites. And as you can see from its printed representation, we can call “slice” much as we do “range”, with start, stop, and step-size arguments.  I haven’t often needed or wanted to create slice objects, but you certainly could:

In [60]: s = slice(5,20,4)

In [61]: string.ascii_lowercase[s]
Out[61]: 'fjnr'

In [62]: string.ascii_uppercase[s]
Out[62]: 'FJNR'

In [63]: string.ascii_letters[s]
Out[63]: 'fjnr'

In [64]: string.punctuation[s]
Out[64]: '&*.<'

Curly braces — {}

Creating dicts

The classic way to create dictionaries (dicts) in Python is with curly braces. You can create an empty dict with an empty pair of curly braces:

In [65]: d = {}

In [66]: len(d)
Out[66]: 0

Or you can pre-populate a dict with some key-value pairs:

In [67]: d = {‘a’:1, ‘b’:2, ‘c’:3}

In [68]: len(d)
Out[68]: 3

You can, of course, create dicts in a few other ways. In particular, you can use the “dict” class to create a dictionary based on a sequence of two-element sequences:

In [69]: dict(['ab', 'cd', 'ef'])
Out[69]: {'a': 'b', 'c': 'd', 'e': 'f'}

In [70]: d = dict([('a', 1), ('b', 2), ('c', 3)])

In [71]: d
Out[71]: {'a': 1, 'b': 2, 'c': 3}

In [72]: d = dict(['ab', 'cd', 'ef'])

In [73]: d
Out[73]: {'a': 'b', 'c': 'd', 'e': 'f'}

But unless you need to create a dict programmatically, I’d say that {} is the best and clearest way to go. I remember reading someone’s blog post a few years ago (which I cannot find right now) in which it was found that {} is faster than calling “dict” — which makes sense, since {} is part of Python’s syntax, and doesn’t require a function call.

Of course, {} can also be used to create a dictionary via a dict comprehension:

In [74]: { one_number : one_number*one_number
...:       for one_number in range(10) }
...:
Out[74]: {0: 0, 1: 1, 2: 4, 3: 9, 4: 16, 5: 25, 6: 36, 7: 49, 8: 64, 9: 81}

In the above code, we create a dict of the number 0-9 (keys) and their values to the second power (values).

Remember that a dict comprehension creates one dictionary, rather than a list containing many dictionaries.

Create sets

I’ve become quite the fan of Python’s sets. You can think of sets in a technical sense, namely that they are mutable, and contain unique, hashable values. As of Python 3.6, they are stored in insertion order.

But really, it’s just easiest to think of sets as dictionaries without any values. (Yes, this means that sets are nothing more than immoral dictionaries.)  Whatever applies to dict keys also applies to the elements of a set.

We can create a set with curly braces:

In [75]: s = {10,20,30}

In [76]: type(s)
Out[76]: set

As you can see, the fact that there is no colon (:) between the name-value pairs allows Python to parse this code correctly, defining ‘s” to be a set, rather than a dict.

Nearly every time I teach about sets, someone tries to create an empty set and add to it, using set.add:

In [77]: s = {}

In [78]: s.add(10)
—————————————————————————
AttributeError Traceback (most recent call last)
<ipython-input-78-721f80ddfefc> in <module>()
—-> 1 s.add(10)

AttributeError: ‘dict’ object has no attribute ‘add’

The error indicates that “s” is a dict, and that dicts lack the “add” method. Which is fine, but didn’t I define “s” to be a set?

Not really: Dicts came first, and thus {} is an empty dict, not an empty set. If you want to create an empty set, you’ll need to use the “set” class:

s = set()

s.add(10)

This works just fine, but is a bit confusing to people starting off in Python.

I often use sets to remove duplicate entries from a list. I can do this with the “set” class (callable), but I can also use the “* argument” syntax when calling a function:

In [79]: mylist = [10, 20, 30, 10, 20, 30, 40]

In [80]: s = {*mylist}

In [81]: s
Out[81]: {10, 20, 30, 40}

Note that there’s a bit difference between {*mylist} (which creates a set from the elements of mylist) and {mylist} which will try to create a set with one element, the list “mylist”, and will fail because lists are unhashable.

Just as we have list comprehensions and dict comprehensions, we also have set comprehensions, which means that we can also say:

In [84]: mylist = [10, 20, 30, 10, 20, 30, 40]

In [85]: {one_number
...: for one_number in mylist}
...:
Out[85]: {10, 20, 30, 40}

str.format

Another place where we can use curly braces is in string formatting. Whereas Python developers used to use the printf-style “%” operator to create new strings, the modern way to do so (until f-strings, see below) was the str.format method. It worked like this:

In [86]: name = ‘Reuven’

In [87]: “Hello, {0}”.format(name)
Out[87]: ‘Hello, Reuven’

Notice that str.format returns a new string; it doesn’t technically have anything to do with “print”, although they are often used together. You can assign the resulting string to a new variable, write it to a file, or (of course) print it to the screen.

str.format looks inside of the string, searching for curly braces with a number inside of them. It then grabs the argument with that index, and interpolates it into the resulting string.  For example:

In [88]: 'First is {0}, then is {1}, finally is {2}'.format(10, 20, 30)
Out[88]: 'First is 10, then is 20, finally is 30'

You can, of course, mix things up:

In [89]: 'First is {0}, finally is {2}, then is {1}'.format(10, 20, 30)
Out[89]: 'First is 10, finally is 30, then is 20'

You can also repeat values:

In [90]: 'First is {0}. Really, first is {0}. Then is {1}'.format(10, 20, 30)
Out[90]: 'First is 10. Really, first is 10. Then is 20'

If you’ll be using each argument once and in order, you can even remove the numbers — although I’ve been told that this makes the code hard to read.  And besides, it means you cannot repeat values, which is sometimes annoying:

In [91]: 'First is {}, then is {}, finally is {}'.format(10, 20, 30)
Out[91]: 'First is 10, then is 20, finally is 30'

You cannot switch from automatic to manual numbering in curly braces (or back):

In [92]: 'First is {0}, then is {}, finally is {}'.format(10, 20, 30)
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-92-f00f3adf93eb> in <module>()
----> 1 'First is {0}, then is {}, finally is {}'.format(10, 20, 30)

ValueError: cannot switch from manual field specification to automatic field numbering

str.format also lets you use names instead of values, by passing keyword arguments (i.e., name-value pairs in the format of key=value):

In [93]: 'First is {x}, then is {y}, finally is {z}'.format(x=10, y=20, z=30)
Out[93]: 'First is 10, then is 20, finally is 30'

You can mix positional and keyword arguments, but I beg that you not do that:

In [94]: 'First is {0}, then is {y}, finally is {z}'.format(10, y=20, z=30)
Out[94]: 'First is 10, then is 20, finally is 30'

f-strings

As of Python 3.6, we have an even more modern way to perform string interpolation, using “f-strings”. Putting “f” before the opening quotes allows us to use curly braces to interpolate just about any Python expression we want — from variable names to operations to function/method calls — inside of a string:

In [99]: name = 'Reuven'

In [100]: f"Hello, {name}"
Out[100]: 'Hello, Reuven'

In [101]: f"Hello, {name.upper()}"
Out[101]: 'Hello, REUVEN'

In [102]: f"Hello, {name.split('e')}"
Out[102]: "Hello, ['R', 'uv', 'n']"

I love f-strings, and have started to use them in all of my code.  bash, Perl, Ruby, and PHP have had this capability for years; I’m delighted to (finally) have it in Python, too!

from __future__ import braces

Do you sometimes wish that you could use curly braces instead of indentation in Python? Yeah, you’re not alone.  Fortunately, the __future__ module is Python’s way of letting you try new features before they’re completely baked into your current Python version. For example, if you’re still using Python 2.7, you can say

from __future__ import division

and division will always return a float, rather than an integer, even if the two operands are integers.

So go ahead, try:

from __future__ import braces

(Yes, this is part of Python.  And no, don’t expect to be able to use curly braces instead of indentation any time soon.)

Enjoyed this article? Join more than 11,000 other developers who receive my free, weekly “Better developers” newsletter. Every Monday, you’ll get an article like this one about software development and Python:

Email Address

Name

Website

 

[Update] Python Lists ข้อมูลประเภทลิสต์ ในภาษาไพธอน | brackets คือ – NATAVIGUIDES

Python Lists ข้อมูลประเภทรายการ ในภาษาไพธอน

Python Collections

ข้อมูลประเภทคอลเล็คชั่น Collections ในภาษาไพธอน มีอยู่ 4 ประเภท ดังนี้

  • List ลิสต์ คือ ชุดข้อมูลแบบคอลเล็คชั่นที่มีการเรียงลำดับ และแก้ไขได้ สามารถมีสมาชิกซ้ำกันได้
  • Tuple ทูเพิ้ล คือ ชุดข้อมูลแบบคอลเล็คชั่นที่มีการเรียงลำดับเหมือนลิสต์ แต่ไม่สามารถแก้ไขได้ สามารถมีสมาชิกซ้ำกันได้
  • Set เซ็บ คือ ชุดข้อมูลแบบคอลเล็คชั่นที่ไม่มีการเรียงลำดับ ไม่มีการทำอินเด็กซ์ และมีสมาชิกซ้ำกันไม่ได้
  • Dictionary ดิกชันนารี คือ ชุดข้อมูลแบบคอลเล็คชั่นที่ไม่มีการเรียงลำดับ แต่แก้ไขได้ มีการทำอินเด็กซ์ และมีสมาชิกซ้ำกันไม่ได้

List ข้อมูลประเภทลิสต์ ในภาษาไพธอน

List ลิสต์ คือ ชุดข้อมูลแบบคอลเล็คชันที่มีการเรียงลำดับ และสามารถแก้ไขได้ โดยการสร้างข้อมูลแบบ List ในภาษาไพธอน จะใช้เครื่องหมาย square brackets [] ครอบชุดข้อมูล

ตัวอย่างการสร้างข้อมูลแบบ List

mylist = ["iPhone", "Samsung", "Vivo"]
print(mylist)

หรืออีกวิธีหนึ่ง เราสามารถสร้างลิสต์ได้โดยการใช้คอนสตรัคเตอร์ list() ซึ่งมีรูปแบบการใช้งานดังนี้

mylist = list(("Swift", "C++", "Python", "Java", "Kotlin", "HTML", "Objective-C", "C#"))

print(mylist)

การเข้าถึงข้อมูลประเภทลิสต์ List

เราสามารถเข้าถึงข้อมูล (Member) แต่ละตัวใน List ได้โดยการอ้างอิงหมายเลขอินเด็กซ์ไว้ภายในเครื่องหมาย [] square brackets โดยหมายเลขอินเด็กซ์จะเริ่มต้นที่ 0

ตัวอย่างการเข้าถึงข้อมูล (Member) ใน List

mylist = ["iPhone", "Samsung", "Vivo"]
print(mylist[1])

การระบุหมายเลขอินเด็กซ์ด้วยค่าตัวเลขที่ติดลบ จะหมายถึงการเริ่มต้นอินเด็กซ์จากข้อมูลตัวท้ายสุด คือเริ่มนับจากด้านหลังนั่นเอง เช่น [-1] จะหมายถึงข้อมูลสมาชิกตัวสุดท้าย (ตัวที่หนึ่งนับจากตัวสุดท้าย ก็คือตัวสุดท้ายนั่นเอง) [-2] จะหมายถึงข้อมูลสมาชิกลำดับที่สองนับจากตัวสุดท้าย เป็นต้น ดังตัวอย่าง

mylist = ["iPhone", "Samsung", "Vivo"]
print(mylist[-1])

เราสามารถเข้าถึงสมาชิกข้อมูลใน List โดยการระบุดินเด็กซ์เป็นช่วงตัวเลขได้ เช่น ต้องการข้อมูลลำดับที่ 3-6 ก็สามารถทำได้ โดยจะคืนค่ากลับมาเป็น List ชุดใหม่ ที่มีข้อมูลตามที่ระบุ

ตัวอย่างการเข้าถึงสมาชิกใน List โดยการระบุอินเด็กซ์เป็นช่วงตัวเลข

mylist = ["Swift", "Python", "Java", "Kotlin", "HTML", "Objective-C", "C#"]
print(mylist[3:6])
  • บรรทัดที่ 1 สร้างข้อมูลแบบ List ขึ้นมาใช้งาน
  • บรรทัดที่ 2 สั่งแสดงค่าของข้อมูลในลิสต์ โดยระบุอินเด็กซ์เป็น [3:6]

จากโค้ดตัวอย่าง จะได้ข้อมูลที่มีอินเด็กซ์เป็น 3 นั่นคือข้อมูลลำดับที่ 4 (เพราะนับเริ่มจาก 0) เป็นตัวแรก และข้อมูลลำดับที่ 6-1 นั่นคือข้อมูลที่มีอินเด็กซ์เป็น 5 เป็นตัวสุดท้าย

เราสามารถเข้าถึงข้อมูลใน List แบบช่วงข้อมูล โดยไม่ระบุอินเด็กซ์เริ่มต้นก็ได้เช่นกัน ซึ่งจะได้ข้อมูลตั้งแต่ลำดับแรกไปจนถึงข้อมูลลำดับที่อินเด็กซ์สิ้นสุดลบหนึ่ง ดังนี้

mylist = ["Swift", "Python", "Java", "Kotlin", "HTML", "Objective-C", "C#"]
print(mylist[:6])

แต่ถ้าระบุเฉพาะอินเด็กซ์เริ่มต้น ว่างอินเด็กซ์สิ้นสุดไว้ จะได้ข้อมูลต้องแต่ลำดับที่ระบุในอินเด็กซ์ไปจนถึงข้อมูลลำดับสุดท้าย

mylist = ["Swift", "Python", "Java", "Kotlin", "HTML", "Objective-C", "C#"]
print(mylist[2:])

การเข้าถึงข้อมูล List แบบกำหนดช่วงข้อมูล เราสามารถระบุเป็นค่าตัวเลขติดลบได้เช่นกัน

mylist = ["Swift", "Python", "Java", "Kotlin", "HTML", "Objective-C", "C#"]
print(mylist[-4:-1])

จากตัวอย่าง จะได้ข้อมูลตั้งแต่ลำดับที่ -4 (ลำดับที่ 4 นับจากจำดับสุดท้าย คือ Kotlin) ไปจนถึงข้อมูลลำดับที่อยู่ก่อนลำดับ -1 (คือลำดับ -2 ซึ่งหมายถึงข้อมูลลำดับที่ 2 นับจากลำดับสุดท้าย นั่นก็คือ Objective-C นั่นเอง)

การเปลี่ยนแปลงข้อมูลในลิสต์ List

เราสามารถเปลี่ยนแปลงข้อมูลในลิสต์ List ได้ โดยระบุอินเด็กซ์ของลิสต์ แล้วกำหนดค่าใหม่ลงไปได้เลย

ตัวอย่างการเปลี่ยนแปลงข้อมูลใน List

mylist = ["Swift", "Python", "Java", "Kotlin", "HTML", "Objective-C", "C#"]
mylist[0] = 'C++'
print(mylist)

บรรทัดที่ 2 เข้าถึงข้อมูลในลิสต์โดยระบุอินเด็กซ์ 0 ซึ่งหมายถึงข้อมูลลำดับที่ 1 และกำหนดค่าใหม่ลงไป ข้อมูลเดิมเป็น Swift ข้อมูลใหม่เป็น C++

การใช้ลูป Loop เข้าถึงข้อมูลใน List

เราสามารถใช้ลูป for เข้าถึงข้อมูลใน List ได้ ดังตัวอย่าง

mylist = ["Swift", "Python", "Java", "Kotlin", "HTML", "Objective-C", "C#"]
for x in mylist:
    print(x) 

จากโค้ดด้านบน เป็นการใช้ลูป for เข้าถึงสมาชิกใน List แล้วแสดงผลออกมาทีละลำดับดับ

การตรวจสอบข้อมูลในลิสต์ List

เราสามารถตรวจสอบว่ามีข้อมูลที่เราต้องการอยู่ในลิสต์ List หรือไม่ โดยใช้คีย์เวิร์ด in

mylist = ["Swift", "Python", "Java", "Kotlin", "HTML", "Objective-C", "C#"]
if "Python" in mylist:
    print("Yes, 'Python' is in the list")

บรรทัดที่ 2 ใช้คีย์เวิร์ด in ตรวจสอบว่ามีข้อมูลตามที่เราระบุอยู่ในลิสต์หรือไม่

การตรวจสอบจำนวนสมาชิกในลิสต์ List

เราสามารถตรวจสอบจำนวนสมาชิกทั้งหมดใน List ได้โดยการใช้ฟังก์ชัน len() ดังนี้

mylist = ["Swift", "Python", "Java", "Kotlin", "HTML", "Objective-C", "C#"]
print(len(mylist)) #7

ฟังก์ชัน len() จะคืนค่ากลับมาเป็นจำนวนสมาชิกทั้งหมดในลิสต์

การเพิ่มสมาชิกใน List

เราสามารถเพิ่มข้อมูลหรือสมาชิกใหม่เข้าไปใน List ได้ โดยใช้เมธอด append() โดยข้อมูลที่เพิ่มเข้าไปใหม่จะถูกเพิ่มต่อท้ายข้อมูลลำดับสุดท้ายในลิสต์ ดังนี้

mylist = ["Swift", "Python", "Java", "Kotlin", "HTML", "Objective-C", "C#"]
mylist.append("C++")
print(mylist)

บรรทัดที่ 2 ใช้เมธอด append() เพิ่มข้อมูลใหม่ในลิสต์

ถ้าต้องการแทรกข้อมูลใหม่เข้าไปในลิสต์โดยการระบุตำแหน่งอินเด็กซ์ สามารถทำได้โดยการใช้เมธอด insert() โดยมีรูปแบบการใช้งานดังนี้

insert(index, data)

  • index คือตำแหน่งที่ต้องการแทรกข้อมูลในลิสต์
  • data คือข้อมูลที่ต้องการแทรกในลิสต์

ตัวอย่างการใช้งานเมธอด insert()

mylist = ["Swift", "Python", "Java", "Kotlin", "HTML", "Objective-C", "C#"]
mylist.insert(1, "C++")
print(mylist)

บรรทัดที่ 2 ใช้เมธอด insert() แทรกข้อมูล “C++” โดยระบุอินเด็กซ์เป็น 1 ซึ่งก็คือตำแหน่งที่ 2 ในลิสต์นั่นเอง

การลบข้อมูลออกจากลิสต์ List

เราสามารถลบข้อมูลประเภทลิสต์ List ได้หลายวิธี ดังนี้

ลบข้อมูลด้วยเมธอด remove()

เราสามารถลบข้อมูลออกจากลิสต์โดยใช้เมธอด remove() โดยมีวิธีใช้งานดังนี้

mylist = ["Swift", "C++", "Python", "Java", "Kotlin", "HTML", "Objective-C", "C#"]
mylist.remove("C++")
print(mylist)

บรรทัดที่ 2 ใช้เมธอด remove() ลบข้อมูลออกจากลิสต์ โดยระบุข้อมูลที่ต้องการลบ

ลบข้อมูลโดยใช้เมธอด pop()

เราสามารถใช้เมธอด pop() ลบข้อมูลลิสต์ โดยการระบุอินเด็กซ์ที่ต้องการลบ (หรือถ้าไม่ระบุอินเด็กซ์ จะเป็นการลบข้อมูลตัวสุดท้าย)

ตัวอย่างการใช้เมธอ pop() แบบระบุอินเด็กซ์

mylist = ["Swift", "C++", "Python", "Java", "Kotlin", "HTML", "Objective-C", "C#"]
mylist.pop(1)
print(mylist)

จากตัวอย่าง ใช้เมธอด pop() โดยระบุอินเด็กซ์เป็น 1 ข้อมูลลำดับที่ 2 จะถูกลบออกไป

ตัวอย่งการใช้เมธอด pop() แบบไม่ระบุอินเด็กซ์

mylist = ["Swift", "C++", "Python", "Java", "Kotlin", "HTML", "Objective-C", "C#"]
mylist.pop()
print(mylist)

เมื่อใช้เมธอด pop() โดยไม่ระบุอินเด็กซ์ ข้อมูลลำดับสุดท้ายจะถูกลบออกไป

ลบข้อมูลโดยใช้คีย์เวิร์ด del

เราสามารถใช้คีย์เวิร์ด del ลบข้อมูลที่ต้องการออกจาก List โดยระบุอินเด็กซ์ข้อมูลที่ต้องการลบ โดยมีวิธีการใช้งานดังนี้

mylist = ["Swift", "C++", "Python", "Java", "Kotlin", "HTML", "Objective-C", "C#"]
del mylist[1]
print(mylist)

บรรทัดที่ 2 ใช้คีย์เวิร์ด del ตามด้วยชื่อตัวแปร List โดยมีการระบุอินเด็กซ์ไว้ใน [] จะเป็นการลบข้อมูลในอินเด็กซ์ที่ระบุ

หรือเราสามารถลบข้อมูล List ทิ้งเลยก็ได โดยการใช้คีย์เวิร์ด del ตามด้วยชื่อตัวแปร List ดังนี้

mylist = ["Swift", "C++", "Python", "Java", "Kotlin", "HTML", "Objective-C", "C#"]
del mylist

โค้ดบรรทัดที่ 2 จะเป็นการลบลิสต์ทิ้งไป

ลบข้อมูลด้วยเมธอด clear()

เราสามารถลบข้อมูลทั้งหมดในลิสต์ด้วยเมธอด clear() ซึ่งจะเป็นการลบสมาชิกทั้งหมดในลิสต์

mylist = ["Swift", "C++", "Python", "Java", "Kotlin", "HTML", "Objective-C", "C#"]
mylist.clear()
print(mylist)

บรรทัดที่ 2 ใช้เมธอด clear() ลบข้อมูลทั้งหมดในลิสต์

การคัดลอกลิสต์

เราสามารถคัดลอกหรือทำสำเนารายการลิสต์ List ได้หลายวิธี ดังนี้

คัดลอกลิสต์ด้วยเมธอด copy()

เราสามารถใช้เมธอด copy() เพื่อทำการคัดลอกลิสต์ได้ โดยมีวิธีใช้งานดังนี้

mylist = ["Swift", "C++", "Python", "Java", "Kotlin", "HTML", "Objective-C", "C#"]
yourlist = mylist.copy()
print(mylist)
print(yourlist)

บรรทัดที่ 2 สร้างตัวแปร yourlist ขึ้นมาใหม่ โดยทำการคัดลอกข้อมูลในตัวแปร mylist ด้วยเมธอด copy()

คัดลอกลิสต์ด้วยเทธอด list()

อีกวิธีที่สามารถคัดลอกลิสต์ได้ ก็คือ การใช้เมธอด list()

mylist = ["Swift", "C++", "Python", "Java", "Kotlin", "HTML", "Objective-C", "C#"]
yourlist = list(mylist)
print(mylist)
print(yourlist)

การจอยลิสต์ List

เราสามารถรวมลิสต์หลาย ๆ ลิสต์เข้าด้วยกันได้หลายวิธี และวิธีที่ง่ายที่สุดคือการใช้โอเปอเรเตอร์ +

mylist = ["Swift", "C++", "Python", "Java", "Kotlin", "HTML", "Objective-C", "C#"]
yourlist = ["One", "Two", "Three", "Four", "Five", "Six", "Seven"]

ourlist = mylist + yourlist

print(ourlist)
#ourlist will be ['Swift', 'C++', 'Python', 'Java', 'Kotlin', 'HTML', 'Objective-C', 'C#', 'One', 'Two', 'Three', 'Four', 'Five', 'Six', 'Seven']

อีกวิธีคือการวนลูปอ่านข้อมูลในลิสต์ต้นทางแล้วเอาไปต่อท้ายลิสต์ต้นทางทีละลำดับ โดยใช้เมธอด append() ดังตัวอย่าง

mylist = ["Swift", "C++", "Python", "Java", "Kotlin", "HTML", "Objective-C", "C#"]
yourlist = ["One", "Two", "Three", "Four", "Five", "Six", "Seven"]

for x in yourlist:
  mylist.append(x)

print(mylist)
#mylist will be ['Swift', 'C++', 'Python', 'Java', 'Kotlin', 'HTML', 'Objective-C', 'C#', 'One', 'Two', 'Three', 'Four', 'Five', 'Six', 'Seven']

วิธีที่ง่าย ๆ อีกวิธีสำหรับการรวมลิสต์ 2 รายการเข้าด้วยกันคือ การใช้งานเมธอด extend() โดยมีรูปแบบการใช้งานดังนี้

mylist = ["Swift", "C++", "Python", "Java", "Kotlin", "HTML", "Objective-C", "C#"]
yourlist = ["One", "Two", "Three", "Four", "Five", "Six", "Seven"]

mylist.extend(yourlist)

print(mylist)

#mylist will be ['Swift', 'C++', 'Python', 'Java', 'Kotlin', 'HTML', 'Objective-C', 'C#', 'One', 'Two', 'Three', 'Four', 'Five', 'Six', 'Seven']

เมธอดของข้อมูลประเภท List

เมธอดที่น่าสนใจสำหรับข้อมูลประเภท List มีดังนี้

ชื่อเมธอดคำอธิบายappend()เพิ่มเอลิเมนต์ต่อท้าย Listclear()ลบเอลิเมนต์ใน Listcopy()คัดลอก Listcount()นับจำนวนข้อมูลที่ระบุที่ปรากฏใน Listextend()เพิ่มเอลิเมนต์หรือข้อมูลประเภทรายการอื่น ๆ ต่อท้าย Listindex()ค้นหาข้อมูลที่ระบุแล้วคืนค่ากลับมาเป็น index ของข้อมูลนั้นที่เจอครั้งแรกinsert()แทรกเอลิเมนต์เข้าไปใน List ณ ตำแหน่งที่ระบุpop()ลบเอลิเมนต์ ณ ตำแหน่งที่ระบุremove()ลบเอลิเมนต์ที่มีค่าตามที่ระบุreverse()เรียงเอลิเมนต์กลับด้านsort()จัดเรียงเอลิเมนต์ใน List


Câu đảo ngữ trong tiếng Anh và các loại câu đảo ngữ | IELTS FIGHTER


CÂU ĐẢO NGỮ CÁC LOẠI CÂU ĐẢO NGỮ BÀI TẬP THỰC HÀNH CHI TIẾT
👉 Link full: http://bit.ly/35ZjpYl
Câu đảo ngữ được hiểu đơn giản là câu có một thành phần nào đó được đặt lên vị trí đầu câu, làm cho cấu trúc thông thường bị đảo lộn. Thành phần được đảo lên đầu câu có thể là trạng từ, phó từ, trợ động từ. Sau khi làm thao tác đảo ngữ, các thành phần khác của câu cũng sẽ có sự thay đổi.
Chúng ta sử dụng cấu trúc đảo ngữ khi muốn nhấn mạnh vào một sự việc hay một chủ thể nào đó trong câu. Cấu trúc đảo ngữ vừa có thể xuất hiện ở văn nói thường ngày hoặc văn viết trang trọng.
Hãy cùng học câu đảo ngữ với Ms.Jenny nhé!

Subscribe IELTS Fighter nhận thông báo video mới nhất để không bỏ lỡ các video bài học thú vị, ngay tại link này nhé:
https://www.youtube.com/IELTSFighter

Tham khảo thêm video từ vựng hay khác:
👉 Bảng phiên âm IPA và cách phát âm chuẩn nhất: http://bit.ly/32cqu5j
👉 Mệnh đề điều kiện bài tập công thức chi tiết: http://bit.ly/2LeuJry
👉 IELTS Speaking band 7+ |New Sample Test with subtitles: http://bit.ly/2JG8n1y

Theo dõi lộ trình học tập vô cùng đầy đủ để các bạn có thể học IELTS Online tại IELTS Fighter qua các bài viết sau:
💜 Lộ trình tự học 0 lên 5.0: http://bit.ly/2kJtIxy
💜 Lộ trình từ học 5.0 lên 6.5: http://bit.ly/2lVWV8H

Xem thêm các khóa học theo lộ trình tại đây nhé:
👉 KHÓA HỌC IELTS MỤC TIÊU 5.05.5: http://bit.ly/2LSuWm6
👉 KHÓA HỌC BỨT PHÁ MỤC TIÊU 6.06.5: http://bit.ly/2YwRxuG
👉 KHÓA HỌC TRỌN GÓI 7.0 IELTS CAM KẾT ĐẦU RA: http://bit.ly/331M26x

IELTS Fighter The leading IELTS Training Center in Vietnam
Branch 1: 254 Hoang Van Thai, Thanh Xuan, HN; Tel: 0462 956 422
Branch 2: 44 Tran Quoc Hoan, Cau Giay, HN; Tel: 0466 862 804
Branch 3: 410 Xã Đàn, Đống Đa, Hà Nội; Tel: 0466 868 815
Branch 4: 350, 3/2 Street, 10 District, HCM; Tel: 0866 57 57 29
Branch 5: 94 Cộng Hòa, Tân Bình, HCM; Tel: 02866538585
Branch 6: 85 Điện Biên Phủ, Bình Thạnh, HCM; Tel: 028 6660 4006
Branch 7: 233 Nguyễn Văn Linh, Thanh Khê, Đà Nẵng; Tel: 0236 357 2009
Branch 8: L39.6 khu dân cư Cityland Phan Văn Trị Q.Gò Vấp TPHCM. SĐT: 028 22295577
Branch 9: 376 Nguyễn Văn Cừ Long Biên Hà Nội. SĐT: 02466619628
Branch 10: 18 LK6C Nguyễn Văn Lộc Hà Đông Hà Nội. SĐT 02466619625
Branch 11: A11 Bà Hom, Phường 13, Quận 6, HCM. SĐT: 028 2244 2323
Branch 12: 254 Tôn Đức Thắng, P. Hòa Minh, Q. Liên Chiểu, Đà Nẵng. SĐT: 0236 629 57 57
Branch 13: 44 Nguyễn Hoàng, (gần bx Mỹ Đình), HN. SĐT 02466593161
Cơ sở 14: 66B Hoàng Diệu 2 Thủ Đức. SĐT: 02822 423 344
Cơ sở 15: 48 Trung Hòa, Cầu Giấy HN SĐT: 02462910811
Cơ sở 16: 44H1 (343) Nguyễn Ánh Thủ, Quận 12 HCM . SĐT: 02 822 406 633
Cơ sở 17: 141143 Nguyễn Thị Thập KĐT mới Him Lam P. Tân Hưng Quận 7 Hotline: 028 22492233

🍓Website: http://ieltsfighter.com/
🍓Fanpage:https://www.facebook.com/ielts.fighter
🍓Group:https://www.facebook.com/groups/ieltsfighter.support/
🍓Holine: 0903 411 666
câu_đảo_ngữ IELTSFIGHTER

นอกจากการดูบทความนี้แล้ว คุณยังสามารถดูข้อมูลที่เป็นประโยชน์อื่นๆ อีกมากมายที่เราให้ไว้ที่นี่: ดูความรู้เพิ่มเติมที่นี่

Câu đảo ngữ trong tiếng Anh và các loại câu đảo ngữ | IELTS FIGHTER

How To Build A Shed By Yourself All STEPS 10×16


How to build a shed by yourself diy all steps included start to finish. A lot of the same steps can be used for a cabin, tiny house, greenhouse, playhouse or any small building. Ever dream of a man cave or she shed to work in or play in? These buildings are so handy to have, you could even live in one! This one is rustic rough cut board and batten. I love how it turned out!
http://bit.ly/RuggedWood here you can get the RUGGED wood treatment for the siding.
I LOVE how it turned out on my shed siding!!

http://bit.ly/ShedDoorHandleLock here is the locking handle I used.
http://bit.ly/HeavyDutyHinges here are the heavy duty black hinges.
http://bit.ly/DoorBarrelBoltLatch here are the barrel bolt latches for the door that mostly stays shut.
http://bit.ly/CarriageBolts here you can check for carriage bolts but you may be better off getting them at a local place.
http://bit.ly/CordlessTools here you can check out some nice cordless tools if you want some to make the job easier.
http://bit.ly/TapeMeasureMax if you need a good tape measure these are my favorite.
http://bit.ly/Window24x24 here you can find a pretty cheap window as well. Otherwise I would recommend the Lowes one.
There’s probably more I could add but all I can think of for now.
http://www.csgnetwork.com/foundationsquarecalc.html here is the one calculator I liked for squaring the building.
https://www.blocklayer.com/squarelayout.aspx here is a second one.
Here is the video timeline if you want to skip ahead since I know it’s a long video. You can’t have a very detailed shed build without it being long. 😉
0:00 Intro
1:18 getting skids leveled
4:11 floor joists
10:22 plywood floor
11:46 laying out trusses
18:14 building trusses
18:54 building walls
26:24 setting trusses
31:56 sheathing roof
37:32 roof underlayment
38:39 housewrap
40:38 overhang framing
41:48 drip edge
42:49 steel roof prep
47:52 ridge cap
49:25 staining siding with RUGGED
52:24 soffit and facia
56:36 gable trim
1:01:35 siding
1:03:31 framing front doors
1:08:11 window install
1:09:33 trim and battens
1:13:18 door latch / lock install
1:16:11 shed is done! look inside
1:17:12 total cost breakdown
1:18:19 let me know how you did on your project, post pictures on Instagram and tag me in them. Instagram https://www.instagram.com/smarteasydiy/ https://www.instagram.com/ruggedwoodtreatment/
Here is the cost breakdown for the shed.
Lumber, concrete blocks and roofing underlayment $1000
Rough cut lumber $700
Steel roofing $450
RUGGED Wood Treatment stain $70
Misc $80
$2300 total
here is the complete material list that I used.
8 4x8x16 solid concrete blocks
1 24×24 window
1 roll roofing underlayment
2 bags of RUGGED wood treatment stain
5 sheets 3/4 treated plywood for floor
10 sheets 5/8 plywood for roof
2 4x6x16 treated skids
2 2x6x16 treated rim joists
13 2x6x10 treated floor joists
64 2x4x925/8 pre cut studs for walls and and truss top chords. They are long enough to reach and cheaper than full 8’
15 2x4x8 door framing and misc
4 2x4x16 wall plates
15 2x4x10 wall plates, truss bottom chords, and misc
Rough cut lumber I used.
54 1x10x8
21 1x10x12
5 1x6x8
9 1x6x10
18 1x6x16
14 1x4x10
12 1x4x12
Get social with me.
Instagram https://www.instagram.com/smarteasydiy/
Facebook https://www.facebook.com/smarteasydiy/
Twitter https://twitter.com/SmartEasyDIY

How To Build A Shed By Yourself All STEPS 10x16

ทำไม Binance ยกเลิกบริการภาษาไทย กระทบใครบ้าง?


ถามทันที คริปโต ทำไม Binance ยกเลิกบริการภาษาไทย แล้วกระทบใครบ้าง?
ถามอีก กับ พี่บิท คุณศุภกฤษฎ์ บุญสาตร์ นายกสมาคมสินทรัพย์ดิจิทัลไทย bitcast
และพี่ซันเจ คุณสัญชัย ปอปลี Cofounder, Cryptomind Asset CEO
โดย อิก บรรพต ธนาเพิ่มสุข, AFPT ที่ปรึกษาการเงิน
สัมภาษณ์วันที่ 13 พ.ย. 2564

ทุกเรื่องที่นักลงทุนต้องรู้ ติดตามกันได้ในทุกช่องทางคร้าบ:
Youtube: http://bit.ly/TAMEIG_Youtube
Clubhouse: https://bit.ly/3mmJgVA
Line Official: http://bit.ly/TAMEIG_LINE
Twitter: https://bit.ly/2UFAczy

ทำไม Binance ยกเลิกบริการภาษาไทย กระทบใครบ้าง?

รากฟันเทียม คือ อะไร | Bangkok Smile Dental Clinic


รากฟันเทียม คือ อะไร | Bangkok Smile Dental Clinic

etrailer | Trailer Hitch Installation – 2016 Jeep Patriot – Curt


Click for more info and reviews of this Curt Trailer Hitch:\r
https://www.etrailer.com/TrailerHitch/Curt/C13081.html\r
Check out some similar Trailer Hitch options:\r
https://www.etrailer.com/fitguide.htm\r
\r
Search for other popular Jeep Patriot parts and accessories:\r
https://www.etrailer.com/vehicle/2016/Jeep/Patriot\r
\r
https://www.etrailer.com\r
Don’t forget to subscribe!\r
https://www.youtube.com/user/etrailertv\r
\r
Full transcript: https://www.etrailer.com/tvinstalltrailerhitch2016jeeppatriotc13081.aspx\r
Today on our 2016 Jeep Patriot, we’re going to take a look at and also show you how to install the Curt customfit class III trailer hitch receiver. This offers a 2\”x2\” opening. It’s part number is C13081. Here’s what our hitch is going to look like installed on the vehicle. As you can see, it’s a nice, clean look. The majority of the crosstube is going to be behind the rear fascia. You’re just going to have the receiver tube opening that comes out here. \r
\r
You’ll see around the end of that, we’ve got a flush reinforcement collar. It gives it a nice, clean look. Then our safety chain connection points down here, these are made out of a rolled steel stock material. Plenty of an opening there for you to connect whatever type of chains that you might need to. You’ll see our 5/8 diameter hitch pin hole there.\r
\r
It’s going to give us plenty of room on each side for whatever class III accessory we might choose to hold our items in place. We have antirattle bolts, we have locking hitch pins, standard hitch pins, whatever you might need. Now, the hitch itself is going to have a 400 pound tongue weight rating, so that’s the maximum downward force we’ll be able to put here at the receiver tube opening. It’s going to give us a 4,000 pound gross trailer weight rating. That would be the total weight of your trailer and anything that you we’re going to load up on it. Now, you do want to check the owner’s manual of the Patriot.\r
\r
You want to see what its tow ratings are and go off of whichever of those numbers are the lowest. The hitch is not rated for use with weight distribution, so you won’t want to use any spring bars or weight distribution setup on it. The Curt also recommends the use of a stabilization strap any time you’re going to be using nonwheeled loads, so something like a cargo carrier or a bike rack, you can use one of the stabilization straps. Now, a few measurements that’ll be helpful when it comes time to select your ball mount, bike rack, or hitch cargo carrier will be from the ground to the inside top edge of our receiver tube opening, we’ve got about 133/4\”. Then from the center of our hitch pin hole to the outermost edge of our bumper, it’s about 6. Now, to begin our installation, we’re going to need to remove the 4 pushpin fasteners that go across the rear of the vehicle. There should be a little gap in there that’ll allow you to get either a screwdriver or a trim panel tool in there.\r
\r
Kind of get it started. You just want to work the center portion out and then the larger portion. The next step’s going to be lowering our exhaust down. We’ve got a couple of hangers there we’re going to remove. We’ve got one located here just above the tailpipe. Just spray these down with a little bit of spray lubricant; that’ll help us get them off. Then if we come directly, kind of cattycorner to that here to the back side, we’ve got a second one. Now, to remove these, typically what you’re going to need is a pry bar or maybe a big screwdriver. Just get on the back side there and kind of pry outward. All right, and that should get that down far enough for us to get to the heat shield, which we’re going to temporarily remove by taking out the 4 nuts that hold it in place. Now we’ll just pull down on that so we can get it set aside. Now we’re ready to grab our bolts. We want to place a flat washer on those. We’ve got an attachment point here on the passenger’s side. It’s pretty much going to be right above where that exhaust hanger was in the frame rail. You’ll see our bolts are going to go in. You can see how they pass all the way through there. You want to bring those back to where they’re about even with the frame. We’re going to place our hitch up and then slide those through to hold it in position. Now we’re ready to get our hitch raised up into position. You just need to work it up over the exhaust there. Then we’ll push those bolts in so they go through the side brackets in the hitch. Now, that’s going to help act as our guide. We can rotate that up and figure out exactly where we need to trim that fascia. Before we do that, we do want to start one of our 1/2\” flange nuts, and we’re going to use those to prevent our bolts from coming out or our hitch from falling off. Now, we’re going to rotate our hitch up. We want to mark the outside of the hitch there on each side. Those are going to act as our marks for trimming up. Then we just need to look in our instructions and determine how far up they

etrailer | Trailer Hitch Installation - 2016 Jeep Patriot - Curt

นอกจากการดูบทความนี้แล้ว คุณยังสามารถดูข้อมูลที่เป็นประโยชน์อื่นๆ อีกมากมายที่เราให้ไว้ที่นี่: ดูบทความเพิ่มเติมในหมวดหมู่LEARN FOREIGN LANGUAGE

ขอบคุณมากสำหรับการดูหัวข้อโพสต์ brackets คือ

Leave a Reply

Your email address will not be published. Required fields are marked *