## graphics – Could someone explain how I can use parameters to shorten my code in python

I’m new to coding so I’m unsure on how to shorten this code on python
I’m using graphics.py to create diagonal squares
Is there a way for me to shorten this code using parameters?

` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` “`

``````def diSquares():

win = GraphWin('Coursework', 500, 500)

dsquares = Rectangle(Point(0,400),Point(100,500))
dsquares.setFill('red')
dsquares.setOutline('black')
dsquares.draw(win)

dsquares = Rectangle(Point(100,300),Point(200,400))
dsquares.setFill('red')
dsquares.setOutline('black')
dsquares.draw(win)

dsquares = Rectangle(Point(200,200),Point(300,300))
dsquares.setFill('red')
dsquares.setOutline('black')
dsquares.draw(win)

dsquares = Rectangle(Point(300,100),Point(400,200))
dsquares.setFill('red')
dsquares.setOutline('black')
dsquares.draw(win)

dsquares = Rectangle(Point(400,0),Point(500,100))
dsquares.setFill('red')
dsquares.setOutline('black')
dsquares.draw(win)
``````

## python 3.x – How do I shorten & optimize my Fibonacci Code?

Here’s the code I’m having trouble shortening. I am currently a beginner in Python 3.x.

``````from os import system

def fibonacci(terms):
count = 0
x = 0
y = 1
z = x + y
if terms <= 0:
print("Enter a positive integer.")
elif terms == 1:
print("Fibonacci sequence in " + str(terms) + " terms.")
print(x)
else:
print("Printing " + str(terms) + " terms.")
while count < terms:
print(x)
z = x + y
x = y
y = z
count += 1

while True:
user_input = int(input("How many terms? "))
fibonacci(user_input)
loop = input("Again? (Y/n) ")
if loop == "Y" or loop == "":
system("cls")
else:
exit()
``````

I would appreciate if there will be someone who will be able to make this as efficient as possible. Thank you.

## Shrt10.com-Start Earn 30/1000 with shorten links payout \$3/max 3 days-Trusted/Fast Support | NewProxyLists

Fast Support
now and Start Earning — https://shrt10.com

start earning and you can see all offers duple your earning

All earning will show in your account in every 2 min

Enjoy .

Any problems you can PM on admin mail support

Happy earnings

Email Support : snaw90@gmail.com​

## python – Shorten dict comprehension with repeated operation

``````dc = {line.split('=')(0): line.split('=')(1) for line in txt}
``````

Below avoids duplication but is even longer:

``````dc = {k: v for line in txt for k, v in
zip(*map(lambda x: (x), line.split('=')))}
``````

Any better way? Just without any imports.

Context: `with open('config.txt', 'r') as f: txt = f.read().split('n')`

``````a=1
bc=sea
``````
``````>>> {'a': '1', 'bc': 'sea'}  # desired output; values should be string
``````

## Adbix Get paid to Shorten

Dear DP members / visitors.
I am Demki, and started new short linking site where with a rev share from some ad exchange and ad networks will do best to provide paying to every visitor sent to our short link site.
Me and my partner in business we have started before some months adbix.cc Short link site, where we have paid many publishers and already looking forward for more growth.
Some of you will already have complain that the CPM rates are low compared other networks / link shortening…

## Adbix Paid to Shorten | NewProxyLists

Dear WJ members / visitors.
I am Demki, and started new short linking site where with a rev share from some ad exchange and ad networks will do best to provide paying to every visitor sent to our short link site.
Me and my partner in business we have started before some months adbix.cc Short link site, where we have paid many publishers and already looking forward for more growth.
Some of you will already have complain that the CPM rates are low compared other networks / link shortening sites.
Let me be clear, many say they count every impression sent by you, but in general is just counted 1 or maximum 2 Impression same ip in 24h.
But we have set the limit in to 8 impressions counted from same IP visit in 24h.
Our Payment term for every payment method goes on Monthly payment.
(The reason is we can keep more in detailed accountancy.)
It is very easy and simple
Register
Start Sharing
Get visitors and make revenue.

(As a referrer adult traffic, Facebook traffic is not allowed at all as most of the users are spamming the link on Facebook groups.)

## Nerdy.vn Shorten Paid Links – 2.0 usd / 1,000 Mostly traffic from Asia Countries. | NewProxyLists

I am LEO TRINH from Vietnam,
I am a affiliate manager at files.pw and Watching.vn,
We are working from 2018 and We are paying frequently for our publishers.

AS A GOOD NEWS
We launched a New site in 2019, called NERDY.VN: https://nerdy.vn is a new money making URL shortener .

We are targeting in ASIA Countries mainly. If you are come from asia countries or have most traffic from there. Please join our affiliate program.

Payout Rates:
MAX payout rate is \$2.0 /1,000 views: https://nerdy.vn/payout-rates

Minimum Payout:
The minimum payout on Shorten is only \$3 (Paypal, MOMO, Payeer). We are paying on monday everyweek.

Payment proof.

Best Regards,
Leo Trinh.

## Lock and shorten URLS EARN MONEY – URL shortener with CPA – Other opportunities to earn money

Lock.ist is a URL shortening service combined with content locking. The revenue model for this network is the CPA. You will therefore not be paid for clicks and impressions. Users need to take action such as installing software or filling out a simple form.

How do I get started with Lock.ist?

When you shorten the link using Lock.ist, it will lock automatically. The visitor must perform a simple task to unlock the link. For each task, you receive a commission of \$ 0.10 to \$ 10.

Payment

You are paid in 2 working days when you reach the minimum payment. The payment option is only Bitcoin. The minimum payment is \$ 20.

Reference program

Publishers can earn extra money by referring others to this network. The commission rate is 10% for life.

Best features

-This network accepts members from all over the world.

-You do not need a website or blog to use this service.

-Tools (Website Widget, Browser button and API)

-Reference system

-Members always receive payment on time.

– Dedicated support

For tips and ideas: https://lock.ist/pages/tips-ideas

## mysql – Shorten the request to retrieve presence data

I have a code that does the following:

• Get data from the `HrAttLogs` Table
• Enter the data of the `HrAttLogs` Table at the `HrAttLogsFormatted` Table

I would like to know if the query below, which I will provide, can be improved? In terms of `Performance` and speed.

``````SELECT
FingerId,
ShiftId,
DateIn,
DateOut,
ScanIn,
ScanOut,
WorkhourIn,
WorkhourOut,
TIME_IN,
TIME_OUT
FROM
(
SELECT
i.FingerId,
i.ShiftId,
i.Date AS 'DateIn',
o.Date AS 'DateOut',
i.Time AS 'ScanIn',
CASE WHEN o.Time != i.Time THEN o.Time END AS 'ScanOut',
CASE
WHEN i.Time < i.ShiftIn_2 THEN i.WorkhourIn_1
WHEN i.Time < i.ShiftIn_3 THEN i.WorkhourIn_2
WHEN i.Time > i.ShiftIn_1 THEN i.WorkhourIn_3
END AS WorkhourIn,
/* Added check for Date too.. the last checking is for any overlapping Date */
CASE WHEN i.Status = 'Rolling' THEN
CASE
WHEN i.DateOut = i.Date AND i.Time > i.ShiftOut_1 THEN i.WorkhourOut_2
WHEN i.DateOut = i.Date AND i.Time > i.ShiftOut_2 THEN i.WorkhourOut_3
WHEN i.DateOut = i.Date AND i.Time > i.ShiftOut_3 THEN i.WorkhourOut_1
WHEN i.DateOut > i.Date THEN i.WorkhourOut_3
END
ELSE
CASE WHEN i.ShiftId != 'Rolling' THEN
CASE WHEN i.DateOut = i.Date AND o.Time > i.ShiftOut_2 THEN i.WorkhourOut_3
ELSE i.WorkhourOut_2
END
WHEN i.DateOut = i.Date AND o.Time > i.ShiftOut_3 THEN i.WorkhourOut_1
END
END AS WorkhourOut,
CASE
WHEN i.Time < i.ShiftIn_2 THEN TIMEDIFF(i.Time, i.WorkhourIn_1)
WHEN i.Time < i.ShiftIn_3 THEN TIMEDIFF(i.Time, i.WorkhourIn_2)
WHEN i.Time > i.ShiftIn_1 THEN TIMEDIFF(i.Time, i.WorkhourIn_3)
END AS 'TIME_IN',
CASE WHEN o.Time != i.Time THEN
CASE WHEN i.Status = 'Rolling' THEN
CASE WHEN o.Time > i.ShiftOut_3 THEN
CASE WHEN o.Time > i.ShiftOut_1 THEN
CASE WHEN o.Time > i.ShiftOut_2 THEN TIMEDIFF(o.Time, i.WorkhourOut_2)
ELSE TIMEDIFF(o.Time, i.WorkhourOut_1)
END
ELSE TIMEDIFF(o.Time, i.WorkhourOut_1)
END
ELSE TIMEDIFF(o.Time, i.WorkhourOut_3)
END
ELSE
CASE WHEN i.Status != 'Rolling' THEN
CASE WHEN o.Time > i.ShiftOut_1 THEN
CASE WHEN o.Time > i.ShiftOut_2 THEN TIMEDIFF(o.Time, i.WorkhourOut_1)
ELSE TIMEDIFF(o.Time, i.WorkhourOut_2)
END
END
END
END
END AS 'TIME_OUT',
i.ShiftIn_1,
i.ShiftIn_2,
i.ShiftIn_3,
i.ShiftOut_1,
i.ShiftOut_2,
i.ShiftOut_3,
i.WorkhourIn_2,
i.WorkhourIn_3,
i.WorkhourOut_2,
i.WorkhourOut_3,
i.Status
FROM
( /* INSERT here */
SELECT
i.FingerId,
fs.ShiftId,
CASE WHEN i.Status = 0 THEN
MIN(i.Date)
END AS 'Date',
--         MIN(i.Date) AS 'Date',
/* Added CASE expression to deal with overlapping attendance Date */
CASE WHEN i.Status = 0 AND MIN(i.Time) >= '19:00:00'
THEN DATE(DATE_ADD(i.Date, INTERVAL + 1 DAY))
ELSE
END AS 'DateOut',
CASE WHEN i.Status = 0 THEN
i.Time
END AS 'Time',
--           MIN(i.Time) AS 'Time',
i.Status,
s.ShiftIn_1,
s.ShiftIn_2,
s.ShiftIn_3,
s.ShiftOut_1,
s.ShiftOut_2,
s.ShiftOut_3,
s.WorkhourIn_1,
s.WorkhourIn_2,
s.WorkhourIn_3,
s.WorkhourOut_1,
s.WorkhourOut_2,
s.WorkhourOut_3
FROM HrAttLogs AS i
INNER JOIN HrEmployee AS fs ON fs.FingerId = i.FingerId
INNER JOIN HrEmployeeShift AS s ON s.Id = fs.ShiftId
WHERE
i.Time >= s.ShiftIn_1
AND i.Date >= '2020-04-07'
AND i.Date <= '2020-04-09'
AND i.MachineIp = '10.20.20.73'
GROUP BY
i.Id,
i.FingerId,
i.Date
) AS i
LEFT JOIN (
SELECT
o.FingerId,
CASE WHEN o.Status = 1 THEN
MAX(o.Date)
END AS 'Date',
CASE WHEN o.Status = 1 THEN
MAX(o.Time)
END AS 'Time',
o.Status
FROM
HrAttLogs AS o
WHERE
o.Date >= '2020-04-07'
AND o.Date <= '2020-04-09'
AND o.MachineIp = '10.20.20.73'
GROUP BY
o.Id,
o.FingerId,
o.Date
ORDER BY
Date ASC,
Status ASC
) AS o ON i.FingerId = o.FingerId
AND o.Date = i.DateOut
AND o.Time >= '00:00:00'
) AS q
WHERE
FingerId = 61
AND FingerId IS NOT NULL
AND ShiftId IS NOT NULL
AND DateIn IS NOT NULL
AND DateOut IS NOT NULL
AND ScanIn  IS NOT NULL
AND WorkhourIn IS NOT NULL
AND WorkhourOut IS NOT NULL
AND TIME_IN IS NOT NULL
AND TIME_OUT IS NOT NULL
ORDER BY
q.FingerId ASC,
DateIn ASC
``````

For more details, I save it here

## c – Is there a way to simplify or shorten this chain of conditions in this version comparison code?

I wonder if there is a way to significantly shorten the string of conditions used here to compare two versions. `struct VERSIONCODE` represents a version number of the form `major.minor.revision` and `CompareVersions` Return `EQUAL` if they are equal; `LHS_NEWER` if `vLHS` is more recent, and `RHS_NEWER` if `vRHS` is more recent.

``````typedef enum
{
EQUAL = 0,
} ECOMPARISON;

// Specifically not named "VERSION" to avoid conflicting with common names from third-party libraries etc.
typedef struct
{
int nMajor;
int nMinor;
int nRev;
} VERSIONCODE;

ECOMPARISON CompareVersions(VERSIONCODE vLHS, VERSIONCODE vRHS)
{
if (vLHS.nMajor > vRHS.nMajor)
{
}
else if (vLHS.nMajor < vRHS.nMajor)
{
}
else// if (vLHS.nMajor == vRHS.nMajor)
{
if (vLHS.nMinor > vRHS.nMinor)
{
}
else if (vLHS.nMinor < vRHS.nMinor)
{
}
else// if (vLHS.nMinor == vRHS.nMinor)
{
if (vLHS.nRev > vRHS.nRev)
{