#🔒 brand new

152 messages · Page 1 of 1 (latest)

full kestrel
#

hello im 5 mins old into codng. i am watchng a youtube video for some excersises and for some reason the run function is not allowing me to test my simple code. s someone free for a vdeo call to help me figure it out?

flat relicBOT
#

@full kestrel

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

agile ravine
full kestrel
#

im fne to try but i dont know many terms or really how to describe what is going on

agile ravine
flat relicBOT
#
Formatting code on Discord

Here's how to format Python code on Discord:

```py
print('Hello world!')
```

These are backticks, not quotes. Check this out if you can't find the backtick key.

For long code samples, you can use our pastebin.

full kestrel
#

ok one moment

agile ravine
#

or you could even post a screenshot to begin with in this instance (normally we prefer code to be posted as text, but when there is problems with how to run things a screenshot of what you are trying to do can sometimes be more helpful)

full kestrel
#

first = input("First: ")
second = input("Second: ")
sum = int(first) + int(second)
print(sum)

flat relicBOT
#

Hey @full kestrel!

Please edit your message to use a code block

```py
print('Hello, world!')
```

This will result in the following:

print('Hello, world!')```
full kestrel
#

im watching a video by programmng with mosh and ths is the exact code he inputs but when i click run i get an error msg ill get the ss now

full kestrel
#

is there somethng wrong on the ss

open marten
#

the code is correct

full kestrel
#

this is my very frst input and as im struggling to grasp it i hope i can contnue today before bed and not have to walk away for now

dire elbow
#

It's looking for an interpreter in a different folder than your current project

full kestrel
#

how do i fix. in kindergarten terms plz lol

dire elbow
#

"PycharmMiscProject" vs "Pycharm_New world"

#

Personally, I would not recommend using pycharm to begin with. It's a bit bloated for a beginner imo

full kestrel
#

bloated? meaning too much?

#

i opened a youtube video and did what he said to get my frst taste about an hour ago

dire elbow
#

Yeah, it does a lot behind the scenes, making it you don't understand what's going on

agile ravine
#

@full kestrel have you moved or renamed the directory for the project?

dire elbow
#

Also, if that's the first code they show, they already do something which is quite bad (overwrite sum function), so I wouldn't put too much faith into it

open marten
#

vscode is the best

dire elbow
#

I can hop in a call if ya want and help you set up

#

Gimme a few mins tho if you want that

celest surge
#

Have you installed Python at all?
But yes, if PcCamel can help interactively that would be quicker.

full kestrel
full kestrel
dire elbow
#

@full kestrel

#

You opened powershell and typed python --version right? What does it show?

full kestrel
dire elbow
#

Okay good, so python is installed correctly

#

Somewhere on your PC make a folder called something like "Code"

full kestrel
#

exit ps?

dire elbow
#

Yes

full kestrel
#

code" created

dire elbow
#

And make a new folder in there called something like first_project

full kestrel
#

done

dire elbow
#

Open vscode and select that folder:

full kestrel
#

done

dire elbow
#

You can open a new terminal with ctrl + `

#

Send a screenshot when you get there

full kestrel
#

ok

dire elbow
#

Not like that, you just opened powershell separately again

#

Click in vscode (make the window active), and then press ctrl + `

#

Again send a ss if you did that pls

full kestrel
dire elbow
#

Okay nice, you might want to make vscode fullscreen, it's pretty cramped right now

#

At the bottom you now see a terminal has hopened

#

This is basically also powershell

#

You can type python --version to try it out

full kestrel
#

Same result

dire elbow
#

For every python project, you want to make a virtual environment. You can do this with the following command:

python -m venv ./.venv

This makes a folder in your current directory (./) called .venv

full kestrel
#

That e book you sent is free on oceanofpdf

dire elbow
full kestrel
dire elbow
#

Is there a new folder now in the directory?

full kestrel
#

Weird when I clicked it said 2 different prices. I didn't scroll any either

dire elbow
#

Better to send a ss, difficult to see when you make a pic

full kestrel
#

seems so

dire elbow
#

Yeah perfect, so there is a .venv folder now. This folder will also contain python.exe

full kestrel
dire elbow
#

Now press ctrl + shift + p and type the following:

#

Click on the Python: select interpreter

#

Send me a ss of what it shows

full kestrel
dire elbow
#

Python: select interpreter

#

Can you find it?

full kestrel
#

i hit enter

dire elbow
#

Oh hmm, one sec

#

On the left, click the 4 squares

#

Then look up "Python"

#

Install that one

full kestrel
#

done

dire elbow
#

Alright, now go back to your files

dire elbow
full kestrel
dire elbow
#

See the bottom one? That's in the .venv folder we just created

#

Select that one

#

Then make a new file in the folder called "tmp1.py` f.e.

#

(right click in the file explorer)

#

SS when done pls

full kestrel
dire elbow
#

Took that a bit too literally lol

#

tmp1.py

full kestrel
#

i have to as i know nothing rn lol

dire elbow
#

Yeah mb

full kestrel
dire elbow
#

Alright, type the following code:

print("Hello world!")
#

Then click on the run button:

#

And ss when done

full kestrel
dire elbow
#

Coolio, it works

#

So that's how you run a .py file.

#

Next time you want to continue coding you:

  1. open vscode
  2. open the folder
#

And then you are able to run code with the run button

full kestrel
#

i greatly appriciate your patence and clarity sir

dire elbow
#

Sure nws.

#

There's one more thing

#

In tutorials you will also find them wanting you to run python in "interactive" or "shell" mode

#

In the terminal section you can click on the + to open a new terminal

#

You will see it will add another terminal in the list on the right

#

And then simply type python

#

ss when done

#

If it works, you should see >> and you can type f.e. 1 + 2 then enter, and it will show 3

full kestrel
#

i believe it opened the agent

dire elbow
#

You can close the agent

#

The + in the image above

full kestrel
#

sweet got it

dire elbow
#

You were able to type the 1 + 2?

full kestrel
#

no ss incoming

#

alrght i t worked

dire elbow
#

Cool

#

when you type python in powershell, it opens python in interactive mode

#

If you see >> you are in "Python interactive" mode

#

You can type exit() to go back to powershell terminal

full kestrel
dire elbow
#

So you now know how to run python in two ways:
1) Interactive mode: open a terminal -> type python
2)run a python file: Create a .py file, click the run button (triangle)

#

That's it

#

Whatever book you use, they will use one of the two modes to run their code in whatever IDE they use (PyCharm, Vscode, w/e), and you can do that too now.

full kestrel
#

awesome. so now im back to the vdeos and book?

dire elbow
#

Jup. I would really recommend following a structured course like automate the boring stuff or some other course

#

Videos are nice for passive learning, but stuff won't stick when you watch someone else program

#

I know, because I've tried 😛

full kestrel
#

on it🫡

dire elbow
#

It's a noob trap

full kestrel
#

im the same way. thats why i was doing the same he was in the vdeo to follow along rather than try and retain

#

very grateful sir

agile ravine
agile ravine
agile ravine
grizzled moth
agile ravine
#

@full kestrel the more code you write yourself without just retyping what someone else has written is what is really valuable
because programming is about problem solving and how to break down big problems to smaller and smaller problems until you can solve each one by themselves and then put everything together again
and don't use AI while you still learning, if you outsource the thinking you will not learn how to do it yourself

full kestrel
flat relicBOT
#
Python help channel closed for inactivity

This help channel has been closed. Feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.