Python 3 beginner course · Chapter 1 of 10
This chapter explains Getting Started: Python 3, Installation, IDLE and Editors in plain language. Read the concept, run the example, check the result and change one part to learn by doing. Optional packages are identified in their sections.
What Python is and where it is used
Python is a readable programming language used for automation, web services, data work and many other tasks. A program is a set of statements; modules help organize those statements. Begin with small scripts you can run and change yourself.
Python example
print("Hello, Python!")Expected result: Hello, Python!
Practice: Predict the result before running the example. Change one value or line and explain the new result.
Python 2 versus Python 3
Python 2 is a legacy version. Use Python 3 for new learning and projects. A visible difference is that print is a function in Python 3, so it uses parentheses. When reading old examples, check the version before copying syntax.
Python example
print("I am learning Python 3")Expected result: I am learning Python 3
Practice: Predict the result before running the example. Change one value or line and explain the new result.
Install Python and check the interpreter
Download Python from python.org. On Windows, the Python launcher can run the installed Python 3; on macOS or Linux, the command is often python3. A virtual environment keeps project packages separate.
Terminal example
py -3 --version
python3 --versionExpected result: Use the command available on your system; it prints a Python 3 version.
Practice: Predict the result before running the example. Change one value or line and explain the new result.
Run Python in IDLE
IDLE is a simple editor and interactive shell that ships with many Python installations. The >>> prompt evaluates one line immediately. Save a .py file to run several lines together.
Python example
2 + 3
print("Done")Expected result: In the shell, the expression shows 5 and print shows Done.
Practice: Predict the result before running the example. Change one value or line and explain the new result.
Use Thonny for beginner projects
Thonny is a beginner-oriented Python editor. Create a file, type a small program, press Run and inspect variables when a result surprises you. The editor helps you see each step rather than guessing.
Python example
name = "Maya"
print("Hello", name)Expected result: Hello Maya
Practice: Predict the result before running the example. Change one value or line and explain the new result.
Use PyCharm or another full editor
PyCharm helps organize larger projects and manage a selected Python interpreter. Verify the project interpreter before running code; using the wrong environment is a common cause of missing-package errors. The same .py file works in other editors.
Python example
def greet(name):
return f"Hello, {name}"
print(greet("Maya"))Expected result: Hello, Maya
Practice: Predict the result before running the example. Change one value or line and explain the new result.
Quick review
Explain the main idea to a friend in one sentence. Then recreate one example without looking at the code. If it fails, read the error message and compare the indentation and names.
Continue through the complete Python learning path. These are original explanations and diagrams; the topic checklist was compared with the w3resource Python index and the official Python tutorial.
No comments:
Post a Comment
Please do not enter any spam link in the comment box.