Wednesday, June 12, 2024

Using the (python) development environment

It's interesting to me that they are advocating a method I used myself to learn HTML. In other words I took a copy of the main page of Yahoo.com (because it was the first main page I was accustomed to at the time) and copied it to my Windows 95 environment which was easy to do on that particular operating system. Then I played with the programming to see what different things did when I changed them. Some changes made no observable changes whatsoever when I ran the page. However, other changes changed the color or other changes that were observable. Other changes I made made the program not work at all. by doing this I began at first to understand <P> which means start a new paragraph and <BR> which means start a new line from the one you are on. This was the beginning of my understanding of HTML and I evolved my consciousness from there with further experimentation. for example, creating a links page every 7 days or so here at this site I program myself using code like this in HTML:

<a href="url">link text</a>
<p>&nbsp;</p>
 
<a href="url">link text</a>
<p>&nbsp;</p>
 
<a href="url">link text</a>
<p>&nbsp;</p> 

However, this code won't run because it is in the wrong format. it has to be color coded to run in HTML. This is what the compose version of the code looks like here at blogger.com.

How it works in HTML is like this: you replace where it says url with the real url you are using and then where it says "link text" you replace those words with the actual name you are given to that particular URL when it prints out on your screens worldwide on the Internet. So, you are telling it to manifest a particular URL whenever someone clicks on this link (or word button) same thing.

However, in learning Python we are trying to do mostly completely different things than what we are trying to accomplish in HTML. In Python we are learning to help the computer program process various kinds of decision making loops I think at this point. However, I'm new to Python so this is just a guess at this point.

The concept likely would maybe go something like A+B might equal C or some other variable (something like this. When I learned Fortran which was my first programming language I felt comfortable because it reminded me a lot of Algebra in School. I always sort of liked Algebra and all the formulas simply because it was both methodical and made sense to me. I had already been trained as an electrician by my father starting at age 10 or 12 so by the time I took Algebra methodical thinking I knew kept me alive while working hot on electrical things so I didn't die of an electrical shock especially if we were working HOT on 220 or 440 or 480 volts where you could die pretty easily. So, this methodical way of thinking made sense to me in this context.

Log in or Sign up to save your future progress! All content is 100% free.
Main content

Course: Intro to computer science - Python > Unit 1

Lesson 1: The programming platform



  • Using the development environment

    Get to know the features of the Khan Academy programming platform. Learn how to use the code editor and the console, how to create spin-offs, and how to ask for help.
    So, we're ready to start programming, but how do we do that? Let's get set up with the right programming equipment.

    Using a development environment

    Most programmers use integrated development environments (IDEs) to create their programs. IDEs combine tools for writing, running, and testing code into a single platform to make it easier and faster to get our work done.
    For this course, we'll be using Khan Academy's online Python IDE.

    Writing code: the code editor

    The first thing we'll need is somewhere to write code. A code editor is a text editor specialized for a programming language.
    Code editors work just like your favorite docs app. We type in it and text appears - nothing fancy here. But, instead of English, its built-in tools observe the rules of a particular programming language.
    A user types in the Khan Academy code editor. An unmatched quotation mark pops up a linter error, and a line over 79 characters long pops up a linter warning. Typing, "in," autocompletes to, "input()".

    Syntax highlighter

    You'll notice that different words, numbers, and symbols appear in different colors. This is called syntax highlighting. The code editor uses colors to make it easier for us to distinguish between different components of our program.
    Imagine if your docs app colored all nouns green, all verbs blue, and all adjectives orange. That's what the syntax highlighter does, but for different elements of the Python language.

    Linter

    A linter is like Python spell check. If we type something it doesn't recognize as valid Python syntax, it'll underline it and pop up a symbol in the left sidebar. If we hover over that symbol, it'll show a message explaining the issue.
    Notice that there are two types of symbols: a red circle means error and a yellow triangle means warning. Errors mean our program is broken or invalid. Warnings help us write programs with good style and clarity, like a writing assistant. They'll warn us of things like, "Hey, this is an odd place to put this," or, "Hey, this line is really long and hard to read."

    Autocomplete

    If we start typing in the editor, we may see a dropdown pop up with suggested words. This feature autocompletes common Python keywords and names, so we don't have to memorize them all. We can then click (or use the up and down arrow keys) to select a suggestion.
    You may not recognize many of these suggestions just yet, but as our programs get larger, we'll start to rely on them more. For example, as our Python vocabulary grows, we may want help remembering: was that thing I needed called len() or length()?

    Running code: the console

    Now that we've written our program, what do we do with it?
    A user runs a program in the Khan Academy IDE by pressing the Run button. An interactive input prompt appears in the console that the user responds to. The user edits the code and runs the program again, and this time a red error message appears in the console.
    At the top of the IDE, you'll see a big green Run button. When we press Run, it submits the program to the computer to execute. Think of this like handing in an assignment; we're telling the computer that we're ready for it to take a look now. In this case, though, there's no penalty for mistakes, so we should run our program early and often!
    As it executes the program, the computer displays any results in the console. This output then stays displayed in the console until the next time we press Run - it does not automatically update.
    Console output might be a result that the program asked the computer to display, or it might be an error that the computer encountered while executing the program. Not every program has output, so it's also possible the console stays empty.

    Programming on Khan Academy

    We designed these features specifically for the Khan Academy IDE, with learners like you in mind!

    Spin-offs

    The spin-off feature allows you to make a copy of a program, while still giving credit to the original creator. This is a great opportunity to experiment with programs that you're curious about or build off of programs that you're inspired by. Changes you make to the spin-off program are entirely your own; they won't affect the original program.
    The Spin-off button is available on all public learner-created programs, as seen in the program galleries, and on all course Projects. The Spin-off button unlocks on a Challenge after you complete it.
    When working on bonuses or creative extensions within the course, we recommend creating a spin-off first so that you don't risk breaking your Challenge or Project solution as you explore.

    Getting help

    Ask the community

    If you're stuck, you can always ask for help from the Khan Academy community. The community can help track down tricky errors, suggest ways to improve your code, or brainstorm how to build a specific feature.
    To request help on a Challenge bonus or a Project, you first need to create a spin-off. This makes your program code publicly visible so that others can see what you're working on. Then, navigate to the Questions tab on your program page and submit a help request.
    The Khan Academy community will then make their best effort to answer your question. As you grow your Python experience, you can join in by answering other people's help requests, too! To see all unanswered help requests, press the Help requests button on the course home page.

    Ask Khanmigo

    If you have access to Khanmigo, Khan Academy's AI-powered tutor, you can ask it for programming help. On any Challenge or Project page, open the Khanmigo chat window and start a conversation!
    Khanmigo can see both the instructions and your code and offer suggestions based off of them. For example, you can ask, "Help me with this error," or, "Where do I start?" As you make changes to your code, Khanmigo keeps up and can offer personalized help based on where you are in the programming process.

    Keyboard shortcuts

    The code editor supports a number of keyboard shortcuts to make it easier to navigate.
    ActionMacPC
    UndoCmd + ZCtrl + Z
    RedoCmd + Shift + ZCtrl + Y
    CopyCmd + CCtrl + C
    PasteCmd + VCtrl + V
    Select allCmd + ACtrl + A
    FindCmd + FCtrl + F
    Save*Cmd + SCtrl + S
    Move cursor to start of lineCmd + ←Ctrl + ←
    Move cursor to end of lineCmd + →Ctrl + →
    Move cursor to start of fileCmd + ↑Ctrl + ↑
    Move cursor to end of fileCmd + ↓Ctrl + ↓
    *

    Want to join the conversation?

    No comments: