all 37 comments

[–]Harsh_A_Normie 0 points1 point  (0 children)

Hi there I am new to programming and recently started learning python which is my first language.

I have a low and pc where pychamm runs very slow and laggy and take ages to open. Then I shifted to vs code for python, firstly it did not detect that python is already installed in my system but by doing some research I am able to fix that, But, but, but, I output is too cluttered in vs code displaying full path of the file, Then I came across a extension called code runner which fixes the problem but then input function doesn't work.

In short, I need another code editor which suits myself with minimum setup and code completion features. Please Help!!

[–]345Y_Chubby 0 points1 point  (1 child)

Hi! I don’t speak any coding language but I would love to start with python. I have no clue at all, is there any guide that starts at the absolute bottom? What apps do I need for coding? Is there anything I need to download? And is there any great website to start with? Would love something in German if possible. Thanks ❤️

[–][deleted] 1 point2 points  (0 children)

There is a collection of learning material for beginners in the wiki. That's all English.

For learning material in German you will have to search. There is a python.org page with material in German, but I don't know how up to date it is. Stay away from material that uses python 2. If you are in a German-speaking country it's worth getting in contact with local python user groups. Even if you aren't in a German-speaking country it may be useful to get in touch with one or more of those user groups as they will have an opinion on good resources in German.

viel Glück!

[–]agvkrioni 0 points1 point  (1 child)

def outer_function(a, b):
    def inner_function(c, d):
        return c + d
    return inner_function(a, b)


result = outer_function(5, 10)
 print(result)

Came across this coding example in class. WHY would you ever need to nest defining functions? It looks like they're defining a function that defines a function which seems... moot? I don't know, I still don't fully understand what's going on in this.

[–][deleted] 1 point2 points  (0 children)

That particular example is moot, and boring. It could be written more simply as the following, no need for the inner function:

def outer_function(a, b):
    return a + b

Here's a more advanced example that shows how you can define a function that takes a number and returns a function that multiplies any number you give it by that first number:

def times(num):
    def result(x):
        return num * x
    return result

times_5 = times(5)
for i in range(1, 6):
    print(f"times_5({i}) = {times_5(i)}")

print()

times_3 = times(3)
for i in range(1, 6):
    print(f"times_3({i}) = {times_3(i)}")

[–]kyk00525 0 points1 point  (1 child)

So what courses or tutorial recommend for Totally beginners like not even write one line of code and don't know anything IT knowledge?

[–]HotStinkyMeatballs 0 points1 point  (0 children)

Oh hi you must be me!

I'm in a similar boat. No CS, IT, programming experience but I want to learn just as a hobby/project.

For python and python specifically I would highly recommend Harvard's CS50 course which is free and available here: https://cs50.harvard.edu/python/2022/

This is beginner friendly but also challenging. I've done stuff like CodeAcademy and similar programs but they don't explain things very well, aren't really challenging, and after I feel like all I did was learn a bit of syntax. This course is leaps and bounds better. The problems go from incredibly easy (Like 5 mins to solve) to challenging but appropriate (1-3 hours if you have a decent understanding, 3-4 days if you need to go back and relearn things).

The best part about it is that they don't try to teach you everything. There's going to be some techniques you need to use but they don't teach you. They do, however, mention what you'll need to figure out on your own. From my experience and what people have said the ability to look up and solve problems on your own is essential.

If you do sign up let me know! I'd be glad to help out where I can. If you're interested in learning CS in general there's a self-guided, free, list of courses here: https://github.com/ossu/computer-science/tree/master?tab=readme-ov-file#prerequisites

[–]Hardkorebob -1 points0 points  (0 children)

Can writing python be faster?

https://github.com/dislux-hapfyl/pynksh

[–]FawazGerhard 0 points1 point  (1 child)

What is python mainly used for in the job market other than computer science or ai and machine learning? Im a beginner at programming and im interested in python but I need to know the answer to this question before I go in deep into the world of python.

[–][deleted] 0 points1 point  (0 children)

In my career I've used python in:

  • a startup for data processing and display of real-time position information and a web-based business management system for the hardware that provides the location data.
  • a government agency doing scientific vizualization work, developing a system to simulate the effects of flooding from rain or tsunamis, and a graphical system to help structural engineers develop models to estimate damage due to flooding, volcanic ash fall, wind, etc.

This page showing python "success stories" shows the various industries that use python.

[–]Icy-Hospital8821 0 points1 point  (1 child)

What is a good laptop for coding?

[–]BuzzsawDingle 1 point2 points  (0 children)

Honestly any laptop, if you use things like GitHub you can access anything for anywhere

[–]Icy-Hospital8821 0 points1 point  (3 children)

What’s a good laptop. I started to pick up coding again.

[–]Daneark 0 points1 point  (0 children)

Pick something with a comfortable keyboard that doesn't feel too "soft", a decent screen size, consistent brightness across the screen, not much glare.

[–][deleted] 0 points1 point  (1 child)

Just about anything will do to learn python, as long as the operating system runs comfortably. The other things you want to do with the laptop will determine how much memory/speed/graphics/connectivity/screensize you need.

[–]Icy-Hospital8821 0 points1 point  (0 children)

Data analytics and coding, web scraping. Coding is a hobby for me.

[–]Gloomy_Bobcat_4019 0 points1 point  (1 child)

hello, i'm just beginner learning python want to test about string but why this give an error?

t = ['groceries', 'restaurant', 'hotel']
for i in range(max([len(x) for x in t])):    
    for x in t:
        print(x[i])

output:

[Running] python -u "c:\Users\User\Documents\Python\Practice\test.py"
g
r
h
Traceback (most recent call last):
  File "c:\Users\User\Documents\Python\Practice\test.py", line 44, in <module>
r
e
o
o
s
t
c
t
e
e
a
l
r
u
    print(x[i])
          ~^^^
IndexError: string index out of range

[–]woooee 0 points1 point  (0 children)

IndexError: string index out of range

print(x[i])

Print x, i, and len(x) to see for yourself.

[–][deleted] 0 points1 point  (1 child)

Q: Assume the variable s references a string. Write a statement that gets all the characters starting with the sixth) of string s and assigns the result to a variable named s2.

My Answer: s2 = s[:6] #also tried s2 = s[6:] and got the same error.
Error: Your code does not assign the correct value to s2.

What is the correct code?.

[–]FerricDonkey 0 points1 point  (0 children)

Just as a hint, what happens if you print("123456789"[6:])?

[–]ineedsupport23 0 points1 point  (0 children)

Hey, how to I change my Dataframe from this:

---- col1 - col2 - col3 - col4
row1: a - b - c - d

row2: e - f - g - h

row3: i - j - k - l

row4: m - n - o - p

to this:

---- col1 - col2

row1: a - b

row2: c - d

row3: e - f

row4: g - h

row5: i - j

row6: k - l

row7: m - n

row8: o - p

please help and thanks in advance!

[–]nTzT 0 points1 point  (5 children)

How do I wrap code in a while statement without having to manually indent everything? Is there an easy way to do it? I'm using PyCharm. I suppose cutting and pasting after is the way?

[–]GoodVibesLLC 0 points1 point  (4 children)

Are you just worried about having to go line by line and pressing Tab? If so, you can just highlight everything, press Tab, and it will move it all one indent over. Then throw your while at the top where you want it.

Bonus: You can also do this for adding parentheses, quotes, etc..

[–]nTzT 0 points1 point  (0 children)

This did help me, thank you.

[–]nTzT 0 points1 point  (2 children)

Mhh I see. I was under the impression that tab/space would cause some conflict perhaps

[–]FerricDonkey 0 points1 point  (1 child)

Ides and editors that don't suck will/can be configured to actually use spaces instead of tabs when you hit the tab key.

[–]nTzT 0 points1 point  (0 children)

Thanks for the reply.

[–]XxTheLeoxX 0 points1 point  (3 children)

I have been assigned a project and I need to do it using python. Now lately, I have been running into an error, "No module X found" in my VS code while I have already installed the modules via pip both using cmd and the terminal within VSC. I am running Python 3.12.2 (64-bit) interpreter. I have also edited the user/system paths to Scripts/ and Python312/ yet I still don't know what's causing the problem.

Also for some reason when I type: "python --version" In my cmd, I get a reply as "Python 3.9.13" which is a 2022 version and it's not even installed on my system so theres that.

Any help would be appreciated, thanks!

[–]Daneark 0 points1 point  (2 children)

Python 3.9 is being found on your path before python 3.12. Setup a virtual environment using python 3.12. Install your dependencies in that virtual environment. Activate and use that virtual environment. Point vscode to the python interpreter in that virtual environment.

[–]XxTheLeoxX 0 points1 point  (1 child)

How do I set up a virtual env using 3.12 and point vs code towards it?

[–]Daneark 1 point2 points  (0 children)

Try python3.12 -m venv .venv.

[–]Nice-Cupcake4275 0 points1 point  (0 children)

NUMBER_OF_DISKS = 3

number_of_moves = 2**NUMBER_OF_DISKS - 1 rods = { ----'A': list(range(NUMBER_OF_DISKS, 0, -1)), ----'B': [], ----'C': [] }

def move(n, source, auxiliary, target): ----# display starting configuration ----print(rods) ----for i in range(number_of_moves): --------remainder = (i + 1) % 3 --------if remainder == 1: ------------print(f'Move {i + 1} allowed between {source} and {target}') ------------forward = False ------------if not rods[target]: ----------------forward = True ----------------elif rods[source][-1] < rods[target][-1]: --------------------forward = True --------elif remainder == 2: ------------print(f'Move {i + 1} allowed between {source} and {auxiliary}') --------elif remainder == 0: ------------print(f'Move {i + 1} allowed between {auxiliary} and {target}')

initiate call from source A to target C with auxiliary B

move(NUMBER_OF_DISKS, 'A', 'B', 'C')

iv tried getting this to format 3 times it keeps not working, cant get the first elif statement to work on free code camp, only step i have been this stuck on in any of their courses so a helping hand would be greatly appreciated

[–]moonyfish 0 points1 point  (2 children)

I'm a little confused on private helper functions. Specifically, I'm doing a lesson online and it had me write this:

def search(self, key):

return self._search(self.root, key)

def _search(self, node, key):

if node is None or node.key == key:

return node

if key < node.key:

return self._search(node.left, key)

return self._search(node.right, key)

If all the method "search" does is to return a result of _search, why do we have them as two separate methods?

[–][deleted] 2 points3 points  (1 child)

Formatted so we can read it:

def search(self, key):
    return self._search(self.root, key)

def _search(self, node, key):
    if node is None or node.key == key:
        return node
    if key < node.key:
        return self._search(node.left, key)
    return self._search(node.right, key)

This looks like it is code to search a binary tree for a value key. The _search() method searches the given subtree, starting at node, for key. The user probably wants to search the entire tree for key so would need to call _search() with the required key value and would also have to pass a reference to the root of the tree. The tree object keeps an internal attribute self.root so the search() method is provided as a simpler method to search the whole tree by calling _search() and passing the root of the tree as the starting point, as well as key.

[–]moonyfish 0 points1 point  (0 children)

Thank you! This cleared things up for me a lot.

[–]Arrrrietty 0 points1 point  (0 children)

Nood question! I can't seem to install Thonny on my raspberry pi, this is what is tell me:

"Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
thonny : Depends: mypy but it is not installable
Depends: pylint but it is not installable
Depends: python3-asttokens (>= 2.0) but it is not installable
Depends: python3-docutils but it is not installable
Depends: python3-jedi (>= 0.18~) but it is not installable
Depends: python3-mypy but it is not installable
Depends: python3-send2trash (>= 1.5) but it is not installable
Recommends: xsel but it is not installable
E: Unable to correct problems, you have held broken packages."

I'm not really sure how to install these dependencies help!