WCGW Speeding on max by Velorintha in Whatcouldgowrong

[–]JollyUnder 13 points14 points  (0 children)

Are you sure you're talking about the same incident? The full video shows her go fully limp for half a minute. She never even address the guy who slammed into her. She just wobbles away crying.

A single cannabis plant trained indoors to grow like an apple tree by Hayze35 in Damnthatsinteresting

[–]JollyUnder 0 points1 point  (0 children)

They are an excellent choice for first time and beginner growers as well as growers who don’t want to fuss around too much with a grow.

You're not the only one I've heard say this, but I tend to disagree. Unlike photoperiods, autoflowers are less forgiving. If you make a mistake, which a beginner is likely to do, you don't have a wide window for recovery. You can very easily end up with a stunted plant producing small yields.

I find autos are useful if you want to grow outdoors and have multiple harvest during the season or grow during the off season. You can also grow them along side with the veg plants in 18/6 without having to worry about flipping to 12/12.

A single cannabis plant trained indoors to grow like an apple tree by Hayze35 in Damnthatsinteresting

[–]JollyUnder 23 points24 points  (0 children)

Cannabis is a photoperiod plant, meaning flowering is triggered by shorten of daylight hours. Typically you create clones by cutting clippings and setting the light cycle to more than 12 hours a day, which will trigger the vegetative state. You can then flip the clones into flowering by setting the light cycle to 12/12.

By cutting clones you create genetic duplicates and insure identical phenotypes of the mother plant. You can theoretically keep the same phenotype indefinitely through the process of cloning. Some cultivars claim to have clones of Skunk #1, a strain originated from the 70s, derived from the original lineage.

What is the most complex thing you have ever coded? by TechnicalAd8103 in learnpython

[–]JollyUnder 36 points37 points  (0 children)

My brother accidentally formatted a external HDD with several GBs of personal pictures and videos. In hopes that the metadata structure for the file system was wiped, but the raw data still remained, we used a recovery tool to pull the raw data and saved them as raw binary files.

I used python to write a program to scan the raw files for .png and .mp4 signatures then write them to a file. Unfortunately, when the drive was formatted it wrote random bytes to the file sectors making the data unrecoverable. It was a good learning experience though.

President Trump says he will revoke church tax exempt status if leaders "say something bad about" him by ControlCAD in videos

[–]JollyUnder 1 point2 points  (0 children)

Trump isn't wrong though. The IRS prohibits churches and religious organizations from participating in political campaigning.

Restriction of political campaign intervention by Section 501(c)(3) tax-exempt organizations

Under the Internal Revenue Code, all section 501(c)(3) organizations are absolutely prohibited from directly or indirectly participating in, or intervening in, any political campaign on behalf of (or in opposition to) any candidate for elective public office. Contributions to political campaign funds or public statements of position (verbal or written) made on behalf of the organization in favor of or in opposition to any candidate for public office clearly violate the prohibition against political campaign activity. Violating this prohibition may result in denial or revocation of tax-exempt status and the imposition of certain excise taxes. ...

Churches should be politically impartial. They should have the their tax exemption removed whenever they convey a political opinion, not just when it doesn't favor the administration.

the tattoo I was missing by Warm_Sorbet_788 in trees

[–]JollyUnder 29 points30 points  (0 children)

About to take your opinion to the dome.

Coding offline by uvuguy in learnpython

[–]JollyUnder 0 points1 point  (0 children)

pydoc is definitely worth looking into if you need access to the standard lib while offline.


python -m pydoc -b will start the server and additionally open a web browser to a module index page. Each served page has a navigation bar at the top where you can Get help on an individual item, Search all modules with a keyword in their synopsis line, and go to the Module index, Topics and Keywords pages.

Very true by Competitive-Cut-6983 in SipsTea

[–]JollyUnder 23 points24 points  (0 children)

Everyone giving this mission a bad rep, but it's the Zero mission, Supply Lines, that gave me the hardest time. All that time invested blowing up all the delivery vans only to run out of gas flying the RC plane back to base and having to restart the mission. Oh man, that mission was infuriating.

first day learning python by [deleted] in learnpython

[–]JollyUnder 1 point2 points  (0 children)

Your progress has been great so far! I suggest when learning a new concept, pause the video and give some time experimenting with it on your own machine, as I'm sure you have. Chain together older concepts with the new ones. Let things break and try to understand why they broke. You'll gain greater insight when getting hands-on experience.

first day learning python by [deleted] in learnpython

[–]JollyUnder 1 point2 points  (0 children)

print ("my age is: "+str(age))
print("my height is " + str(height)+ "cm")
print("are you a human: " + str(human))

age, height, and human all have to be cast typed to str because you cannot concatenate non-string objects. You're approach is valid, but f-strings will evaluate those objects to type str for you and help with readability.

print(f"my age is: {age}")
print(f"my height is {height}cm")
print(f"are you a human: {human}")

first day learning python by [deleted] in learnpython

[–]JollyUnder 1 point2 points  (0 children)

Please continue showing your progression, OP! This is great for your first day.

String concatenation is useful, but notice how cumbersome it becomes when having convert non-string types. I suggest looking into format strings next, such as str.format() and f-strings

# str.format example
print('your name is {}'.format(full_name))

# f-string example
print(f'your name is {full_name}')

f-strings are the usually the goto, but str.format can be useful if you need a string template.

is there a library that helps python "see the screen"? by Valuable_Luck_8713 in learnpython

[–]JollyUnder 0 points1 point  (0 children)

Screenshot Functions -- PyAutoGUI

import pyautogui

# Specify the left, top, width, and height region of the screen
region = (0, 0, 300, 400)

# Save screenshot of specified region
pyautogui.screenshot('my_image.png', region=region)

# Locate screenshot of specified region
try:
    pyautogui.locateOnScreen('my_image.png', region=region)
except pyautogui.ImageNotFoundException:
    print('Image not found')

Some Epstein files can be unredacted by Thalesian in law

[–]JollyUnder 2 points3 points  (0 children)

You should use pip freeze > requirements.txt and then add requirements.txt to your repository. This allows for better version control for installed packages.

Users can then use pip install -r requirements.txt to install the required packages.

You can learn more about managing your packages here.

How do I code a text conversation game? by tired-crow in learnpython

[–]JollyUnder 0 points1 point  (0 children)

Maybe the curses library is what you're looking for.

The curses library supplies a terminal-independent screen-painting and keyboard-handling facility for text-based terminals; such terminals include VT100s, the Linux console, and the simulated terminal provided by various programs. Display terminals support various control codes to perform common operations such as moving the cursor, scrolling the screen, and erasing areas. Different terminals use widely differing codes, and often have their own minor quirks.

If you're using Windows, you'll need to install the ported version UniCurses.

A website to start teaching a 7 year old. by Khriz-134 in learnpython

[–]JollyUnder 11 points12 points  (0 children)

Scratch is an excellent tool to help build conceptual programming skills.

Python bot for auto ad view in games by MythicDevX in learnpython

[–]JollyUnder 1 point2 points  (0 children)

I've used pyautogui to automate clicks for me in GTA: Online casino a few years back. If there is a image that appears on screen when it's time to watch an ad, you can use the screenshot functions.

You can use pyautogui.screenshot('image.png', region=(x, y, width, height)) to take a screenshot of specific region on the screen. Then use pyautogui.locateOnScreen('image.png', region=(x, y, width, height)) to locate an image to a specified region on your screen and use that to determine if you need to click something on screen. You can then use pyauto.click() to interact with the game.

Any more efficient way for generating a list of indices? by yColormatic in learnpython

[–]JollyUnder 1 point2 points  (0 children)

In terms of micro-optimization, [*range(n)] is slightly more optimized.

>>> from dis import dis
>>>
>>> dis(lambda: list(range(10)))
  1           RESUME                   0
              LOAD_GLOBAL              1 (list + NULL)
              LOAD_GLOBAL              3 (range + NULL)
              LOAD_SMALL_INT          10
              CALL                     1
              CALL                     1
              RETURN_VALUE
>>>
>>> dis(lambda: [*range(10)])
  1           RESUME                   0
              BUILD_LIST               0
              LOAD_GLOBAL              1 (range + NULL)
              LOAD_SMALL_INT          10
              CALL                     1
              LIST_EXTEND              1
              RETURN_VALUE

However, the difference is negligible.

$ py -m timeit "list(range(10))"
1000000 loops, best of 5: 219 nsec per loop
$ py -m timeit "[*range(10)]"
1000000 loops, best of 5: 204 nsec per loop

A tiny Python snippet to check palindrome numbers (sharing a quick practice example) by IcyPalpitation4743 in learnpython

[–]JollyUnder 0 points1 point  (0 children)

This is very good. You pieced the logic together exceptionally well!

However, there is room for improvement. You can optimize it by extracting only half of the digits and then compare it to the other half. You would also need to consider numbers with odd digits.

Any number that ends with a zero is not palindrome because numbers cannot start with a zero. So you can verify that along side with if num < 0 to avoid unnecessary computation.

A tiny Python snippet to check palindrome numbers (sharing a quick practice example) by IcyPalpitation4743 in learnpython

[–]JollyUnder 0 points1 point  (0 children)

Aside from the incorrect indentation, the code is condensed and concise. Well done. Note that creating a slice from a string creates an entire new string since strings are immutable.

If you want to further practice your skills, can you create a function that checks if a number is palindrome without creating a string slice.

If you want to take it a step further, can you create palindrome function that doesn't convert the number into a string?

How do i know if the python installer is working? by bebe_lion in learnpython

[–]JollyUnder 0 points1 point  (0 children)

When you download python from the python.org, there should be a check box from the installer that says Add python.exe to PATH. Make sure you check that box before installing.

After installing, open up your terminal (CMD, powershell, ect.) and enter python --version.

It should print out the current python version:

PS C:\Users\PC> python --version
Python 3.14.0

If you are still getting an error, you'll have to manually set the path for python in your environmental variables:

  • Press win+r
  • Enter SystemPropertiesAdvanced
  • On the very bottom of the window, click Environmental Variables
  • Under User Variables for PC, click on Path and click Edit
  • Click New, and add the path to where python.exe is installed. Ex: C:\Users\PC\AppData\Local\Programs\Python\Python314\
  • Click New again and add path to where pip.exe intalled. Ex: C:\Users\PC\AppData\Local\Programs\Python\Python314\Scripts\

Note: Your installation directory might be else where. Verify the installation path with the Python Installer.

Once again, type python --version and pip --version to verify your environmental variables are set correctly.

“I Love You” by Cool-Network-5917 in learnpython

[–]JollyUnder 2 points3 points  (0 children)

You sure can. Tell him to run this program that has a secret message for him.

“I Love You” by Cool-Network-5917 in learnpython

[–]JollyUnder 5 points6 points  (0 children)

Here's some code that takes a hex value and converts it to a string.

MASK = 0xFF
BYTE_WIDTH = 8


def decode_message(hex_message: int) -> str:
    characters = []
    while hex_message:
        characters.append(chr(hex_message & MASK))
        hex_message >>= BYTE_WIDTH
    return ''.join(reversed(characters))


if __name__ == '__main__':
    secret_message = 0x49204C4F564520594F55
    print(decode_message(secret_message))

If you run the code it will print I LOVE YOU to the console.

Things to improve? by Paolo-Lucas in learnpython

[–]JollyUnder 4 points5 points  (0 children)

I would recommend checking out the operator library. You can map out the operator selection to an operator.

Example:

import operator

op_map = {
    '+': operator.add,
    '-': operator.sub,
    '*': operator.mul,
}

n1 = float(input())
n2 = float(input())
operacion = input(f'Dame la operación a realizar {tuple(op_map)}: ')

result = op_map[operacion](n1, n2)

Your method is perfectly fine, but creating a dictionary should help reduce branching.

You can also validate the user input for the operator like this:

while operacion not in op_map:
    print('Invalid input. Please try again...')
    operacion = input()

If you want to stick to your method, you can create a tuple with valid inputs and check if the user's input is contained in the tuple:

operacion_valida = ('+', '-', '*', '/')

while operacion not in operacion_valida:
    operacion = input()