## python – Text Wrap using return and print

We give you a chain S and a width w.
Your task is to wrap the string in a paragraph of width w.
Input format
The first line contains a string, S.
The second line contains the width, w.

Example of input
ABCDEFGHIJKLIMNOQRSTUVWXYZ
4
Example of exit
A B C D
E F G H
IJKL
IMNO
QRST
UVWX
YZ

I tried the code, but I did not get the required result. As 2 additional lines enter the exit.
Note: the last 4 lines of the code are immutable (not to be modified)

``````import textwrap

def wrap(string, max_width):
y=max_width
z=0

for i in range(0,len(string),y):
print(string(0+z:y+z))
z+=max_width

if __name__ == '__main__':
string, max_width = input(), int(input())
result = wrap(string, max_width)
print(result)
``````

## python – Implicit recursion when assigning a return function to a variable?

Hi guys, I started studying Python and I had a slightly strange behavior for me. It's like this: I have a file test.py which contains functions. In another file, exemple1.py I've imported this and other files as modules. In the archives exemple1.py I created 3 functions (func1, func2, func3). In func1 I pass in parameter: a list and the reference of a function defined in test.py.
In func1 I attributed the return of func2 to 3 variables, all with the same parameters for func2:

``````a = func2(x_best,h,0.1)
b = func2(x_best,h,0.1)
c = func2(x_best,h,0.1)
``````

However, the variables receive the values ​​as if func2 was run 3 times, always receiving as his own return from the previous run. Another thing I realized is that if I declare only two variables, the values ​​assigned to the variables are the equivalent of two executions of the variable. func2 taking as parameters the return of the previous run. My question is: is there an implicit recursion based on the number of variables I declare ??? I am quite confused by these results.

Below, I will specify the codes of what I'm trying to say. I will omit certain functions because they do not interfere with the problem. Thank you in advance for your help.

test.py

``````#!/usr/bin/env python
# -*- coding: utf-8 -*-
import math
import json
from openpyxl import *
from random import *
from math import *

def beale ():
return (1.5 - ponto(0)+ponto(0)*ponto(1))**2+(2.25-ponto(0)+ponto(0)*ponto(1)**2)**2+(2.625-ponto(0)+ponto(0)*ponto(1)**3)**2

def tgo(problema):

pontos = points_generator(100)
matriz = t_matriz_generator(pontos, problema)
indices = list()
melhores = list()
for i in range(len(matriz)):
j = 0
while (j < 4):
if(matriz(i)(j) < 0):
break
if (j >= 3):
indices.append(i)
j += 1
for a in indices:
melhores.append(pontos(a))
return melhores, problema
``````

exemple1.py

``````from random import *
from teste import *
import math
import time

def LineSearch(Xtrial, Xbest, d, h):
while (problema(Xtrial) < problema(Xbest)):
Xbest = Xtrial
h *= 2
Xtrial(i)=trial_search(Xbest,h,d)
return Xbest, h

def trial_search(ponto, h, d):
FinalPoint = ponto
for i in range(len(FinalPoint)):
FinalPoint(i) = (FinalPoint(i)+h)*d
if (problema(FinalPoint) < problema(ponto)):
continue
else:
FinalPoint(i) = ponto(i)
return FinalPoint

def Unirandi(x0, problema):
tol = 0.0001
h = 1.0
fails = 0
x_best = x0

a = trial_search(x_best,h,0.1)
b = trial_search(x_best,h,0.1)
c = trial_search(x_best,h,0.1)

p, problema = tgo(beale)
Unirandi((-0.05338583452963963, 4.311503781033389),problema)
``````

The values ​​for the variables are:

``````a -> (0.11094661416547036, 0.11531150378103339)
b -> (0.11094661416547036, 0.11531150378103339)
c -> (0.11094661416547036, 0.11531150378103339)
``````

If I only declare

``````a = trial_search(x_best,h,0.1)
b = trial_search(x_best,h,0.1)
``````

as a result I have:

``````a -> (0.10946614165470361, 0.15311503781033392)
b -> (0.10946614165470361, 0.15311503781033392)
``````

and finally if I just declare

``````a = trial_search(x_best,h,0.1)
``````

following

``````a -> (0.09466141654703604, 0.531150378103339)
``````

Hello WHT,

## Web Development – The Most Effective Way to Return Results to a Web Page with a Sorting Algorithm

Recently, I created a search page where the user can enter his search criteria and the server will use a scoring and sorting algorithm to return the "best" results first. The flow of current is as follows:

1. The user enters his search criteria.
2. The server-side code (PHP) creates a query to retrieve all the results that match this criteria.
3. The server uses a function to assign a "score" to each result.
4. The server scans all the results and ranks the results from the highest score to the lowest score using a "quick sort" algorithm.
5. The table is spliced ​​in order to take only the 15 best results. These are then passed to the web page to be displayed as results.

At the bottom of the results is a "Load More" button. When you click on it, the process is identical to the one described above (via AJAX), but instead shifts the array to a certain amount, but again, it only takes the following 15 results and returns them to the web page in JSON format, before adding them to the results. via JavaScript.

After review, this seems really ineffective. I ask the database to match the results each time the page is loaded or the user clicks "Load more", noting then sorting each one of them, only to take than 15 of these results.

Of course, I have to query all the corresponding results in order to provide the "best" results for the whole table, rather than on this one.

I thought maybe a better way to do it is to sort and score the entire table via a cronjob and give each line a "position ranking". When the user comes to load the web page, he can simply query the database to obtain the corresponding results in the same SQL statement, classify them in the "position evaluation" column, and then limit the results to 15 ( and use offset for the AJAX request). .

Would this process be much faster? The only drawback I can think of is that the ratings would be out of date, depending on how often the cronjob sorted the results.

Is it worth it to move to this new process or is my concern for efficiency unfounded?

## algorithms – Find closed forms for return values

``````
int coffee(int n) {
int s = n * n;
for (int q = 0; q < n; q++)
s = s - q;
for (int q = n; q > 0; q--)
s = s - q;
return s + 2;
}

int tea(int n) {
int r = 0;
for (int i = 1; i < n*n*n; i = i * 2)
r++;
return r * r;
}

int mocha(int n) {
int r = 0;
for (int i=0; i<=n; i = i+16)
for (int j=0; j``````
``` I'm trying to find the value back in terms of $$n$$ for coffee, tea, mochabut I'm stuck right now. I know coffee will return 2 as the code follows: $$s = n ^ 2$$ $$s = n ^ 2 - displaystyle sum_ {q = 0} ^ {n-1} q = n ^ 2 - dfrac {n (n-1)} {2}$$ $$s = n ^ 2 - dfrac {n (n-1)} {2} - displaystyle sum_ {q = 1} ^ nq = n ^ 2 - dfrac {n (n-1)} {2} - dfrac {n (n + 1)} {2} = 0$$ Then, $$s = 0 + 2$$. However, I can not understand tea, mocha, and espressobecause they do not follow the increments of +1. Could someone help me calculate the return value in terms of $$n$$? ```
``` jQuery(document).ready(function() {jQuery.ajax({type: "POST",url : rating_form_script.ajaxurl,data : { action : "display_rating_form_ajax", args : {"id":1,"post_id":137670,"comment_id":0,"custom_id":"0","user_id":0,"term_id":0,"title":false,"score":true,"total":true,"stats":true,"user_stats":false,"tooltip":true,"result":true,"rich_snippet":true,"is_widget":false,"state":"","before_content":"","after_content":"","rates":"rating,ratings","txt_score":"%1\$s\/%2\$s"} }, success : function(data) { jQuery("body").find("[data-id=\"RFR1P137670\"]").html(data); }});}); { "@context": "http://schema.org", "@type": "Article", "mainEntityOfPage": { "@type": "WebPage", "@id": "https://newproxylists.com/algorithms-find-closed-forms-for-return-values/" }, "headline": "algorithms - Find closed forms for return values", "url": "https://newproxylists.com/algorithms-find-closed-forms-for-return-values/", "author": { "@type": "Person", "name":"Admin" }, "publisher": { "@type": "Organization", "name": "New and Fresh Private + Public Proxies Lists Everyday!", "logo": { "@type": "ImageObject", "url": " ", "width": "", "height": "" } }, "datePublished": "2019-09-14T13:06:58+00:00", "dateModified": "2019-09-14T13:06:58+00:00", "aggregateRating": { "@type": "AggregateRating", "bestRating": "5", "worstRating": "1", "ratingValue": "5", "ratingCount": "4" } } ```
``` Author AdminPosted on September 14, 2019Tags Algorithms, Closed, find, forms, return, values ```
``` algorithms – Finding the return value in terms of \$ n \$ int coffee(int n) { int s = n * n; for (int q = 0; q < n; q++) s = s - q; for (int q = n; q > 0; q--) s = s - q; return s + 2; } int tea(int n) { int r = 0; for (int i = 1; i < n*n*n; i = i * 2) r++; return r * r; } int mocha(int n) { int r = 0; for (int i=0; i<=n; i = i+16) for (int j=0; j I'm trying to find the value back in terms of $$n$$ for coffee, tea, mocha, but I'm stuck for now. I know that coffee will return 2 as the code follows: $$s = n ^ 2$$ $$s = n ^ 2 - displaystyle sum_ {q = 0} ^ {n-1} q = n ^ 2 - dfrac {n (n-1)} {2}$$ $$s = n ^ 2 - dfrac {n (n-1)} {2} - displaystyle sum_ {q = 1} ^ nq = n ^ 2 - dfrac {n (n-1)} {2} - dfrac {n (n + 1)} {2} = 0$$ Then, $$s = 0 + 2$$ , but I do not get to understand tea, mocha and espresso because they do not follow the increments of +1. Could someone help me calculate the return value in terms of $$n$$? jQuery(document).ready(function() {jQuery.ajax({type: "POST",url : rating_form_script.ajaxurl,data : { action : "display_rating_form_ajax", args : {"id":1,"post_id":137441,"comment_id":0,"custom_id":"0","user_id":0,"term_id":0,"title":false,"score":true,"total":true,"stats":true,"user_stats":false,"tooltip":true,"result":true,"rich_snippet":true,"is_widget":false,"state":"","before_content":"","after_content":"","rates":"rating,ratings","txt_score":"%1\$s\/%2\$s"} }, success : function(data) { jQuery("body").find("[data-id=\"RFR1P137441\"]").html(data); }});}); { "@context": "http://schema.org", "@type": "Article", "mainEntityOfPage": { "@type": "WebPage", "@id": "https://newproxylists.com/algorithms-finding-the-return-value-in-terms-of-n/" }, "headline": "algorithms - Finding the return value in terms of \$ n \$", "url": "https://newproxylists.com/algorithms-finding-the-return-value-in-terms-of-n/", "author": { "@type": "Person", "name":"Admin" }, "publisher": { "@type": "Organization", "name": "New and Fresh Private + Public Proxies Lists Everyday!", "logo": { "@type": "ImageObject", "url": " ", "width": "", "height": "" } }, "datePublished": "2019-09-13T22:08:17+00:00", "dateModified": "2019-09-13T22:08:17+00:00", "aggregateRating": { "@type": "AggregateRating", "bestRating": "5", "worstRating": "1", "ratingValue": "5", "ratingCount": "4" } } Author AdminPosted on September 13, 2019Tags Algorithms, finding, return, terms PHP code to make a WHOIS request and return the received data I've written a bit of PHP to make WHOIS queries and return the retrieved WHOIS record. First, a function allows you to identify the TLS of the first level for the domain: //Return the first-level TLD for a domain function getTld(\$domain) { //If domain contains dot, find first-level TLD and return it if(strpos(\$domain, ".")) { return(pathinfo(\$domain, PATHINFO_EXTENSION)); //If domain doesn't contain a dot, just return domain as-is } else { return(\$domain); } } Then the top-level TLD is prefixed to .whois-servers.net, and a WHOIS lookup is done on TCP port 43: //Return raw WHOIS data for domain function whois(\$domain) { \$whoisServer = getTld(\$domain) . ".whois-servers.net"; set_error_handler("whoisWarningHandler", E_WARNING); \$whois = fsockopen(\$whoisServer, 43); restore_error_handler(); stream_set_timeout(\$whois, 3); stream_set_blocking(\$whois, false); fwrite(\$whois, \$domain . "rn"); \$read = (\$whois); \$retries = 1; \$null = null; while(stream_select(\$read, \$null, \$null, 5) === false) { if(\$retries++ >= 5) { return(0); } print("Retrying... (attempt " . \$retries . ")"); sleep(1); } sleep(1); return(filter_var(fread(\$whois, 65535), FILTER_DEFAULT, FILTER_FLAG_STRIP_HIGH)); } Finally, there is a custom warning manager to terminate the program if a connection to the WHOIS server can not be established: //Custom warning handler for WHOIS fsock/stream function whoisWarningHandler(\$errno, \$errstr) { print("An error occurred while connecting to the WHOIS server.nnError output:nn" . \$errstr . "n"); exit(2); } The code can then be called using, for example, print(whois("example.com"));, which would print the WHOIS record for example.com. Can any one indicate if the best practices in terms of quality, efficiency and code security have been followed, as well as the recommended adjustments / improvements that could be made? jQuery(document).ready(function() {jQuery.ajax({type: "POST",url : rating_form_script.ajaxurl,data : { action : "display_rating_form_ajax", args : {"id":1,"post_id":136888,"comment_id":0,"custom_id":"0","user_id":0,"term_id":0,"title":false,"score":true,"total":true,"stats":true,"user_stats":false,"tooltip":true,"result":true,"rich_snippet":true,"is_widget":false,"state":"","before_content":"","after_content":"","rates":"rating,ratings","txt_score":"%1\$s\/%2\$s"} }, success : function(data) { jQuery("body").find("[data-id=\"RFR1P136888\"]").html(data); }});}); { "@context": "http://schema.org", "@type": "Article", "mainEntityOfPage": { "@type": "WebPage", "@id": "https://newproxylists.com/php-code-to-make-a-whois-request-and-return-the-received-data/" }, "headline": "PHP code to make a WHOIS request and return the received data", "url": "https://newproxylists.com/php-code-to-make-a-whois-request-and-return-the-received-data/", "author": { "@type": "Person", "name":"Admin" }, "publisher": { "@type": "Organization", "name": "New and Fresh Private + Public Proxies Lists Everyday!", "logo": { "@type": "ImageObject", "url": " ", "width": "", "height": "" } }, "datePublished": "2019-09-12T13:02:02+00:00", "dateModified": "2019-09-12T13:02:02+00:00", "aggregateRating": { "@type": "AggregateRating", "bestRating": "5", "worstRating": "1", "ratingValue": "4.8", "ratingCount": "79" } } Author AdminPosted on September 12, 2019Tags code, data, php, received, request, return, WHOIS oracle – Why does my continuous query notification script only return events from the production database? What I use:Python 3.7Oracle 12c (development)Oracle 10g (production)RedHat 6cx_Oracle 7oracle_client 11.2.0 What am I doing:Build a python listener that uses the query notification continues to update a collection of json files. My problem:Several months ago, I asked my database administrator to grant a change notification to a development database user at work to support a python listener using cx_Oracle . Listener manages the events and stores the results in json. Everything worked as expected. Last week (03/09/19), I asked the database administrator to grant the same notification to another user of my production database to test on the field my listener in the real world. As soon as this grant was completed, my development auditor stopped receiving events. The production auditor receives and manages the events as planned. Why did my development auditor stop receiving events? I would still like to test the code changes against dev before releasing updates. Additional information (relevant?): The development user had more privileges than the production user. The production user can only select The development server is Oracle 12c, production is on Oracle 10g. (Weird, but we have no control over that) Dev and prod share the same port but reside on different hardware The development listening program always has the privilege of subscribing to events. it's just not handling them. jQuery(document).ready(function() {jQuery.ajax({type: "POST",url : rating_form_script.ajaxurl,data : { action : "display_rating_form_ajax", args : {"id":1,"post_id":135956,"comment_id":0,"custom_id":"0","user_id":0,"term_id":0,"title":false,"score":true,"total":true,"stats":true,"user_stats":false,"tooltip":true,"result":true,"rich_snippet":true,"is_widget":false,"state":"","before_content":"","after_content":"","rates":"rating,ratings","txt_score":"%1\$s\/%2\$s"} }, success : function(data) { jQuery("body").find("[data-id=\"RFR1P135956\"]").html(data); }});}); { "@context": "http://schema.org", "@type": "Article", "mainEntityOfPage": { "@type": "WebPage", "@id": "https://newproxylists.com/oracle-why-does-my-continuous-query-notification-script-only-return-events-from-the-production-database/" }, "headline": "oracle - Why does my continuous query notification script only return events from the production database?", "url": "https://newproxylists.com/oracle-why-does-my-continuous-query-notification-script-only-return-events-from-the-production-database/", "author": { "@type": "Person", "name":"Admin" }, "publisher": { "@type": "Organization", "name": "New and Fresh Private + Public Proxies Lists Everyday!", "logo": { "@type": "ImageObject", "url": " ", "width": "", "height": "" } }, "datePublished": "2019-09-10T02:38:24+00:00", "dateModified": "2019-09-10T02:38:24+00:00", "aggregateRating": { "@type": "AggregateRating", "bestRating": "5", "worstRating": "1", "ratingValue": "5", "ratingCount": "12" } } Author AdminPosted on September 10, 2019Tags Continuous, Database, events, Notification, Oracle, production, query, return, script sql – How to check a query with an empty return? I have a query with a lot of columns and when I go back empty, I want it to show 1. However, I can not check because of the many columns and the GROUP BY. A simple example follows below: SELECT ISNULL( (SELECT SUM(amount), p.staff_id from payment p INNER JOIN staff s on s.staff_id=p.staff_id GROUP BY p.staff_id),0) However, I get the following error: Only one expression can be specified in the select list when the subquery is not introduced with EXISTS. How can I check if a query is null and give it a value when it has more than one column? jQuery(document).ready(function() {jQuery.ajax({type: "POST",url : rating_form_script.ajaxurl,data : { action : "display_rating_form_ajax", args : {"id":1,"post_id":135772,"comment_id":0,"custom_id":"0","user_id":0,"term_id":0,"title":false,"score":true,"total":true,"stats":true,"user_stats":false,"tooltip":true,"result":true,"rich_snippet":true,"is_widget":false,"state":"","before_content":"","after_content":"","rates":"rating,ratings","txt_score":"%1\$s\/%2\$s"} }, success : function(data) { jQuery("body").find("[data-id=\"RFR1P135772\"]").html(data); }});}); { "@context": "http://schema.org", "@type": "Article", "mainEntityOfPage": { "@type": "WebPage", "@id": "https://newproxylists.com/sql-how-to-check-a-query-with-an-empty-return/" }, "headline": "sql - How to check a query with an empty return?", "url": "https://newproxylists.com/sql-how-to-check-a-query-with-an-empty-return/", "author": { "@type": "Person", "name":"Admin" }, "publisher": { "@type": "Organization", "name": "New and Fresh Private + Public Proxies Lists Everyday!", "logo": { "@type": "ImageObject", "url": " ", "width": "", "height": "" } }, "datePublished": "2019-09-09T16:03:24+00:00", "dateModified": "2019-09-09T16:03:24+00:00", "aggregateRating": { "@type": "AggregateRating", "bestRating": "5", "worstRating": "1", "ratingValue": "5", "ratingCount": "48" } } Author AdminPosted on September 9, 2019Tags Check, empty, query, return, SQL c ++ – return type deduction – decltype – return (x) returns int & What is happening here?? int x = 1; decltype(auto) f() { return x; } // return type is int, same as decltype(x) decltype(auto) f() { return(x); } // return type is int&, same as dcltype((x)) ** This is an excerpt from the documentation * The question arises why decltype deduces that return (x) This is of the int type & int x = 1; auto f(){ return (x); // return type is int&, same as decltype((x)) } int main(){ bool es_ref = std::is_reference::value; std::cout << es_ref; } I did the tests and yes, but my question is to know if there is an anonymous reference or what? How are they different? return x of return (x)yeah () Act as an operator or as a c ++ theme. I appreciate them they direct me to the light. Function Declaration - Go to Return Type Deduction jQuery(document).ready(function() {jQuery.ajax({type: "POST",url : rating_form_script.ajaxurl,data : { action : "display_rating_form_ajax", args : {"id":1,"post_id":135466,"comment_id":0,"custom_id":"0","user_id":0,"term_id":0,"title":false,"score":true,"total":true,"stats":true,"user_stats":false,"tooltip":true,"result":true,"rich_snippet":true,"is_widget":false,"state":"","before_content":"","after_content":"","rates":"rating,ratings","txt_score":"%1\$s\/%2\$s"} }, success : function(data) { jQuery("body").find("[data-id=\"RFR1P135466\"]").html(data); }});}); { "@context": "http://schema.org", "@type": "Article", "mainEntityOfPage": { "@type": "WebPage", "@id": "https://newproxylists.com/c-return-type-deduction-decltype-return-x-returns-int/" }, "headline": "c ++ - return type deduction - decltype - return (x) returns int &amp;", "url": "https://newproxylists.com/c-return-type-deduction-decltype-return-x-returns-int/", "author": { "@type": "Person", "name":"Admin" }, "publisher": { "@type": "Organization", "name": "New and Fresh Private + Public Proxies Lists Everyday!", "logo": { "@type": "ImageObject", "url": " ", "width": "", "height": "" } }, "datePublished": "2019-09-08T18:27:35+00:00", "dateModified": "2019-09-08T18:27:35+00:00", "aggregateRating": { "@type": "AggregateRating", "bestRating": "5", "worstRating": "1", "ratingValue": "5", "ratingCount": "22" } } Author AdminPosted on September 8, 2019Tags amp, decltype, deduction, int, return, returns, type Posts navigation Page 1 Page 2 … Page 43 Next page ```