Chapter One Python Course
Chapter One Python Course
Chapter one
4. Use Cases
Web Development: JavaScript, PHP, Ruby
System Programming: C, Rust
Mobile Apps: Kotlin (Android), Swift (iOS)
Data Science & AI: Python, R
Game Development: C++, C#
WHAT IS THE PYTHON?
Python is a high-level, interpreted programming language known for its
simplicity and readability. It was created by Guido van Rossum and first
released in 1991.
KEY FEATURES OF PYTHON
Easy to learn and use: Simple, clean syntax that’s close to English.
Interpreted: Code runs line-by-line without needing to compile.
Dynamically typed: No need to declare variable types explicitly.
Versatile: Used in web development, data science, AI, automation,
scripting, and more.
Large standard library: Comes with many modules to do a lot of tasks out-
of-the-box.
Cross-platform: Runs on Windows, macOS, Linux, etc
POPULAR USES OF PYTHON:
Data science & machine learning: Libraries like pandas, NumPy,
TensorFlow.
Automation & scripting: Automate repetitive tasks.
Game development: Libraries like Pygame.
Education: Widely used to teach programming because of its simplicity.
Desktop Application(Tkinter).
TEXT EDITOR
Lightweight programs mainly for writing and editing code or text. Usually
don’t have built-in compilers or debuggers. Can be extended with plugins
to add more features
Examples:
Notepad++ — Simple, Windows-based text editor with syntax highlighting.
Sublime Text — Fast, extensible, popular among developers.
Vim — Powerful, keyboard-driven editor, widely used in terminals
IDE STANDS FOR
INTEGRATED DEVELOPMENT
ENVIRONMENT.
It’s a software application that provides developers with a set of tools
to write, test, and debug code efficiently in one place
Feature Description
A text editor with features like
Code Editor syntax highlighting, auto-
completion, and formatting.
Translates your code into
Compiler/Interpreter
machine code so it can run.
Helps find and fix errors in your
Debugger code by inspecting the flow and
variables during execution.
Tools to automate repetitive
Build Automation Tools tasks like compiling and running
code.
Integration with systems like Git
Version Control
to track changes to your code.
EXAMPLES OF IDE
Visual Studio Code (VS Code) — Lightweight but with many IDE
features through extensions.
PyCharm — Specialized IDE for Python development.
IntelliJ IDEA — Popular for Java and Kotlin.
Eclipse — Used mainly for Java and C++.
Android Studio — Official IDE for Android app development.
Visual Studio — Powerful IDE mainly for .NET and C++.
CREATING CODE WITH
PYTHON
VS Code is a text editor. In addition to editing text, you can visually browse files and run text-
based commands at a terminal.
In the terminal, you can execute code hello.py to start coding.
In the text editor above, you can type print("hello, world"). This is a famous canonical
program that nearly all coders write during their learning process.
In the terminal window, you can execute commands. To run this program, you are going to
need to move your cursor to the bottom of the screen, clicking in the terminal window. You
can now type a second command in the terminal window. Next to the dollar sign, type python
hello.py and press the enter key on your keyboard.
Recall that computers really only understand zeros and ones. Therefore, when you run python
hello.py, Python will interpret the text that you created in hello.py and translate it into the
zeros and ones that the computer can understand.
The result of running the python hello.py program is hello, world.
FUNCTIONS
Functions are verbs or actions that the computer or computer language will
already know how to perform.
In your hello.py program, the print function knows how to print to the
terminal window.
The print function takes arguments. In this case, "hello, world" are the
arguments that the print function takes.
BUGS
Bugs are a natural part of coding. These are mistakes, problems for you to
solve! Don’t get discouraged! This is part of the process of becoming a great
programmer.
Imagine that in our hello.py program we accidentally typed print("hello,
world", forgetting the final ) required by the print function. If you make this
mistake, the interpreter will output an error in the terminal window!
Error messages can often inform you of your mistakes and provide clues on
how to fix them. However, there will be many times when the interpreter is
not this helpful.
BUGS
Bugs are a natural part of coding. These are mistakes, problems for you to
solve! Don’t get discouraged! This is part of the process of becoming a great
programmer.
Imagine that in our hello.py program we accidentally typed print("hello,
world", forgetting the final ) required by the print function. If you make this
mistake, the interpreter will output an error in the terminal window!
Error messages can often inform you of your mistakes and provide clues on
how to fix them. However, there will be many times when the interpreter is
not this helpful.
IMPROVING YOUR FIRST
PYTHON PROGRAM
We can personalize your first Python program.
In our text editor in hello.py we can add another function. input is a function
that takes a prompt as an argument. We can edit our code to say
This edit alone, however, will not allow your program to output what your
user inputs. For that, we will need to introduce you to variables
VARIABLES
A variable is just a container for a value within your own program.
In your program, you can introduce your own variable in your program by
editing it to read.
Notice that this equal = sign in the middle of name = input("What's your
name? ") has a special role in programming. This equal sign literally assigns
what is on the right to what is on the left. Therefore, the value returned by
input("What's your name? ") is assigned to name.
VARIABLES
End attributes
Code
x = float(input("What's x? "))
y = float(input("What's y? "))
print(x + y)
This change allows your user to enter 1.2 and 3.4 to present a total of
4.6.
EXAMPLE USING ROUND
METHOD
# Get the user's input
x = float(input("What's x? "))
y = float(input("What's y? "))
# Ask the user for their name, remove whitespace from the str and capitalize the
first letter of each word
name = input("What's your name? ").strip().title()