Objective: Understand what coding is and why it’s important. Get introduced to common programming languages and how code interacts with computers.
Coding is the process of giving instructions to a computer to perform specific tasks. It’s like writing a recipe or a set of directions, where each step is an instruction the computer needs to follow exactly.
Imagine you’re trying to tell someone how to make a sandwich, but they have to follow your instructions without guessing or improvising. If you say, "Put peanut butter," they might put it on the table if you didn't specify "on the bread!" Coding works the same way; you need to be clear and precise.
Coding is used in everything from mobile apps and websites to medical devices and financial systems. Learning to code can help you create your own programs, solve problems, or even build the next popular app. And coding is fun! It’s about using logic to solve real problems.
For this course, we’ll use Python because it’s beginner-friendly, versatile, and widely used.
Imagine you have to give instructions to someone to walk through a maze blindfolded. Try writing a set of clear, step-by-step directions that someone could follow without confusion. This exercise will help you think in "instructions" like a computer does.
Example:
Objective: Learn how to set up Python on your computer and write your first program.
>>>
>>>
symbol is called the Python "prompt," where you can type commands and see instant results.Let's start with a classic beginner program, called "Hello, World!"
Explanation: The print
function displays whatever is inside the parentheses on the screen. Here, it printed "Hello, World!" Try changing the text inside the quotes and running it again!
Write a program that prints your name. For example:
Expected output: Replace [Your Name]
with your actual name. This will get you familiar with using print
to display messages.
Objective: Learn the basic building blocks of programming: variables, data types, and syntax.
A variable is like a container that stores information. Think of it as a labeled box that you can put something into, like a number or a word.
Try typing these examples in IDLE:
name
stores the text "Alice"
, age
stores the number 15
, and height
stores the decimal number 5.8
.Create variables that store:
Example:
Every piece of information in Python has a specific "type":
"Hello"
).10
, 2023
).3.14
, 5.8
).Try this:
Use type()
to check the type:
Syntax is the set of rules that define how programs are written and interpreted. Just like in English, a sentence needs correct grammar, code needs correct syntax.
Example: Notice how Python uses indentation and colons to organize blocks of code.
This is just the beginning! The next lessons would introduce conditionals, loops, functions, and more.