Created at 1pm, Dec 29
benjaminSoftware Development
0
Python Basics
-HrFPsy8hQ2Ans4UlES1EJFzaNzpFW0T8i7U8cw2dr8
File Type
PDF
Entry Count
145
Embed. Model
jina_embeddings_v2_base_en
Index Type
hnsw

A starter pack for anyone who is tarting to learn python programming.

The Assignment Operator An operator is a symbol, such as +, that performs an operation on one or more values. For example, the + operator takes two numbers, one to the left of the operator and one to the right, and adds them together. 50 3.3. Create a Variable Values are assigned to variable names using a special symbol called the assignment operator (=) . The = operator takes the value to the right of the operator and assigns it to the name on the left. Lets modify the hello_world.py le from the previous section to assign some text in a variable before printing it to the screen: >>> greeting = "Hello, World" >>> print(greeting)
id: f1823d977ed62f1ce8f070af72035a29 - page: 51
Hello, world On the rst line, you create a variable named greeting and assign it the value "Hello, World" using the = operator. print(greeting) displays the output Hello, World because Python looks for the name greeting, nds that its been assigned the value "Hello, World", and replaces the variable name with its value before calling the function. If you hadnt executed greeting = "Hello, World" before executing print(greeting), then you would have seen a NameError like you did when you tried to execute print(Hello, World) in the previous section.
id: 9021126a9ae49875d6209e64560da084 - page: 52
Note Although = looks like the equals sign from mathematics, it has a dierent meaning in Python. This distinction is important and can be a source of frustration for beginner programmers. Just remember, whenever you see the = operator, whatever is to the right of it is being assigned to a variable on the left. Variable names are case sensitive, so a variable named greeting is not the same as a variable named Greeting. For instance, the following code produces a NameError: 51 3.3. Create a Variable >>> greeting = "Hello, World" >>> print(Greeting) Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name 'Greeting' is not defined If you have trouble with an example in this book, double-check that every character in your codeincluding spacesmatches the example exactly. Computers have no common sense, so being almost correct isnt good enough!
id: 40a77beed4b88d0b39584271174976da - page: 52
Rules for Valid Variable Names Variable names can be as long or as short as you like, but there are a few rules that you must follow. Variable names may contain uppercase and lowercase letters (AZ, az), digits (09), and underscores (_), but they cannot begin with a digit. For example, each of the following is a valid Python variable name: string1 _a1p4a list_of_names The following arent valid variable names because they start with a digit: 9lives 99_balloons 2beOrNot2Be In addition to English letters and digits, Python variable names may contain many dierent valid Unicode characters. Unicode is a standard for digitally representing characters used in most of the worlds writing systems. That means variable names can contain letters from non-English alphabets, such as decorated letters 52 3.3. Create a Variable
id: 72574177fe5f1c156910a0d680210547 - page: 53
How to Retrieve?
# Search

curl -X POST "https://search.dria.co/hnsw/search" \
-H "x-api-key: <YOUR_API_KEY>" \
-H "Content-Type: application/json" \
-d '{"rerank": true, "top_n": 10, "contract_id": "-HrFPsy8hQ2Ans4UlES1EJFzaNzpFW0T8i7U8cw2dr8", "query": "What is alexanDRIA library?"}'
        
# Query

curl -X POST "https://search.dria.co/hnsw/query" \
-H "x-api-key: <YOUR_API_KEY>" \
-H "Content-Type: application/json" \
-d '{"vector": [0.123, 0.5236], "top_n": 10, "contract_id": "-HrFPsy8hQ2Ans4UlES1EJFzaNzpFW0T8i7U8cw2dr8", "level": 2}'